pi-build/functions/utility.function

436 wiersze
11 KiB
Plaintext
Czysty Zwykły widok Historia

2020-06-14 14:06:45 +00:00
##################################
# DIPOLE CALC
##################################
DIPOLE(){
cd $HOME/bin
wget --tries 2 --connect-timeout=60 https://raw.githubusercontent.com/km4ack/pi-scripts/master/dipole
chmod +x dipole
cat > dipole.desktop <<EOF
[Desktop Entry]
Name=Dipole Calculator
GenericName=Dipole Calc
Comment=Dipole Calculator
Exec=$HOME/bin/dipole
Icon=/usr/share/icons/Adwaita/scalable/apps/accessories-calculator-symbolic.svg
Terminal=false
Type=Application
Categories=HamRadio;
EOF
sudo mv dipole.desktop /usr/share/applications/
}
##################################
# Call Lookup
##################################
CALLSIGN(){
cd $HOME/bin
wget --tries 2 --connect-timeout=60 https://raw.githubusercontent.com/km4ack/pi-scripts/master/getcall
chmod +x getcall
cat > getcall.desktop <<EOF
[Desktop Entry]
Name=Call Sign Lookup
GenericName=Call sign lookup utility
Comment=Call sign lookup utility
Exec=$HOME/bin/getcall
Icon=/usr/share/icons/Adwaita/scalable/apps/user-info-symbolic.svg
Terminal=false
Type=Application
Categories=HamRadio;
EOF
sudo mv getcall.desktop /usr/share/applications/
}
##################################
# Temp Convert
##################################
TEMPCONVERT(){
if ! hash bc 2>/dev/null; then
sudo apt-get install -y bc
fi
cd $HOME/bin
wget --tries 2 --connect-timeout=60 https://raw.githubusercontent.com/km4ack/pi-scripts/master/converttemp
chmod +x converttemp
cat > converttemp.desktop <<EOF
[Desktop Entry]
Name=Temperature Converter
GenericName=Temperature Converter
Comment=Utility to convert temperature
Exec=$HOME/bin/converttemp
Icon=/usr/share/icons/Adwaita/22x22/actions/mark-location.png
Terminal=false
Type=Application
Categories=HamRadio;
EOF
sudo mv converttemp.desktop /usr/share/applications/
}
##################################
# GPARTED
##################################
GPARTED(){
sudo apt-get install -y gparted
}
##################################
# Log Viewer | Showlog
##################################
SHOWLOG(){
cd $HOME/bin
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/showlog
chmod +x showlog
cat > showlog.desktop <<EOF
[Desktop Entry]
Name=Log Viewer
GenericName=KM4ACK Log Viewer
Comment=Log File Viewer
Exec=$HOME/bin/showlog
Icon=/usr/share/icons/PiXflat/48x48/apps/fm-details.png
Terminal=false
Type=Application
Categories=Utility
EOF
sudo mv showlog.desktop /usr/share/applications/
}
##################################
# Real Time Clock
##################################
#Based on directions from the following web site
#https://thepihut.com/blogs/raspberry-pi-tutorials/17209332-adding-a-real-time-clock-to-your-raspberry-pi
RTC(){
DOUBLE=$(sudo i2cdetect -y 1 | grep UU)
if [ -n "$DOUBLE" ]; then
yad --form --width=500 --text-align=center --center --title="Build-a-Pi" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="Real Time Clock already installed" \
--button=gtk-close
2020-09-24 15:34:20 +00:00
#exit statement here causes script to exit without finishing. Reference link next line
#https://github.com/km4ack/pi-build/issues/139
else
2020-06-14 14:06:45 +00:00
IC2ACTIVE=$(ls /dev/*i2c*)
if [ $IC2ACTIVE = '/dev/i2c-1' ]
then
echo "IC2 is active"
else
yad --form --width=500 --text-align=center --center --title="Build-a-Pi" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="Please enable IC2 interface in the Raspberry Pi Configuration and try again" \
--button=gtk-close
exit 1
fi
NOW=$(date)
INFO=$(yad --form --width=500 --text-align=center --center --title="Build-a-Pi" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="<b>System time is $NOW</b>" \
--field="Is this Correct":CB "yes|no" \
--button="Continue")
echo $?
TIME=$(echo $INFO | awk -F "|" '{print $1}')
if [ $TIME = 'no' ]; then
yad --form --width=500 --text-align=center --center --title="Build-a-Pi" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="Please set time on the Raspberry Pi and try again. You can set time \
by connecting to the internet or attaching a GPS" \
--button=gtk-close
exit 1
fi
CLOCK=$(sudo i2cdetect -y 1 | grep 68)
if [ -z "$CLOCK" ]; then
yad --form --width=500 --text-align=center --center --title="Build-a-Pi" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="Real Time Clock not detected. Please be sure the RTC is installed and seated firmly" \
--button=gtk-close
exit 1
else
sudo modprobe rtc-ds1307
echo "ds1307 0x68" | sudo tee -a /sys/class/i2c-adapter/i2c-1/new_device
sudo hwclock -w
echo rtc-ds1307 | sudo tee -a /etc/modules
sudo sed -i 's/exit\ 0//' /etc/rc.local
echo "echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "sudo hwclock -s" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "date" | sudo tee -a /etc/rc.local > /dev/null 2>&1
echo "exit 0" | sudo tee -a /etc/rc.local > /dev/null 2>&1
yad --form --width=500 --text-align=center --center --title="Build-a-Pi" --text-align=center \
--image $LOGO --window-icon=$LOGO --image-on-top --separator="|" --item-separator="|" \
--text="Real Time Clock has been installed and configured" \
--button=gtk-close
fi
2020-09-24 15:34:20 +00:00
fi #close first if/then statement
2020-06-14 14:06:45 +00:00
}
2020-08-20 17:42:52 +00:00
##################################
# PISTATS
##################################
PISTATS(){
cd $HOME
CUR=$(curl -s http://www.w1hkj.com/pi3/ | grep .tgz | sed 's/.*pistats//' | sed 's/<\/a><br>//')
wget http://www.w1hkj.com/pi3/pistats$CUR
tar -xzvf pistats$CUR
rm pistats$CUR
PISTATDIR=$(ls $HOME | grep pistats)
cd $PISTATDIR
sudo apt-get install -y libfltk1.3-dev
make
sudo mv pistats /usr/local/bin
sudo mv $HOME/$PISTATDIR/data/pistats.desktop /usr/share/applications/
cd $HOME
rm -rf $PISTATDIR
}
2020-06-14 14:06:45 +00:00
2020-09-24 18:27:03 +00:00
##################################
# TELNET
##################################
TELNET(){
sudo apt install -y telnet
}
2020-06-14 14:06:45 +00:00
2020-09-24 19:16:07 +00:00
##################################
# PiQtTermTCP
##################################
PITERM(){
cd $DIR
wget https://www.cantab.net/users/john.wiseman/Downloads/Beta/piQtTermTCP
sudo chmod +x piQtTermTCP
sudo mv piQtTermTCP /usr/local/bin/
2020-06-14 14:06:45 +00:00
2020-09-24 19:16:07 +00:00
cat > piqttermtcp.desktop <<EOF
[Desktop Entry]
Name=PiQtTermTCP
GenericName=PiQtTermTCP
Comment=Terminal Program
Exec=/usr/local/bin/piQtTermTCP
Icon=/usr/share/icons/gnome/22x22/apps/xscreensaver.png
Terminal=false
Type=Application
Categories=Utility
EOF
2020-06-14 14:06:45 +00:00
2020-09-24 19:16:07 +00:00
sudo mv piqttermtcp.desktop /usr/share/applications/
}
2020-06-14 14:06:45 +00:00
2020-09-24 20:03:59 +00:00
##################################
# Security Tools
##################################
SECURITY(){
2020-10-11 22:27:42 +00:00
cd $HOME/bin
2020-09-24 20:03:59 +00:00
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/security-tools
bash security-tools
2020-06-14 14:06:45 +00:00
2020-09-24 20:03:59 +00:00
sudo mv $HOME/bin/securefile /usr/local/bin
2020-06-14 14:06:45 +00:00
2020-09-24 20:03:59 +00:00
cat > secure-file.desktop <<EOF
[Desktop Entry]
Name=SSE File Encryptor
GenericName=SSE File Encryptor
Comment=A program to encrypt files on the pi
Exec=/usr/local/bin/securefile
Icon=/usr/share/icons/gnome/22x22/actions/lock.png
Terminal=false
Type=Application
Categories=Utility
EOF
2020-06-14 14:06:45 +00:00
2020-09-24 20:03:59 +00:00
sudo mv secure-file.desktop /usr/share/applications/
}
2020-06-14 14:06:45 +00:00
2020-10-11 22:27:42 +00:00
##################################
# YGATE
##################################
YGATE(){
cd $HOME/bin
wget https://raw.githubusercontent.com/craigerl/ygate/master/ygate.py
2020-10-11 23:16:36 +00:00
chmod +x ygate.py
2020-06-14 14:06:45 +00:00
2020-10-11 22:27:42 +00:00
cat > ygate.desktop <<EOF
[Desktop Entry]
Name=YGATE
GenericName=YGATE
Comment=Yaesu APRS Application
2020-10-14 16:41:42 +00:00
Exec=$HOME/bin/ygate.py
2020-10-11 22:27:42 +00:00
Terminal=true
Type=Application
Categories=Utility
EOF
2020-06-14 14:06:45 +00:00
2020-10-11 22:27:42 +00:00
sudo mv ygate.desktop /usr/share/applications/
}
2020-06-14 14:06:45 +00:00
2020-10-13 21:14:10 +00:00
##################################
# BPQ
##################################
BPQ(){
2020-10-13 22:29:40 +00:00
source $HOME/pi-build/config
2020-10-13 21:14:10 +00:00
#install LinBPQ
cd
2020-10-13 22:29:40 +00:00
##########################################################################
#commands below this line were taken from John Wiseman's install script.
#and modded to pull the operators call sign from the BAP config file.
#http://www.cantab.net/users/john.wiseman/Downloads/installLinRMS
##########################################################################
export LINBPQ=pilinbpq;
export APRS=piBPQAPRS
echo "Downloading $LINBPQ and $APRS to linbpq and bpqaprs"
mkdir linbpq
cd linbpq
wget -nv http://www.cantab.net/users/john.wiseman/Downloads/Beta/$LINBPQ -O linbpq
chmod +x linbpq
wget -nv http://www.cantab.net/users/john.wiseman/Downloads/Beta/$APRS -O bpqaprs
chmod +x bpqaprs
echo "Downloading config files"
wget -nv http://www.cantab.net/users/john.wiseman/Downloads/SimpleRMSGateway_bpq32.cfg -O bpq32.cfg
echo "Downloading HTML Files"
mkdir HTML
cd HTML
wget -nv http://www.cantab.net/users/john.wiseman/Downloads/Beta/HTMLPages.zip
unzip -o -q HTMLPages.zip
rm HTMLPages.zip
cd ..
wget -nv http://www.cantab.net/users/john.wiseman/Downloads/LinBPQAPRS.zip
unzip -o -q LinBPQAPRS.zip
rm LinBPQAPRS.zip
echo "Updating your callsign in configuration files"
#read -e -p "Enter Your Callsign (Without SSID): " CALL
CALL=$(echo "$CALL" | tr '[:lower:]' '[:upper:]')
sed -i "s/MYCALL/$CALL/g" bpq32.cfg
#####################################################
#End John Wiseman install script
#####################################################
2020-10-13 21:14:10 +00:00
#install BPQ config generator
cd $HOME/linbpq
wget https://www.cantab.net/users/john.wiseman/Downloads/Beta/piBPQConfigGen
chmod +x piBPQConfigGen
cat > bpq-config.desktop <<EOF
[Desktop Entry]
Name=BPQ Config Generator
GenericName=BPQ Config Generator
Comment=Config File Generator for LinBPQ
2020-10-14 16:41:42 +00:00
Exec=$HOME/linbpq/piBPQConfigGen
2020-10-13 21:14:10 +00:00
Terminal=false
Type=Application
Categories=Utility
EOF
2020-06-14 14:06:45 +00:00
2020-10-13 21:14:10 +00:00
sudo mv bpq-config.desktop /usr/share/applications/
2020-10-13 22:09:08 +00:00
#add LinBPQ-README to desktop
FILE=$HOME/Desktop/LinBPQ-README
touch $FILE
cat << EOF > $FILE
LinBPQ was installed during the build.
You will find the config file generator
2021-01-10 17:20:15 +00:00
under accessories in the main pi menu.
2020-10-13 22:09:08 +00:00
NO CONFIGURATION was done for LinBPQ
during the build. Each individual
operator is responsible for configuring
his/her station.
After completing the config file, you can
start LinBPQ from the command line by running:
~/linbpq/.linbpq
Depending on your station setup, you may
need to start rig control, direwolf, or
other applications before running LinBPQ.
If you need help, you can find
the LinBPQ forums at
https://groups.io/g/bpq32/topics
2020-10-13 22:29:40 +00:00
and the main LinBPQ web page at
http://g8bpq.org.uk
2020-10-13 22:09:08 +00:00
EOF
2020-10-13 21:14:10 +00:00
}
2020-06-14 14:06:45 +00:00
2020-10-14 16:41:42 +00:00
##################################
# Battery Test Script
##################################
BATT(){
cd $HOME/bin
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/batt-test
chmod +x batt-test
cat > battery-test.desktop <<EOF
[Desktop Entry]
Name=Battery Test Script
GenericName=Battery Test Script
Comment=Battery Test Utility
Exec=$HOME/bin/batt-test
Terminal=true
Type=Application
Categories=Utility
EOF
sudo mv battery-test.desktop /usr/share/applications/
}
2020-10-15 12:04:44 +00:00
##################################
# VNC Viewer
##################################
VNC(){
cd $HOME
PACKAGE=$(curl -s https://www.realvnc.com/en/connect/download/viewer/raspberrypi/ | grep .deb | awk '{print $2}' | \
sed 's/href="\/download\/file\/viewer.files\///' | sed 's/"//')
2020-10-14 22:55:11 +00:00
2020-10-15 12:04:44 +00:00
wget https://realvnc.com/download/file/viewer.files/$PACKAGE
sudo dpkg -i $PACKAGE
rm $PACKAGE
}
2020-10-14 16:41:42 +00:00
2021-01-11 17:06:24 +00:00
##################################
# ZYGRIB Viewer
##################################
ZYGRIB(){
sudo apt install -y zygrib
sudo apt install -y zygrib-maps
}
2020-10-14 16:41:42 +00:00
2020-06-14 14:06:45 +00:00