pi-build/functions/utility.function

479 wiersze
14 KiB
Plaintext

##################################
# DIPOLE CALC
##################################
DIPOLE() {
cd ${HOME}/bin || exit
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 || exit
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 || exit
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 || exit
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
#exit statement here causes script to exit without finishing. Reference link next line
#https://github.com/km4ack/pi-build/issues/139
else
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
fi #close first if/then statement
}
##################################
# PISTATS
##################################
PISTATS() {
cd ${HOME} || exit
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} || exit
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} || exit
rm -rf "${PISTATDIR}"
}
##################################
# TELNET
##################################
TELNET() {
sudo apt install -y telnet
}
##################################
# PiQtTermTCP
##################################
PITERM() {
cd ${DIR} || exit
wget https://www.cantab.net/users/john.wiseman/Downloads/Beta/piQtTermTCP
sudo chmod +x piQtTermTCP
sudo mv piQtTermTCP /usr/local/bin/
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
sudo mv piqttermtcp.desktop /usr/share/applications/
}
##################################
# Security Tools
##################################
SECURITY() {
cd ${HOME}/bin || exit
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/security-tools
bash security-tools
sudo mv ${HOME}/bin/securefile /usr/local/bin
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
sudo mv secure-file.desktop /usr/share/applications/
}
##################################
# YGATE
##################################
YGATE() {
cd ${HOME}/bin || exit
wget https://raw.githubusercontent.com/craigerl/ygate/master/ygate.py
chmod +x ygate.py
cat >ygate.desktop <<EOF
[Desktop Entry]
Name=YGATE
GenericName=YGATE
Comment=Yaesu APRS Application
Exec=${HOME}/bin/ygate.py
Terminal=true
Type=Application
Categories=Utility
EOF
sudo mv ygate.desktop /usr/share/applications/
}
##################################
# BPQ
##################################
BPQ() {
source ${HOME}/pi-build/config || exit
#install LinBPQ
cd || exit
##########################################################################
#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 || exit
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 || exit
wget -nv http://www.cantab.net/users/john.wiseman/Downloads/Beta/HTMLPages.zip
unzip -o -q HTMLPages.zip
rm HTMLPages.zip
cd .. || exit
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
#####################################################
#install BPQ config generator
cd ${HOME}/linbpq || exit
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
Exec=${HOME}/linbpq/piBPQConfigGen
Terminal=false
Type=Application
Categories=Utility
EOF
sudo mv bpq-config.desktop /usr/share/applications/
#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
under accessories in the main pi menu.
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
and the main LinBPQ web page at
http://g8bpq.org.uk
EOF
}
##################################
# Battery Test Script
##################################
BATT() {
cd ${HOME}/bin || exit
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/
}
##################################
# VNC Viewer
##################################
VNC() {
cd ${HOME} || exit
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/"//')
wget https://realvnc.com/download/file/viewer.files/${PACKAGE}
sudo dpkg -i ${PACKAGE}
rm ${PACKAGE}
}
##################################
# ZYGRIB Viewer
##################################
ZYGRIB() {
sudo apt install -y zygrib
sudo apt install -y zygrib-maps
}
##################################
# GPS update tool
##################################
GPSUPDATE() {
#remove existing file if needed before installing
if [ -f ${HOME}/bin/gpsupdate ]; then
rm ${HOME}/bin/gpsupdate
fi
cd ${HOME}/bin || exit
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/gpsupdate
chmod +x gpsupdate
cat >gpsupdate.desktop <<EOF
[Desktop Entry]
Name=GPS Update Tool
GenericName=Used to change between GPS units
Comment=Used to change between GPS units
Exec=${HOME}/bin/gpsupdate
Terminal=false
Type=Application
Categories=Utility
EOF
sudo mv gpsupdate.desktop /usr/share/applications/
}
##################################
# removeMS Tool
##################################
REMOVEMS() {
#download the file
cd ${HOME}/bin || exit
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/removeMS
chmod +x ${HOME}/bin/removeMS
#place user directions on desktop
cat <<EOF >${HOME}/Desktop/Block-Microsoft.txt
You have chosen to install the removeMS
script which will block the Pi from accessing
the Microsoft repository. The block has not
been applied yet. To apply the block, open a
terminal window and run the following command:
removeMS
You only need to perform the block one time for
each Pi. You can delete the removeMS script
from your system by running:
rm ~/bin/removeMS
More information is available in this video
https://youtu.be/I7jLVgnnUW0
EOF
}