From 633e30248c35ef7ea8d715b50bd82444be185dad Mon Sep 17 00:00:00 2001 From: Hugh Date: Wed, 17 Mar 2021 10:36:15 -0400 Subject: [PATCH] Better error handling for cd --- build-a-pi | 6 ++-- diagnostic | 4 +-- functions/additional.function | 64 +++++++++++++++++------------------ functions/autohotspot | 6 ++-- functions/base.function | 18 +++++----- functions/flsuite.function | 28 +++++++-------- functions/utility.function | 40 +++++++++++----------- update | 8 ++--- 8 files changed, 87 insertions(+), 87 deletions(-) diff --git a/build-a-pi b/build-a-pi index 228a77d..f96154e 100755 --- a/build-a-pi +++ b/build-a-pi @@ -446,7 +446,7 @@ pcmanfm --set-wallpaper /usr/share/rpd-wallpaper/bap-wallpaper.jpg mkdir -p ${DIR} 2>/dev/null #add virtual sound card link for pulse audio -cd ${DIR} || exit +cd ${DIR} || ! echo "Failure" cat >tempsound <tempsound <>${HOME}/.bashrc chmod +x ${MYPATH}/update ${MYPATH}/build-a-pi #create build-a-pi menu item -cd ${MYPATH} || exit +cd ${MYPATH} || ! echo "Failure" cat >build-a-pi.desktop </dev/null 2>&1 LATEST=$(cat ${HOME}/patmenu2/latest | grep '^release' | sed 's/release=//') CURRENT=$(cat ${HOME}/patmenu2/changelog | grep '^release' | sed 's/release=//') @@ -303,7 +303,7 @@ echo "DIREWOLF $DIRE" >>${DIR}/apps.info echo "Pat Menu $PATMENU" >>${DIR}/apps.info echo "EES $EES" >>${DIR}/apps.info -cd ${HOME}/Desktop || exit +cd ${HOME}/Desktop || ! echo "Failure" zip -r ${CALL}-diagnostic.zip ${DIR} >/dev/null 2>&1 rm -rf ${DIR} >/dev/null 2>&1 diff --git a/functions/additional.function b/functions/additional.function index 20bc34e..5b1440d 100644 --- a/functions/additional.function +++ b/functions/additional.function @@ -177,7 +177,7 @@ EOF # M0IAX Tools ################################## M0IAX() { - cd ${DIR} || exit + cd ${DIR} || return wget http://m0iax.com/wp-content/uploads/2020/08/JS8CallUtils_RaspberryPi.zip unzip JS8CallUtils_RaspberryPi.zip rm JS8CallUtils_RaspberryPi.zip @@ -249,16 +249,16 @@ EOF # CHIRP ################################## CHIRP() { - cd ${DIR} || exit + cd ${DIR} || return wget --tries 2 --connect-timeout=60 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 || exit + cd ${HOME}/chirp || return wget --tries 2 --connect-timeout=60 https://trac.chirp.danplanet.com/chirp_daily/LATEST/$CHIRPBUILD tar -xzf $CHIRPBUILD CHIRPDIR=$(echo $CHIRPBUILD | sed 's/[.].*$//') - cd $CHIRPDIR || exit + cd $CHIRPDIR || return sudo python setup.py install pip install future } @@ -268,11 +268,11 @@ CHIRP() { ################################## GARIM() { GPKG=$(curl -s https://www.whitemesa.net/garim/src/ | grep tar.gz | tail -1 | sed 's/^.*garim/garim/' | sed 's/tar.gz.*$/tar.gz/') - cd ${DIR} || exit + cd ${DIR} || return wget --tries 2 --connect-timeout=60 https://www.whitemesa.net/garim/src/$GPKG tar -xzvf $GPKG DIRR=$(echo $GPKG | sed 's/.tar.gz//') - cd ${DIRR} || exit + cd ${DIRR} || return ./configure make sudo make install @@ -284,14 +284,14 @@ GARIM() { QSSTV() { sudo apt-get install -y g++ libfftw3-dev qt5-default libpulse-dev libhamlib-dev libasound2-dev libv4l-dev libopenjp2-7 libopenjp2-7-dev - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return #not working with 9.5.1 #TAR=$(curl -s http://users.telenet.be/on4qz/qsstv/downloads/ | grep tar.gz | sed 's/.*href="//' | sed 's/">.*$//' | tail -1) #wget --tries 2 --connect-timeout=60 http://users.telenet.be/on4qz/qsstv/downloads/$TAR #SSTVTAR=$(echo $TAR | sed 's/.tar.gz//;s/.0//') #tar -xvzf $TAR - #cd $SSTVTAR || exit + #cd $SSTVTAR || return #qmake #make #sudo make install @@ -299,7 +299,7 @@ QSSTV() { #hard code for 9.4.4 as temp wrokaround 02MARCH2021 wget --tries 2 --connect-timeout=60 http://users.telenet.be/on4qz/qsstv/downloads/qsstv_9.4.4.tar.gz tar -xvzf qsstv_9.4.4.tar.gz - cd qsstv_9.4.4 || exit + cd qsstv_9.4.4 || return qmake make sudo make install @@ -311,7 +311,7 @@ QSSTV() { # GRIDTRACKER ################################## GRIDTRACKER() { - cd ${HOME} || exit + cd ${HOME} || return sudo apt-get install -y libgconf-2-4 GRIDDLL=$(curl -s https://tagloomis.com/downloads/ | grep Arm | head -1 | sed 's/.*href="//' | sed 's/.gz.*$/.gz/') wget --tries 2 --connect-timeout=60 $GRIDDLL @@ -342,10 +342,10 @@ PROPAGATION() { sudo apt-get install -y gfortran yelp python3-gi python3-gi-cairo rarian-compat gnome-doc-utils pkg-config python3-dateutil python3-mpltoolkits.basemap python3-cairocffi libgtk-3-dev #install primary program - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return wget --tries 2 --connect-timeout=60 https://www.qsl.net/hz1jw/voacapl/downloads/voacapl-0.7.2.tar.gz tar -xzf voacapl-0.7.2.tar.gz - cd voacapl-0.7.2 || exit + cd voacapl-0.7.2 || return ./configure make sudo make install @@ -364,12 +364,12 @@ PROPAGATION() { # YAAC ################################## YAAC() { - cd ${DIR} || exit + cd ${DIR} || return #wget --tries 2 --connect-timeout=60 https://sourceforge.net/projects/yetanotheraprsc/files/YAAC.zip/ wget --tries 2 --connect-timeout=60 https://www.ka2ddo.org/ka2ddo/YAAC.zip sudo apt-get install -y openjdk-8-jre librxtx-java mkdir -p ${HOME}/YAAC - cd ${HOME}/YAAC || exit + cd ${HOME}/YAAC || return touch YAAC echo "#!/bin/bash" >>YAAC echo "java -jar ${HOME}/YAAC/YAAC.jar" >>YAAC @@ -403,16 +403,16 @@ XASTIR() { gv libcurl4-openssl-dev shapelib libshp-dev libpcre3-dev libproj-dev libdb-dev python-dev \ libax25-dev libwebp-dev libwebp-dev libgraphicsmagick1-dev festival festival-dev - cd || exit + cd || return git clone https://github.com/Xastir/Xastir.git - cd Xastir || exit + cd Xastir || return ./bootstrap.sh mkdir build - cd build || exit + cd build || return ../configure make sudo make install - cd || exit + cd || return rm -rf Xastir cat >xastir.desktop <>/etc/dhcpcd.conf #setup ip forward sed 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf -cd ${HOME}/temp || exit +cd ${HOME}/temp || return wget http://www.raspberryconnect.com/images/autohotspotN/autohotspotn-95-4/autohotspot-service.txt @@ -85,7 +85,7 @@ if [ -z "iw" ]; then #THIS MIGHT NEED TO SOME LOOKING AT -- SEE SC2157 fi #install autohotspot script -cd ${HOME}/temp || exit +cd ${HOME}/temp || return wget http://www.raspberryconnect.com/images/autohotspotN/autohotspotn-95-4/autohotspotN.txt #mod ip address for our custom setup sed -i 's/192.168.50.5/10.10.10.10/' autohotspotN.txt diff --git a/functions/base.function b/functions/base.function index 92027f5..a215cb6 100644 --- a/functions/base.function +++ b/functions/base.function @@ -44,7 +44,7 @@ HSTOOLS() { # GPS ################################ GPS() { - cd ${DIR} || exit + cd ${DIR} || return wget --tries 2 --connect-timeout=60 https://raw.githubusercontent.com/km4ack/pi-scripts/master/gpsinstall chmod +x ${DIR}/gpsinstall sudo ${DIR}/gpsinstall @@ -75,7 +75,7 @@ EOF ################################ ARDOP() { mkdir -p ${HOME}/ardop - cd ${HOME}/ardop || exit + cd ${HOME}/ardop || return wget --tries 2 --connect-timeout=60 https://www.cantab.net/users/john.wiseman/Downloads/Beta/piardopc sudo chmod +x ${HOME}/ardop/piardopc } @@ -85,7 +85,7 @@ ARDOP() { ################################ ARDOPGUI() { mkdir -p ${HOME}/ardop - cd ${HOME}/ardop || exit + 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 <\ flxmlrpc.*$//') XMPKG=$(echo ${FLXM} | sed 's/.tar.gz//') - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return wget --tries 2 --connect-timeout=60 http://www.w1hkj.com/files/flxmlrpc/${FLXM} tar -zxvf ${FLXM} rm ./*.gz #THIS IS DANGEROUS -- SEE SC2035 #build FLXMLRPC - cd ${XMPKG} || exit + cd ${XMPKG} || return ./configure --prefix=/usr/local --enable-static make sudo make install @@ -58,13 +58,13 @@ FLRIG() { RIGPKG=$(echo ${RIGTAR} | sed 's/.tar.gz//') #Download latest FLRIG - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return wget --tries 2 --connect-timeout=60 http://www.w1hkj.com/files/flrig/${RIGTAR} tar -zxvf ${RIGTAR} rm ./*.gz #THIS IS DANGEROUS -- SEE SC2035 #Build FLRIG - cd ${RIGPKG} || exit + cd ${RIGPKG} || return ./configure --prefix=/usr/local --enable-static make sudo make install @@ -80,13 +80,13 @@ FLWRAP() { WRAPPKG=$(echo ${WRAPTAR} | sed 's/.tar.gz//') #Download latest FLWRAP - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return wget --tries 2 --connect-timeout=60 http://www.w1hkj.com/files/flwrap/${WRAPTAR} tar -zxvf ${WRAPTAR} rm ./*.gz #THIS IS DANGEROUS -- SEE SC2035 #Build FLRIG - cd ${WRAPPKG} || exit + cd ${WRAPPKG} || return ./configure --prefix=/usr/local --enable-static make sudo make install @@ -102,13 +102,13 @@ FLDIGI() { FLPKG=$(echo ${FLTAR} | sed 's/.tar.gz//') #Download latest FLDIGI tar file - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return wget --tries 2 --connect-timeout=60 http://www.w1hkj.com/files/fldigi/${FLTAR} tar -zxvf ${FLTAR} rm ./*.gz #THIS IS DANGEROUS -- SEE SC2035 #build FLDIGI - cd ${FLPKG} || exit + cd ${FLPKG} || return ./configure --prefix=/usr/local --enable-static make sudo make install @@ -123,13 +123,13 @@ FLMSG() { MSGPKG=$(echo ${MSGTAR} | sed 's/.tar.gz//') #download FLMSG - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return wget --tries 2 --connect-timeout=60 http://www.w1hkj.com/files/flmsg/${MSGTAR} tar -zxvf ${MSGTAR} rm ./*.gz #THIS IS DANGEROUS -- SEE SC2035 #Build FLMSG - cd ${MSGPKG} || exit + cd ${MSGPKG} || return ./configure --prefix=/usr/local --enable-static make sudo make install @@ -144,13 +144,13 @@ FLAMP() { AMPPKG=$(echo ${AMPTAR} | sed 's/.tar.gz//') #download FLAMP - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return wget --tries 2 --connect-timeout=60 http://www.w1hkj.com/files/flamp/$AMPTAR tar -zxvf ${AMPTAR} rm ./*.gz #THIS IS DANGEROUS -- SEE SC2035 #build FLAMP - cd ${AMPPKG} || exit + cd ${AMPPKG} || return ./configure --prefix=/usr/local --enable-static make sudo make install @@ -165,13 +165,13 @@ FLNET() { NETPKG=$(echo ${NETTAR} | sed 's/.tar.gz//') #download FLNET - cd ${HOME}/Downloads || exit + cd ${HOME}/Downloads || return wget --tries 2 --connect-timeout=60 http://www.w1hkj.com/files/flnet/$NETTAR tar -zxvf ${NETTAR} rm ./*.gz #THIS IS DANGEROUS -- SEE SC2035 #build FLNET - cd ${NETPKG} || exit + cd ${NETPKG} || return ./configure --prefix=/usr/local --enable-static make sudo make install diff --git a/functions/utility.function b/functions/utility.function index c33a705..2d3be47 100644 --- a/functions/utility.function +++ b/functions/utility.function @@ -2,7 +2,7 @@ # DIPOLE CALC ################################## DIPOLE() { - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget --tries 2 --connect-timeout=60 https://raw.githubusercontent.com/km4ack/pi-scripts/master/dipole chmod +x dipole @@ -26,7 +26,7 @@ EOF # Call Lookup ################################## CALLSIGN() { - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget --tries 2 --connect-timeout=60 https://raw.githubusercontent.com/km4ack/pi-scripts/master/getcall chmod +x getcall @@ -52,7 +52,7 @@ TEMPCONVERT() { if ! hash bc 2>/dev/null; then sudo apt-get install -y bc fi - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget --tries 2 --connect-timeout=60 https://raw.githubusercontent.com/km4ack/pi-scripts/master/converttemp chmod +x converttemp @@ -83,7 +83,7 @@ GPARTED() { ################################## SHOWLOG() { - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/showlog chmod +x showlog @@ -185,18 +185,18 @@ by connecting to the internet or attaching a GPS" \ # PISTATS ################################## PISTATS() { - cd ${HOME} || exit + cd ${HOME} || return CUR=$(curl -s http://www.w1hkj.com/pi3/ | grep .tgz | sed 's/.*pistats//' | sed 's/<\/a>
//') wget http://www.w1hkj.com/pi3/pistats${CUR} tar -xzvf pistats${CUR} rm pistats${CUR} PISTATDIR=$(ls ${HOME} | grep pistats) - cd ${PISTATDIR} || exit + cd ${PISTATDIR} || return 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 + cd ${HOME} || return rm -rf "${PISTATDIR}" } @@ -211,7 +211,7 @@ TELNET() { # PiQtTermTCP ################################## PITERM() { - cd ${DIR} || exit + cd ${DIR} || return wget https://www.cantab.net/users/john.wiseman/Downloads/Beta/piQtTermTCP sudo chmod +x piQtTermTCP sudo mv piQtTermTCP /usr/local/bin/ @@ -236,7 +236,7 @@ EOF # Security Tools ################################## SECURITY() { - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/security-tools bash security-tools @@ -261,7 +261,7 @@ EOF # YGATE ################################## YGATE() { - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget https://raw.githubusercontent.com/craigerl/ygate/master/ygate.py chmod +x ygate.py @@ -284,9 +284,9 @@ EOF # BPQ ################################## BPQ() { - source ${HOME}/pi-build/config || exit + source ${HOME}/pi-build/config || return #install LinBPQ - cd || exit + cd || return ########################################################################## #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. @@ -297,7 +297,7 @@ BPQ() { echo "Downloading ${LINBPQ} and ${APRS} to linbpq and bpqaprs" mkdir linbpq - cd linbpq || exit + cd linbpq || return 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 @@ -310,11 +310,11 @@ BPQ() { echo "Downloading HTML Files" mkdir HTML - cd HTML || exit + cd HTML || return wget -nv http://www.cantab.net/users/john.wiseman/Downloads/Beta/HTMLPages.zip unzip -o -q HTMLPages.zip rm HTMLPages.zip - cd .. || exit + cd .. || return wget -nv http://www.cantab.net/users/john.wiseman/Downloads/LinBPQAPRS.zip unzip -o -q LinBPQAPRS.zip rm LinBPQAPRS.zip @@ -330,7 +330,7 @@ BPQ() { #End John Wiseman install script ##################################################### #install BPQ config generator - cd ${HOME}/linbpq || exit + cd ${HOME}/linbpq || return wget https://www.cantab.net/users/john.wiseman/Downloads/Beta/piBPQConfigGen chmod +x piBPQConfigGen @@ -380,7 +380,7 @@ EOF # Battery Test Script ################################## BATT() { - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/batt-test chmod +x batt-test @@ -403,7 +403,7 @@ EOF # VNC Viewer ################################## VNC() { - cd ${HOME} || exit + cd ${HOME} || return 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/"//') @@ -429,7 +429,7 @@ GPSUPDATE() { rm ${HOME}/bin/gpsupdate fi - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/gpsupdate chmod +x gpsupdate @@ -453,7 +453,7 @@ EOF REMOVEMS() { #download the file - cd ${HOME}/bin || exit + cd ${HOME}/bin || return wget https://raw.githubusercontent.com/km4ack/pi-scripts/master/removeMS chmod +x ${HOME}/bin/removeMS #place user directions on desktop diff --git a/update b/update index ab5b05d..7d41545 100755 --- a/update +++ b/update @@ -47,7 +47,7 @@ trap FINISH EXIT #fix issue 108 https://github.com/km4ack/pi-build/issues/108 #Thanks to N5RKS for finding the bug if [ -d ${HOME}/pi-build/temp ]; then - rm -rf ${HOME}/pi-build/temp + rm -rf "${HOME}/pi-build/temp" fi ##################################### @@ -91,8 +91,8 @@ EOF fi echo "Updating Build a Pi to $LATEST" mv ${MYPATH}/config ${HOME}/Documents/config.bap - rm -rf ${MYPATH} - cd ~ || exit + rm -rf "${MYPATH}" + cd ~ || ! echo "Failure" git clone https://github.com/km4ack/pi-build.git mv ${HOME}/Documents/config.bap ${MYPATH}/config @@ -400,7 +400,7 @@ CHECK() { if [ ! -d ${HOME}/patmenu2 ]; then PATMENU="Not_Installed" else - cd ${HOME}/patmenu2/ || exit + cd ${HOME}/patmenu2/ || ! echo "Failure" wget -O ${HOME}/patmenu2/latest https://raw.githubusercontent.com/km4ack/patmenu2/master/changelog >/dev/null 2>&1 LATEST=$(cat ${HOME}/patmenu2/latest | grep '^release' | sed 's/release=//') CURRENT=$(cat ${HOME}/patmenu2/changelog | grep '^release' | sed 's/release=//')