pi-build/functions/utility.function

281 wiersze
7.0 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(){
cd $DIR
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