pi-build/build-a-pi

503 wiersze
14 KiB
Bash

#!/bin/bash
#MAIN SCRIPT FOR NEW PI BUILD
#20191210 KM4ACK
MYDIR=$HOME/pi-build
DIR=$HOME/temp
mkdir -p $DIR
TEMPCRON=$DIR/tempcron
touch $TEMPCRON
WHO=$(whoami)
RB=$(ls $HOME/.config/ | grep KM4ACK)
LOG=$HOME/Documents/mylog.txt
touch $LOG
if [ $WHO = "root" ]
then
echo "No need for sudo with this script"
exit 0
fi
if [ -z "$RB" ]
then
echo
else
echo "It looks like you have run this script before"
echo "It is only designed to be run one time"
echo "It may cause issues if you try to run multiple times"
echo "Press CRTL+C to exit or"
read -n 1 -s -r -p "Press any key to continue"
fi
clear;echo;echo
read -p "What is your call sign? " CALL
echo "Please stand by while we grab a few updates"
echo "This may take a while if you haven't already"
echo "updated the system. You will be presented with"
echo "a pop up window shortly to select which"
echo "applications you wish to install."
read -n 1 -s -r -p "Press any key to begin"
sudo apt-get update
sudo apt-get -y upgrade
sudo apt -y full-upgrade
touch $HOME/.config/KM4ACK
mkdir -p $HOME/bin
echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bashrc
if ! hash yad 2>/dev/null; then
sudo apt install -y yad
fi
if ! hash jq 2>/dev/null; then
sudo apt install -y jq
fi
##########################################
MAIN () {
yad --height=600 --width=400 --center --list --checklist --column=Install --column=App --separator="," --text "Select the apps you wish to install." --title="Build-a-Pi by KM4ACK" --button="Exit:1" --button="Install Selected:2" < $MYDIR/app-list > $MYDIR/appchoices
BUTTON=$?
if [ $BUTTON = "3" ]
then
yad --width=500 --height=500 --center --button="Close:1" --wrap --text-info < info.txt
MAIN
elif [ $BUTTON = "252" ]
then
exit 0
elif [ $BUTTON = "1" ]
then
exit 0
fi
echo $BUTTON
cat $MYDIR/appchoices | sed 's/TRUE,//g' | sed 's/,//' | sed 's/$/=yes/' > $MYDIR/config
rm $MYDIR/appchoices
};export -f MAIN
MAIN
############################################################################
source $MYDIR/config
if [ $HOTSPOT = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING AUTOHOTSPOT"
echo "##################################################"
sleep 2
cd $DIR
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/autohotspotN-setup
chmod +x $DIR/autohotspotN-setup
sudo $DIR/autohotspotN-setup
echo "*/5 * * * * sudo /usr/bin/autohotspotN >/dev/null 2>&1" >> $TEMPCRON
rm $DIR/autohotspotN-setup
fi
if [ $GPS = "yes" ] > /dev/null 2>&1
then
cd $DIR
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/gpsinstall
chmod +x $DIR/gpsinstall
sudo $DIR/gpsinstall
rm $DIR/gpsinstall
fi
if [ $CONKY = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING CONKY"
echo "##################################################"
sleep 2
if ! hash conky 2>/dev/null; then
sudo apt install -y conky
fi
sudo apt-get install -y ruby2.3
sudo gem install gpsd_client
sudo gem install maidenhead
cp $MYDIR/conky/.conkyrc $HOME/.conkyrc
mkdir -p $HOME/bin/conky
cp $MYDIR/conky/* $HOME/bin/conky/
chmod +x $HOME/bin/conky/get-grid $HOME/bin/conky/temp-conv $HOME/bin/conky/get-freq $HOME/bin/conky/grid
sed -i "s/N0CALL/$CALL/" $HOME/.conkyrc
echo "@reboot sleep 20 && export DISPLAY=:0 && /usr/bin/conky" >> $TEMPCRON
fi
if [ $FLRIG = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING FLRIG"
echo "##################################################"
sleep 2
if ! hash flrig 2>/dev/null; then
sudo apt install -y flrig
fi
fi
if [ $FLDIGI = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING FLDIGI"
echo "##################################################"
sleep 2
if ! hash fldigi 2>/dev/null; then
sudo apt install -y fldigi
fi
fi
if [ $FLAMP = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING FLAMP"
echo "##################################################"
sleep 2
if ! hash fldigi 2>/dev/null; then
sudo apt install -y flamp
fi
fi
if [ $FLMSG = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING FLMSG"
echo "##################################################"
sleep 2
if ! hash fldigi 2>/dev/null; then
sudo apt install -y flmsg
fi
fi
if [ $PAT = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING PAT WINLINK"
echo "##################################################"
sleep 2
if ! hash pat 2>/dev/null; then
cd $DIR
wget https://github.com/la5nta/pat/releases/download/v0.8.0/pat_0.8.0_linux_armhf.deb
sudo dpkg -i $DIR/pat_0.8.0_linux_armhf.deb
pat http &
sudo killall pat
sudo systemctl start pat@$WHO
sudo systemctl enable pat@$WHO
#/usr/bin/pat http &
#sudo killall pat
cd $DIR
wget https://raw.githubusercontent.com/km4ack/patmenu/master/patlogin
bash patlogin
jq '.ax25.rig = '\"my-rig\"'' $HOME/.wl2k/config.json | jq '.ardop.rig = '\"my-rig\"'' | jq '.hamlib_rigs = {'\"my-rig\"': {"address": "127.0.0.1:4532", "network": "tcp"}}' > ~/Desktop/config.json
mv ~/Desktop/config.json ~/.wl2k/config.json
sed -i "s/\"http_addr\": \".*\",/\"http_addr\": \"0.0.0.0:8080\",/" $HOME/.wl2k/config.json
#enable gps in pat is gps=yes
if [ $GPS = "yes" ]
then
sed -i 's/"enable_http": false,/"enable_http": true,/' $HOME/.wl2k/config.json
fi
fi
fi
if [ $ARDOPC = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING PIARDOPC"
echo "##################################################"
sleep 2
mkdir -p $HOME/ardop
cd $HOME/ardop
wget https://www.cantab.net/users/john.wiseman/Downloads/Beta/piardopc
sudo chmod +x $HOME/ardop/piardopc
fi
if [ $ARDOPGUI = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING ARDOP-GUI"
echo "##################################################"
sleep 2
mkdir -p $HOME/ardop
cd $HOME/ardop
wget https://www.cantab.net/users/john.wiseman/Downloads/Beta/piARDOP_GUI
sudo chmod +x $HOME/ardop/piARDOP_GUI
ln -s $HOME/ardop/piARDOP_GUI $HOME/Desktop/ARDOP-GUI
FILE=$HOME/.config/G8BPQ/ARDOP_GUI.conf
mkdir -p $HOME/.config/G8BPQ
touch $FILE
echo "[General]" >> $FILE
echo "Host=local" >> $FILE
echo "Port=8515" >> $FILE
fi
if [ $PATMENU = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING Pat Menu"
echo "##################################################"
sleep 2
git clone https://github.com/km4ack/patmenu.git $HOME/patmenu && bash $HOME/patmenu/setup
fi
if [ $HAMLIB = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING RIG CONTROL"
echo "##################################################"
sleep 2
cd $DIR
wget https://sourceforge.net/projects/hamlib/files/hamlib/3.3/hamlib-3.3.tar.gz
tar -xzf $DIR/hamlib-3.3.tar.gz
rm $DIR/hamlib-3.3.tar.gz
cd $DIR/hamlib-3.3
./configure
make
sudo make install
sudo ldconfig
fi
if [ $GARIM = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING GARIM"
echo "##################################################"
sleep 2
cd $HOME
sudo apt-get install -y fluid
wget https://www.whitemesa.net/garim/src/garim-1.1.tar.gz
tar xzvf garim-1.1.tar.gz
rm garim-1.1.tar.gz
cd $HOME/garim-1.1
./configure
make
sudo make install
fi
if [ $DIREWOLF = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING DIREWOLF"
echo "##################################################"
sleep 2
cd $HOME
git clone https://www.github.com/wb2osz/direwolf
cd $HOME/direwolf
sudo apt-get install -y libasound2-dev
make
sudo make install
make install-conf
sed -i "s/N0CALL/$CALL/" "$HOME/direwolf.conf"
sed -i 's/# ADEVICE plughw:1,0/ADEVICE plughw:1,0/' $HOME/direwolf.conf
fi
if [ $AX25 = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING AX25"
echo "##################################################"
sleep 2
sudo apt-get install -y ax25-tools
echo "wl2k "$CALL" 1200 255 7 Winlink" | sudo tee -a /etc/ax25/axports
sudo apt-get install -y ax25-apps
fi
if [ $JS8CALL = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING JS8CALL"
echo "##################################################"
sleep 2
cd $DIR
JS8LATE=$(curl -s http://files.js8call.com/latest.html | grep armhf | awk '{ print $2 }' | sed 's/href=//' | sed 's/"//g')
JS8PKG=$(curl -s http://files.js8call.com/latest.html | grep armhf | awk '{ print $2 }' | sed 's/\///g' | sed 's/href="http:files.js8call.com[0-9].[0-9].[0-9]//' | sed 's/"//')
wget $JS8LATE
sudo dpkg -i $JS8PKG
sudo apt-get --fix-broken -y install
sudo dpkg -i $JS8PKG
fi
if [ $PULSE = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING PULSE AUDIO"
echo "##################################################"
sleep 2
sudo apt-get install -y pulseaudio
sudo apt-get install -y pavucontrol
fi
if [ $M0IAX = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING M0IAX TOOLS"
echo "##################################################"
sleep 2
pip3 install gps
pip3 install maidenhead
pip3 install psutil
cd $HOME/bin
wget https://raw.githubusercontent.com/m0iax/js8calltools/master/js8callgpsUI.py
wget https://raw.githubusercontent.com/m0iax/js8calltools/master/gps_listener.py
wget https://raw.githubusercontent.com/m0iax/js8call_aprsmessaging_interface/master/aprs_msgJS8Call.py
chmod +x js8callgpsUI.py aprs_msgJS8Call.py
ln -s $HOME/bin/js8callgpsUI.py $HOME/Desktop/JS8-GPS-Tool
ln $HOME/bin/aprs_msgJS8Call.py $HOME/Desktop/JS8Call-Messenger
fi
if [ $WSJTX = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING WSJTX"
echo "##################################################"
sleep 2
cd $DIR
wget --no-check-certificate https://physics.princeton.edu/pulsar/k1jt/wsjtx_2.1.0_armhf.deb
sudo dpkg -i wsjtx_2.1.0_armhf.deb
sudo apt-get --fix-broken -y install
sudo dpkg -i wsjtx_2.1.0_armhf.deb
fi
if [ $CHIRP = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING CHIRP"
echo "##################################################"
sleep 2
cd $DIR
wget https://trac.chirp.danplanet.com/chirp_daily/LATEST/
CHIRPBUILD=$(cat index.html | grep .tar.gz | grep chirp-daily- | awk '{ print $6 }' | sed 's/.*"//' | sed 's/>//' | sed 's/[<].*$//')
sudo apt-get -y install python-gtk2 python-serial python-libxml2
mkdir $HOME/chirp
cd $HOME/chirp
wget https://trac.chirp.danplanet.com/chirp_daily/LATEST/$CHIRPBUILD
tar -xzf $CHIRPBUILD
CHIRPDIR=$(echo $CHIRPBUILD | sed 's/[.].*$//')
cd $CHIRPDIR
sudo python setup.py install
fi
if [ $XASTIR = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING XASTIR"
echo "##################################################"
sleep 2
sudo apt-get install -y xastir
sudo sed -i 's/Exec=xastir/Exec=sudo xastir/' /usr/share/applications/xastir.desktop
fi
if [ $YAAC = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING YAAC"
echo "##################################################"
sleep 2
cd $DIR
wget https://www.ka2ddo.org/ka2ddo/YAAC.zip
sudo apt-get install -y openjdk-8-jre librxtx-java
mkdir -p $HOME/YAAC
cd $HOME/YAAC
touch YAAC
echo "#!/bin/bash" >> YAAC
echo "java -jar $HOME/YAAC/YAAC.jar" >> YAAC
chmod +x YAAC
ln -sf $HOME/YAAC/YAAC $HOME/Desktop/YAAC
ln -sf $HOME/YAAC/YAAC $HOME/bin/YAAC
unzip $DIR/YAAC.zip
fi
if [ $EES = "yes" ] > /dev/null 2>&1
then
echo;echo;echo
echo "##################################################"
echo "##########INSTALLING KM4ACK EMERGENCY EMAIL SERVER"
echo "##################################################"
sleep 2
#install PHP7.3 if not installed
#this will also install apache2
if ! hash php7.3 2>/dev/null; then
sudo apt install -y php7.3
fi
#Install the KM4ACK EES
cd $DIR
wget https://github.com/km4ack/EES-LITE/archive/master.zip
unzip master.zip
sudo cp -r $DIR/EES-LITE-master/* /var/www/html/
rm -rf $DIR/EES-LITE-master
rm $DIR/master.zip
cd /var/www/html
sudo chmod +x /var/www/html/firstrun
sudo /var/www/html/./firstrun
#/var/www/html/./schedule
sudo mv /var/www/html/index.html /var/www/html/index.html.org
sudo sed -i "s/N0CALL/$CALL/" /var/www/html/config.php
sudo sed -i 's/REMINDER\ FOR\ OPERATOR\ TO\ DO\ SOMETHING/ENABLE\ AUTO\ POST\ REPLY\ IN\ CRON/' /var/www/html/config.php
cd $DIR
#Change Pat Winlink port so it won't interfer with the EES
sed -i 's/0.0.0.0:8080/0.0.0.0:5000/' $HOME/.wl2k/config.json
sed -i 's/PORT=8080/PORT=5000/' $HOME/patmenu/config
sudo killall pat
sudo systemctl start pat@pi
fi
#add virtual sound card link for pulse audio
#20191228
cd $DIR
cat > tempsound <<EOF
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
EOF
sudo chown root:root tempsound
sudo mv tempsound /etc/asound.conf
#End 20191228 edits
crontab $TEMPCRON
/var/www/html/./schedule > /dev/null 2>&1
rm -rf $DIR
echo;echo;echo "rebooting in 5 seconds"
sleep 5
sudo reboot