pi-build/functions/base.function

278 wiersze
8.4 KiB
Plaintext

#this installs the basic software for build-a-pi
#km4ack 20200513
TEMPCRON=${MYPATH}/cron.tmp
DIR=${MYPATH}/temp
mkdir -p ${DIR}
BUILDDIR=$HOME/.bap-source-files
mkdir -p ${BUILDDIR}
source ${MYPATH}/config
CLEANSOURCE(){
#this function removes any old source files before
#new files are downloaded for installation. This
#function is called by install functions below.
PACKAGE=$(ls $BUILDDIR | grep $PACKAGE)
if [ -d $BUILDDIR/$PACKAGE ]; then
sudo rm -rf $BUILDDIR/$PACKAGE*
fi
}
################################
# HOTSPOT
################################
HOTSPOT() {
HS="/usr/bin/autohotspotN"
if [ ! -f "${HS}" ]; then
#pass variables with script because run as root
sudo bash ${MYPATH}/functions/autohotspot "${SHACKSSID}" "${SHACKPASS}" "${HSPASS}"
echo "*/5 * * * * sudo /usr/bin/autohotspotN >/dev/null 2>&1" >>${TEMPCRON}
else
echo ################################
echo ################################
echo " FATAL ERROR"
echo "HOTSPOT ALREADY INSTALLED ONCE"
echo " CANNOT INSTALL AGAIN"
echo " WILL CONTINUE IN 10 SECONDS"
echo ################################
echo ################################
sleep 10
fi
}
################################
# HOTSPOT TOOLS
################################
HSTOOLS() {
if [ -d ${HOME}/hotspot-tools2 ]; then
rm -rf ${HOME}/hotspot-tools2
fi
git clone https://github.com/km4ack/hotspot-tools2.git ${HOME}/hotspot-tools2
cat <<EOF > /run/user/$UID/hotspot-tools.desktop
[Desktop Entry]
Name=Hotspot Tools
GenericName=Tools to Manage AutoHotSpot
Comment=Tools to Manage AutoHotSpot
Exec=/home/`whoami`/hotspot-tools2/hstools
Icon=/home/`whoami`/hotspot-tools2/logo.png
Terminal=false
Type=Application
Categories=HamRadio;
EOF
sudo cp /run/user/$UID/hotspot-tools.desktop /usr/share/applications/hotspot-tools.desktop
}
################################
# GPS
################################
GPS() {
cd ${BUILDDIR} || return
echo "##########################"
echo "# Installing GPS #"
echo "##########################"
sudo apt install -y python3-gps gpsd-tools gpsd-clients gpsd chrony python3-gi-cairo libgps-dev
sudo mv /etc/default/gpsd /etc/default/gpsd.org
sudo wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/gpsd -P /etc/default/
CHRONYCHK=$(grep "refclock SHM 0 offset 0.5 delay 0.2 refid NMEA" /etc/chrony/chrony.conf)
if [ -z "$CHRONYCHK" ]; then
echo "refclock SHM 0 offset 0.5 delay 0.2 refid NMEA" | sudo tee -a /etc/chrony/chrony.conf
fi
#line below added per this issue - https://github.com/km4ack/pi-build/issues/146 24SEPT2020
ln -s /lib/systemd/system/gpsd.service /etc/systemd/system/multi-user.target.wants/
OLDCODE(){
#code below built gpsd from source. This is no longer needed with the release of
#bullseye in late 2021. We can now isntall gpsd with apt.
#begin gpsd change 11OCT2021 - see https://github.com/km4ack/pi-build/issues/316
sudo apt-get -y install scons libncurses5-dev python-dev pps-tools chrony python-gi-cairo
sudo ldconfig
cd ${BUILDDIR}
wget http://download.savannah.gnu.org/releases/gpsd/gpsd-3.23.1.tar.gz
tar -xzf gpsd-3.23.1.tar.gz
rm gpsd-3.23.1.tar.gz
cd gpsd-3.23.1/
scons prefix=/usr --config=force
sudo scons udev-install
sudo ldconfig
sudo scons clean
sudo wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/gpsd -P /etc/default/
CHRONYCHK=$(grep "refclock SHM 0 offset 0.5 delay 0.2 refid NMEA" /etc/chrony/chrony.conf)
if [ -z "$CHRONYCHK" ]; then
echo "refclock SHM 0 offset 0.5 delay 0.2 refid NMEA" | sudo tee -a /etc/chrony/chrony.conf
fi
#end gpsd change 11OCT2021
}
#Set GPS by serial ID
#GPS Variable set by main script or update script and placed in config file
if [ "$GPS" != 'NONE' ]; then
sudo sed -i "s|DEVICES.*$|DEVICES=\"$GPS\"|g" /etc/default/gpsd
fi
#add xgps to menu
cat >xgps.desktop <<EOF
[Desktop Entry]
Name=XGPS
GenericName=XGPS
Comment=GPS Date Viewer
Exec=/usr/bin/xgps
Icon=/usr/share/icons/Adwaita/scalable/devices/thunderbolt-symbolic.svg
Terminal=false
Type=Application
Categories=Utility
EOF
sudo mv xgps.desktop /usr/share/applications/
}
################################
# ARDOP
################################
ARDOP() {
if [ -f ${HOME}/ardop/piardopc; then
rm ${HOME}/ardop/piardopc
fi
mkdir -p ${HOME}/ardop
cd ${HOME}/ardop || return
#determine if 64 bit and install correct dependencies.
if [ `getconf LONG_BIT` = '64' ]; then
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install -y libqt5widgets5:armhf libqt5serialport5:armhf libasound2:armhf libasound2-plugins:armhf
fi
wget --tries 2 --connect-timeout=60 https://www.cantab.net/users/john.wiseman/Downloads/Beta/piardopc
sudo chmod +x ${HOME}/ardop/piardopc
}
################################
# ARDOP GUI
################################
ARDOPGUI() {
mkdir -p ${HOME}/ardop
cd ${HOME}/ardop || return
wget --tries 2 --connect-timeout=60 https://www.cantab.net/users/john.wiseman/Downloads/Beta/piARDOP_GUI
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}
}
################################
# VARA
################################
VARA() {
cd ${HOME}/Downloads || return
curl -O https://raw.githubusercontent.com/WheezyE/Winelink/main/install_winelink.sh && bash install_winelink.sh bap
rm ${HOME}/Downloads/install_winelink.sh
}
################################
# HAMLIB
################################
HAMLIB() {
PACKAGE=hamlib
CLEANSOURCE
sudo apt install libusb-1.0-0 libusb-1.0-0-dev
cd ${BUILDDIR} || return
NEWRIG=$(curl -s https://sourceforge.net/projects/hamlib/files/latest/download |
grep -o https://downloads.sourceforge.net/project/hamlib/hamlib/[0-9].[0-9] |
head -n 1 | awk -F "/" '{print $7}')
HAMLIBLINK=https://sourceforge.net/projects/hamlib/files/hamlib/${NEWRIG}/hamlib-${NEWRIG}.tar.gz
echo "###################################"
echo "# Installing Hamlib "
echo "###################################"
wget --tries 2 --connect-timeout=60 ${HAMLIBLINK}
tar -xzf hamlib-${NEWRIG}.tar.gz
rm hamlib-${NEWRIG}.tar.gz
cd hamlib-${NEWRIG} || return
./configure
make
sudo make install
sudo ldconfig
sudo make clean
}
################################
# DIREWOLF
################################
DIREWOLF() {
cd ${BUILDDIR} || return
git clone https://www.github.com/wb2osz/direwolf
cd ${BUILDDIR}/direwolf || return
mkdir build
cd build
sudo apt-get install -y libasound2-dev cmake libudev-dev
cmake ..
make -j 4
sudo make install
make install-conf
sudo make clean
sed -i "s/N0CALL/${CALL}/" "${HOME}/direwolf.conf"
sed -i 's/# ADEVICE plughw:1,0/ADEVICE plughw:3,0/' ${HOME}/direwolf.conf
sed -i '/#PTT\ \/dev\/ttyUSB0\ RTS/a #Uncomment line below for PTT with CAT through FLRIG\n#PTT RIG 2 localhost:4532' ${HOME}/direwolf.conf
}
################################
# AX25
################################
AX25() {
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
}
################################
# PULSE AUDIO Control
################################
PULSE() {
sudo apt-get install -y pavucontrol
}
##################################
# 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 || return
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/
}