kopia lustrzana https://github.com/km4ack/pi-build
537 wiersze
15 KiB
Bash
537 wiersze
15 KiB
Bash
#!/bin/bash
|
|
|
|
#MAIN SCRIPT FOR NEW PI BUILD
|
|
#20191210 KM4ACK
|
|
#Credit to TB-14 for the inspiration for this script
|
|
|
|
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
|
|
APPLIST=app-list
|
|
BUILDLOG=$HOME/Documents/build-log.txt
|
|
chmod +x $MYDIR/addon-build-a-pi
|
|
|
|
|
|
|
|
#put info in build log
|
|
echo "###########SYSTEM INFO##############" >> $BUILDLOG
|
|
cat /etc/os-release >> $BUILDLOG
|
|
uname -a >> $BUILDLOG
|
|
free -m | grep Mem: | awk '{ print $2 }' >> $BUILDLOG
|
|
echo "###########END SYSTEM INFO##############" >> $BUILDLOG
|
|
|
|
#Backup cron just in case script is run twice
|
|
crontab -l > $TEMPCRON
|
|
#add part 2 to be called from cron at boot
|
|
echo "@reboot sleep 20 && export DISPLAY=:0 && lxterminal -e $HOME/pi-build/addon-build-a-pi" >> $TEMPCRON
|
|
|
|
#create primary log
|
|
touch $LOG
|
|
#create buld log
|
|
touch $BUILDLOG
|
|
|
|
if [ $WHO = "root" ]
|
|
then
|
|
echo "No need for sudo with this script"
|
|
exit 0
|
|
fi
|
|
|
|
if [ -z "$RB" ]
|
|
then
|
|
echo
|
|
else
|
|
cat <<EOF
|
|
It looks like you have run this script before
|
|
It is only designed to be run one time
|
|
It may cause issues if you try to run multiple times
|
|
Press CRTL+C to exit or
|
|
EOF
|
|
read -n 1 -s -r -p "Press any key to continue"
|
|
fi
|
|
|
|
|
|
clear;echo;echo
|
|
read -p "What is your call sign? " CALL
|
|
touch $MYDIR/callsign.txt
|
|
echo $CALL > $MYDIR/callsign.txt
|
|
cat <<EOF
|
|
Please stand by while we grab a few updates
|
|
This may take a while if you haven't already
|
|
updated the system. You will be presented with
|
|
a pop up window shortly to select which
|
|
applications you wish to install.
|
|
|
|
EOF
|
|
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
|
|
|
|
#create bin dir and add to path
|
|
mkdir -p $HOME/bin
|
|
echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bashrc
|
|
#grab add-wifi tool
|
|
cd $HOME/bin
|
|
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/add-wifi
|
|
chmod +x add-wifi
|
|
cd $HOME
|
|
|
|
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
|
|
|
|
clear;echo;echo
|
|
cat <<EOF
|
|
Decision time......
|
|
The FLDIGI suite can be built from source or downloaded from the
|
|
repository. Building from source will give you the very latest and
|
|
greatest FLDIGI suite. It will also add roughly an hour to the
|
|
build time of this script. If you choose to build from
|
|
source, many of FLDIGI tools will be installed. The
|
|
tools this script includes is FLRIG, FLDIGI, FLARQ, FLMSG, FLAMP.
|
|
|
|
EOF
|
|
read -p "Build FL suite from source? y/n " FLS
|
|
if [ $FLS = "y" ] || [ $FLS = "Y" ]
|
|
then
|
|
APPLIST=source-app-list
|
|
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/$APPLIST > $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 || echo "Can't download autohotspot script" >> $BUILDLOG
|
|
chmod +x $DIR/autohotspotN-setup
|
|
sudo $DIR/autohotspotN-setup
|
|
echo "*/5 * * * * sudo /usr/bin/autohotspotN >/dev/null 2>&1" >> $TEMPCRON
|
|
rm $DIR/autohotspotN-setup
|
|
echo "Hot spot installed" >> $BUILDLOG
|
|
fi
|
|
|
|
if [ $GPS = "yes" ] > /dev/null 2>&1
|
|
then
|
|
echo;echo;echo
|
|
echo "##################################################"
|
|
echo "##########INSTALLING GPS Tools"
|
|
echo "##################################################"
|
|
cd $DIR
|
|
wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/gpsinstall || echo "Can't download GPS Tools" >> $BUILDLOG
|
|
chmod +x $DIR/gpsinstall
|
|
sudo $DIR/gpsinstall
|
|
rm $DIR/gpsinstall
|
|
echo "GPS Tools installed" >> $BUILDLOG
|
|
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 || echo "Can't download Pat Winlink" >> $BUILDLOG
|
|
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
|
|
echo "Pat Winlink installed" >> $BUILDLOG
|
|
fi
|
|
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 || echo "Can't download HAMLIB" >> $BUILDLOG
|
|
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
|
|
echo "HAMLIB installed" >> $BUILDLOG
|
|
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
|
|
echo "CONKY installed" >> $BUILDLOG
|
|
fi
|
|
|
|
if [ $FL_Suite = "yes" ] > /dev/null 2>&1
|
|
then
|
|
echo;echo;echo
|
|
echo "##################################################"
|
|
echo "##########INSTALLING FLDIGI SUITE"
|
|
echo "##################################################"
|
|
sleep 2
|
|
|
|
chmod +x $HOME/pi-build/flsuite
|
|
$HOME/pi-build/flsuite
|
|
echo "FLDIGI SUITE installed" >> $BUILDLOG
|
|
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
|
|
echo "FLRIG installed repository" >> $BUILDLOG
|
|
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
|
|
echo "FLDIGI installed repository" >> $BUILDLOG
|
|
fi
|
|
fi
|
|
|
|
if [ $FLAMP = "yes" ] > /dev/null 2>&1
|
|
then
|
|
echo;echo;echo
|
|
echo "##################################################"
|
|
echo "##########INSTALLING FLAMP"
|
|
echo "##################################################"
|
|
sleep 2
|
|
if ! hash flamp 2>/dev/null; then
|
|
sudo apt install -y flamp
|
|
echo "FLAMP installed repository" >> $BUILDLOG
|
|
fi
|
|
fi
|
|
|
|
if [ $FLMSG = "yes" ] > /dev/null 2>&1
|
|
then
|
|
echo;echo;echo
|
|
echo "##################################################"
|
|
echo "##########INSTALLING FLMSG"
|
|
echo "##################################################"
|
|
sleep 2
|
|
if ! hash flmsg 2>/dev/null; then
|
|
sudo apt install -y flmsg
|
|
echo "FLMSG installed repository" >> $BUILDLOG
|
|
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 || echo "Can't download PIARDOPC" >> $BUILDLOG
|
|
sudo chmod +x $HOME/ardop/piardopc
|
|
echo "PIARDOPC installed" >> $BUILDLOG
|
|
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 || echo "Can't download piARDOP_GUI" >> $BUILDLOG
|
|
sudo chmod +x $HOME/ardop/piARDOP_GUI
|
|
cat > ardopgui.desktop <<EOF
|
|
[Desktop Entry]
|
|
Name=ARDOP GUI
|
|
GenericName=ARDOP GUI
|
|
Comment=Graphical User Interface for ARDOP modem
|
|
Exec=$HOME/ardop/piARDOP_GUI
|
|
Terminal=false
|
|
Type=Application
|
|
Categories=Network;HamRadio;
|
|
EOF
|
|
|
|
sudo mv ardopgui.desktop /usr/share/applications/
|
|
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
|
|
echo "ARDOP-GUI installed" >> $BUILDLOG
|
|
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 || echo "Can't download Pat Menu" >> $BUILDLOG
|
|
echo "Pat Menu installed" >> $BUILDLOG
|
|
cat > patmenu.desktop <<EOF
|
|
[Desktop Entry]
|
|
Name=Pat Menu
|
|
GenericName=Amateur Radio Digital Modem
|
|
Comment=Amateur Radio Sound Card Communications
|
|
Exec=$HOME/patmenu/patmenu-new
|
|
Icon=$HOME/patmenu/pat-logo.png
|
|
Terminal=true
|
|
Type=Application
|
|
Categories=Network;HamRadio;
|
|
EOF
|
|
|
|
sudo mv patmenu.desktop /usr/share/applications/
|
|
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 || echo "Can't download DIREWOLF" >> $BUILDLOG
|
|
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
|
|
echo "DIREWOLF installed" >> $BUILDLOG
|
|
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
|
|
echo "AX25 tools installed" >> $BUILDLOG
|
|
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 || echo "Can't Download JS8Call" >> $BUILDLOG
|
|
sudo dpkg -i $JS8PKG
|
|
sudo apt-get --fix-broken -y install
|
|
sudo dpkg -i $JS8PKG
|
|
echo "JS8Call installed" >> $BUILDLOG
|
|
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
|
|
echo "Pulse audio installed" >> $BUILDLOG
|
|
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 || echo "Can't download M0IAX Tools" >> $BUILDLOG
|
|
wget https://raw.githubusercontent.com/m0iax/js8calltools/master/gps_listener.py
|
|
wget https://raw.githubusercontent.com/m0iax/js8call_aprsmessaging_interface/master/aprs_msgJS8Call.py
|
|
wget https://raw.githubusercontent.com/m0iax/js8calltools/master/configAndSettings.py
|
|
chmod +x js8callgpsUI.py aprs_msgJS8Call.py
|
|
cat > js8msg.desktop <<EOF
|
|
[Desktop Entry]
|
|
Name=JS8Call Messenger
|
|
GenericName=JS8Call Messenger
|
|
Comment=Message Helper for JS8Call
|
|
Exec=$HOME/bin/aprs_msgJS8Call.py
|
|
Terminal=false
|
|
Type=Application
|
|
Categories=Network;HamRadio;
|
|
EOF
|
|
|
|
sudo mv js8msg.desktop /usr/share/applications/
|
|
|
|
cat > js8gps.desktop <<EOF
|
|
[Desktop Entry]
|
|
Name=JS8Call GPS Tool
|
|
GenericName=JS8Call GPS Tool
|
|
Comment=GPS Tool for JS8Call
|
|
Exec=$HOME/bin/js8callgpsUI.py
|
|
Terminal=false
|
|
Type=Application
|
|
Categories=Network;HamRadio;
|
|
EOF
|
|
|
|
sudo mv js8gps.desktop /usr/share/applications/
|
|
echo "MOIAX tools installed" >> $BUILDLOG
|
|
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 || echo "Can't download WSJTX" >> $BUILDLOG
|
|
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
|
|
echo "WSJTX installed" >> $BUILDLOG
|
|
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
|
|
|
|
sudo apt-get install -y extra-xdg-menus
|
|
|
|
crontab $TEMPCRON
|
|
|
|
rm -rf $DIR
|
|
|
|
#clean up downloads dir
|
|
rm -rf $HOME/Downloads/*
|
|
|
|
echo;echo;echo "rebooting in 5 seconds"
|
|
sleep 5
|
|
sudo reboot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|