################################################################## # # # # # # # # # ##### # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # # # # ## # # ##### ####### # ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ##### # # # # # ################################################################## #20200620 DESK=$(printenv | grep DISPLAY) MYPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" LOGO=${MYPATH}/logo.png RB=${HOME}/.config/KM4ACK BASE=${MYPATH}/base.txt ADDITIONAL=${MYPATH}/additional.txt UTILITY=${MYPATH}/utility.txt FLSUITE=${MYPATH}/flsuite.txt CONFIG=${MYPATH}/config FUNCTIONS=${MYPATH}/functions TEMPCRON=${MYPATH}/cron.tmp DIR=${MYPATH}/temp WHO=$(whoami) VERSION=$(grep "version=" ${MYPATH}/changelog | sed 's/version=//') FINISH() { if [ -f "${BASE}" ]; then rm ${BASE} fi if [ -f "${ADDITIONAL}" ]; then rm ${ADDITIONAL} fi if [ -f "${FLSUITE}" ]; then rm ${FLSUITE} fi if [ -f "${UTILITY}" ]; then rm ${UTILITY} fi } trap FINISH EXIT #check for display. can't run from SSH if [ -z "$DESK" ]; then cat </dev/null; then sudo apt install -y yad fi if ! hash jq 2>/dev/null; then sudo apt install -y jq fi if ! hash bc >/dev/null; then sudo apt install -y bc fi ##################################### # Check if run before ##################################### if [ -f "${RB}" ]; then bash ${MYPATH}/update & exit fi ##################################### # Check user is pi ##################################### if [ "$WHO" != 'pi' ]; 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="USER NAME IS NOT PI\rThis script is designed to be run as the pi user. Please set the user name to pi \ and try again. You can change the user name after the build is complete but some configuration may not work \ as expected" \ --button=gtk-close exit 1 fi ##################################### # notice to user ##################################### cat <${MYPATH}/intro.txt This script takes approximately 4 hours to complete if you choose to install everything. If you find it helpful please consider a donation to encourage future development. https://paypal.me/km4ack EOF INTRO=$(yad --width=550 --height=250 --text-align=center --center --title="Build-a-Pi" --show-uri \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ --text-info \ --button="Continue":2 <${MYPATH}/intro.txt \ >/dev/null 2>&1) BUT=$? if [ ${BUT} = 252 ]; then rm ${MYPATH}/intro.txt exit fi rm ${MYPATH}/intro.txt ##################################### # Create autostart dir #used to autostart conky at boot ##################################### mkdir -p ${HOME}/.config/autostart ##################################### # Get User Call ##################################### CALL() { INFO=$(yad --form --width=420 --text-align=center --center --title="Build-a-Pi" \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ --text="version $VERSION" \ --field="Call Sign*" \ --field="* Required":LBL \ --button="Continue":2) BUT=$? if [ ${BUT} = 252 ]; then exit fi } CALL CALL=$(echo ${INFO} | awk -F "|" '{print $1}') CALL=${CALL^^} #Verify call not empty ATTEMPTS=0 while [ -z "$CALL" ]; do if [ $ATTEMPTS -eq 3 ]; then yad --form --width=420 --text-align=center --center --title="Build-a-Pi" --text-align=center \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ --text="Empty callsign after 3 attempts. Quiting!" \ --button=gtk-ok exit fi yad --form --width=420 --text-align=center --center --title="Build-a-Pi" --text-align=center \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ --text="Call Can't be Blank" \ --button=gtk-ok ((ATTEMPTS = ATTEMPTS + 1)) CALL CALL=$(echo ${INFO} | awk -F "|" '{print $1}') CALL=${CALL^^} done echo "CALL=$CALL" >${CONFIG} ##################################### # Base Apps ##################################### yad --center --list --checklist --width=600 --height=600 --separator="" \ --image ${LOGO} --column=Check --column=App --column=Description \ --print-column=2 --window-icon=${LOGO} --image-on-top --text-align=center \ --text="Base Applications" --title="Build-a-Pi" \ false "HOTSPOT" "Hot Spot Generator for Portable Ops" \ false "HSTOOLS" "Tools to Manage Hot Spot" \ false "GPS" "GPS Software" \ false "ARDOP" "Modem for HF" \ false "ARDOPGUI" "GUI for ARDOP" \ false "HAMLIB" "Needed for Rig Control" \ false "DIREWOLF" "Software TNC" \ false "AX25" "Data Link Layer Protocol" \ false "PULSE" "Pulse Audio Control Interface" \ --button="Exit":1 \ --button="Check All and Continue":3 \ --button="Next":2 >${BASE} BUT=$? if [ ${BUT} = 252 ] || [ ${BUT} = 1 ]; then exit fi if [ ${BUT} = 3 ]; then BASEAPPS=(HOTSPOT HSTOOLS GPS ARDOP ARDOPGUI HAMLIB DIREWOLF AX25 PULSE) for i in "${BASEAPPS[@]}"; do echo "$i" >>${BASE} done fi #check if hotspot is chosen for install & get info if needed HS=$(grep "HOTSPOT" ${BASE}) if [ -n "$HS" ]; then HSINFO() { #unblock wifi sudo rfkill unblock all >/dev/null 2>&1 #bring wifi up sudo ifconfig wlan0 up #LIST=$(sudo iw dev "wlan0" scan ap-force | egrep "^BSS|SSID:" | grep SSID: | sed 's/SSID://' | awk '{ print $1 }') #LIST=$(echo $LIST | sed 's/ /|/g') LIST=$(sudo iw dev "wlan0" scan ap-force | sed -ne 's/^.*SSID: \(..*\)/\1/p' | sort | uniq | paste -sd '|') HSINFO=$(yad --center --form --width=400 --height=400 --separator="|" --item-separator="|" \ --image ${LOGO} --column=Check --column=App --column=Description \ --window-icon=${LOGO} --image-on-top --text-align=center \ --text="HotSpot Information\r\rPlease enter the information\rbelow \ for the Hot Spot\rNOTE: The last field is the password for the hotspot. You will use this password to \ connect to your Pi when it is in hotspot mode This password can only contain letters and numbers" \ --title="Build-a-Pi" \ --field="Home Wifi SSID":CB "$LIST" \ --field="Home Wifi Password" \ --field="Hot Spot Password" \ --button="Exit":1 \ --button="Continue":2 \ --button="Refresh Wifi":3) BUT=$? if [ ${BUT} = 3 ]; then HSINFO #Call HSINFO function fi if [ ${BUT} = 252 ] || [ ${BUT} = 1 ]; then exit fi #} #HSINFO #fi SHACKSSID=$(echo $HSINFO | awk -F "|" '{print $1}') SHACKPASS=$(echo $HSINFO | awk -F "|" '{print $2}') HSPASS=$(echo $HSINFO | awk -F "|" '{print $3}') #Check password length if [ -n "$HS" ]; then COUNT=${#HSPASS} if [ ${COUNT} -lt 8 ]; then yad --center --form --width=300 --height=200 --separator="|" \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --text-align=center \ --text="Hotspot password has to be 8-63 characters" --title="Build-a-Pi" \ --button=gtk-ok HSINFO fi fi } HSINFO fi echo "SHACKSSID=$SHACKSSID" >>${CONFIG} echo "SHACKPASS=\"$SHACKPASS\"" >>${CONFIG} echo "HSPASS=\"$HSPASS\"" >>${CONFIG} ################################### #CHECK IF GPS IS CHOSEN TO INSTALL# ################################### GPSINSTALL=$(cat ${BASE} | grep GPS) if [ -n "${GPS}INSTALL" ]; then yad --center --height="300" --width="300" --form --separator="|" --item-separator="|" --title="GPS" \ --image ${LOGO} --window-icon=${LOGO} --image-on-top \ --text="\r\r\r\r\rConnect your GPS to the pi" \ --button="Exit":1 \ --button="Continue":2 BUT=$? if [ ${BUT} = 1 ] || [ ${BUT} = 252 ]; then exit fi USB=$(ls /dev/serial/by-id) USB=$(echo $USB | sed "s/\s/|/g") GPS=$(yad --center --height="600" --width="300" --form --separator="|" --item-separator="|" --title="GPS" \ --image ${LOGO} --window-icon=${LOGO} --image-on-top \ --text="Choose Your GPS" \ --field="GPS":CB "$USB") BUT=$? if [ ${BUT} = 252 ] || [ ${BUT} = 1 ]; then echo exiting exit fi GPS=$(echo ${GPS} | awk -F "|" '{print $1}') GPS=/dev/serial/by-id/${GPS} echo "GPS=${GPS}" >>${CONFIG} fi ##################################### # FLSUITE ##################################### yad --center --list --checklist --width=600 --height=600 --separator="" \ --image ${LOGO} --column=Check --column=App --column=Description \ --print-column=2 --window-icon=${LOGO} --image-on-top --text-align=center \ --text="FLDIGI Suite" --title="Build-a-Pi" \ false "FLRIG" "Rig Contol GUI" \ false "FLDIGI" "Digital Software" \ false "FLAMP" "File Transfer Program" \ false "FLNET" "Net Control Software" \ false "FLMSG" "Forms Manager" \ false "FLWRAP" "File Encapsulation" \ --button="Exit":1 \ --button="Check All and Continue":3 \ --button="Next":2 >${FLSUITE} BUT=$? if [ ${BUT} = 252 ] || [ ${BUT} = 1 ]; then exit fi if [ ${BUT} = 3 ]; then FLAPPS=(FLRIG FLDIGI FLAMP FLNET FLMSG FLWRAP) for i in "${FLAPPS[@]}"; do echo "$i" >>${FLSUITE} done fi ##################################### # Ham Apps ##################################### yad --center --list --checklist --width=600 --height=600 --separator="" \ --image ${LOGO} --column=Check --column=App --column=Description \ --print-column=2 --window-icon=${LOGO} --image-on-top --text-align=center \ --text="Ham Applications" --title="Build-a-Pi" \ false "CONKY" "System Information Display" \ false "PI-APRS" "APRS Message Application" \ false "CHIRP" "Program Radios" \ false "GARIM" "File Transfer Program" \ false "PAT" "Radio Email Application" \ false "PAT-MENU" "Control for Pat Winlink" \ false "JS8CALL" "Weak Signal Digital Mode Software" \ false "M0IAX" "Tools for JS8Call Messages" \ false "WSJTX" "Weak Signal Digital Mode Software" \ false "PYQSO" "Logging Software" \ false "CQRLOG" "Logging Software" \ false "XLOG" "Logging Software" \ false "EES" "KM4ACK Emergency Email Server" \ false "QSSTV" "Slow Scan TV" \ false "GRIDTRACKER" "Track Grids in WSJTX" \ false "HAMCLOCK" "Clock for Ham Radio Ops" \ false "PROPAGATION" "Propagation Prediction Software" \ false "YAAC" "Yet Another APRS Client" \ false "XASTIR" "APRS Client" \ false "GPREDICT" "Satellite Tracking" \ false "TQSL" "LOTW Software" \ --button="Exit":1 \ --button="Check All and Continue":3 \ --button="Next":2 >${ADDITIONAL} BUT=$? if [ ${BUT} = 252 ] || [ ${BUT} = 1 ]; then exit fi if [ ${BUT} = 3 ]; then ADDAPPS=(CONKY PI-APRS CHIRP GARIM PAT PAT-MENU JS8CALL M0IAX WSJTX PYQSO CQRLOG EES QSSTV GRIDTRACKER HAMCLOCK PROPAGATION YAAC XASTIR GPREDICT TQSL XLOG) for i in "${ADDAPPS[@]}"; do echo "$i" >>${ADDITIONAL} done fi #check if hamclock is being installed HCCHECK=$(grep "HAMCLOCK" ${ADDITIONAL}) if [ -n "$HCCHECK" ]; then HC=$(yad --form --width=420 --text-align=center --center --title="Build-a-Pi" \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ --text="version $VERSION" \ --field="Ham Clock Size":CB "SMALL|LARGE" \ --button="Continue":2) HC=$(echo $HC | awk -F "|" '{print $1}') sed -i 's/HAMCLOCK//' ${ADDITIONAL} echo $HC >>${ADDITIONAL} fi PATCHECK=$(grep "PAT" ${ADDITIONAL}) if [ -n "$PATCHECK" ]; then INFO=$(yad --form --width=420 --text-align=center --center --title="Build-a-Pi" \ --image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \ --text="version $VERSION" \ --field="Six Character Grid Square" \ --field="Winlink Password" \ --field="Password is case sensitive":LBL \ --button="Continue":2) GRID=$(echo ${INFO} | awk -F "|" '{print $1}') GRID=${GRID^^} WL2KPASS=$(echo ${INFO} | awk -F "|" '{print $2}') echo "GRID=$GRID" >>${CONFIG} echo "WL2KPASS=\"$WL2KPASS\"" >>${CONFIG} fi ##################################### # Utilities ##################################### yad --center --list --checklist --width=600 --height=600 --separator="" \ --image ${LOGO} --column=Check --column=App --column=Description \ --print-column=2 --window-icon=${LOGO} --image-on-top --text-align=center \ --text="Utilities" --title="Build-a-Pi" \ false "DIPOLE" "Dipole Calculator" \ false "CALLSIGN" "Call sign lookup" \ false "TEMPCONVERT" "Temperature Converter" \ false "GPARTED" "Disk Utility Tool" \ false "SHOWLOG" "Log file viewer" \ false "PISTATS" "Pi3/4 Stats Monitor" \ false "TELNET" "Telnet Protocol" \ false "PITERM" "piQtTermTCP Terminal Program" \ false "SECURITY" "File Encryption Software" \ false "YGATE" "Yaesu APRS Software" \ false "BPQ" "LinBPQ Software" \ false "BATT" "Battery Test Script" \ false "VNC" "VNC Client Application" \ false "ZYGRIB" "Grib File Viewer" \ false "GPSUPDATE" "Tool to Manage GPS Devices" \ --button="Exit":1 \ --button="Check All and Continue":3 \ --button="Install Selected":2 >${UTILITY} BUT=$? if [ ${BUT} = 252 ] || [ ${BUT} = 1 ]; then exit fi if [ ${BUT} = 3 ]; then UTILAPPS=(DIPOLE CALLSIGN TEMPCONVERT GPARTED SHOWLOG PISTATS TELNET PITERM SECURITY YGATE BPQ BATT VNC ZYGRIB GPSUPDATE) for i in "${UTILAPPS[@]}"; do echo "$i" >>${UTILITY} done fi #backup crontab crontab -l >$TEMPCRON echo "@reboot sleep 10 && export DISPLAY=:0 && ${MYPATH}/.complete" >>$TEMPCRON ${MYPATH}/.funfacts & #upgrade the system sudo apt-get -y upgrade sudo apt -y full-upgrade #set wallpaper #fix issue 193 sudo cp bap-wallpaper.jpg /usr/share/rpd-wallpaper/ 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 cat >tempsound <tempsound <>${HOME}/.bashrc #set update script to exec chmod +x ${MYPATH}/update ${MYPATH}/build-a-pi #create build-a-pi menu item cd ${MYPATH} || exit cat >build-a-pi.desktop </dev/null 2>&1 rm -rf ${DIR} >/dev/null 2>&1 #sudo apt -y autoremove > /dev/null 2>&1 #restore crontab crontab ${TEMPCRON} rm ${TEMPCRON} echo "WE ARE ALL DONE HERE. If you close this window, you will have to reboot manually." #reboot when done yad --width=400 --height=200 --title="Reboot" --image ${LOGO} \ --text-align=center --skip-taskbar --image-on-top \ --wrap --window-icon=${LOGO} \ --undecorated --text="Build Finished \rReboot Required\r\r" \ --button="Reboot Now":0 \ --button="Exit":1 BUT=$(echo $?) if [ ${BUT} = 0 ]; then echo rebooting sudo reboot elif [ ${BUT} = 1 ]; then exit fi