From a0ecb5b1249a83d3bc487e805e15b5e1ca5a74d5 Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 11 Oct 2021 21:04:16 -0700 Subject: [PATCH 01/11] First test of allsky-config --- allsky-config | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 allsky-config diff --git a/allsky-config b/allsky-config new file mode 100755 index 000000000..93a8630db --- /dev/null +++ b/allsky-config @@ -0,0 +1,68 @@ +#!/bin/bash + +# +# Ease setup of Allsky software using whiptail text interface +# + +source "variables.sh" + +calc_wt_size() { + # NOTE: it's tempting to redirect stderr to /dev/null, so supress error + # output from tput. However in this case, tput detects neither stdout or + # stderr is a tty and so only gives default 80, 24 values + WT_HEIGHT=18 + WT_WIDTH=$(tput cols) + + if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then + WT_WIDTH=80 + fi + if [ "$WT_WIDTH" -gt 178 ]; then + WT_WIDTH=120 + fi + WT_MENU_HEIGHT=$(($WT_HEIGHT-7)) +} + +select_camera() { + CAM=$(whiptail --title "Allsky Software Config Tool (allsky-config)" --menu "Camera Type" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ + "ZWO" "ZWO camera is used for allsky" \ + "RPiHQ" "RPiHQ camera is used for allsky" \ + 3>&1 1>&2 2>&3) + if [ $? -eq 0 ]; then + sed -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh" + if [ $? -eq 0 ]; then + whiptail --msgbox "Camera set to $CAM" 20 60 2 + return 0 + else + whiptail --msgbox "Something went wrong setting camera to ${CAM}. Does ${ALLSKY_CONFIG}/config.sh exist?" 20 60 2 + return 1 + fi + else + return 1 + fi +} + + +main_menu() { + while true; do + MAIN=$(whiptail --title "Allsky Software Config Tool (allsky-config)" --menu "Main Menu" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ + "C" "Camera Selection" \ + "E" "End of Night Processing" \ + "P" "Post Processing" \ + "U" "Upload Settings" \ + 3>&1 1>&2 2>&3) + RETVAL=$? + if [ $RETVAL -eq 1 ]; then + exit 0 + elif [ $RETVAL -eq 0 ]; then + case "$MAIN" in + C) select_camera ;; + *) whiptail --msgbox "Sorry, this function not yet implemented." 20 60 2 ;; + esac + else + exit 1 + fi + done +} + +calc_wt_size +main_menu \ No newline at end of file From 3d62b1fe98e04b122889c707c69201a678187aa3 Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 18 Oct 2021 16:15:03 -0600 Subject: [PATCH 02/11] Added camera selection to Installer --- allsky-config | 68 --------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100755 allsky-config diff --git a/allsky-config b/allsky-config deleted file mode 100755 index 93a8630db..000000000 --- a/allsky-config +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -# -# Ease setup of Allsky software using whiptail text interface -# - -source "variables.sh" - -calc_wt_size() { - # NOTE: it's tempting to redirect stderr to /dev/null, so supress error - # output from tput. However in this case, tput detects neither stdout or - # stderr is a tty and so only gives default 80, 24 values - WT_HEIGHT=18 - WT_WIDTH=$(tput cols) - - if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then - WT_WIDTH=80 - fi - if [ "$WT_WIDTH" -gt 178 ]; then - WT_WIDTH=120 - fi - WT_MENU_HEIGHT=$(($WT_HEIGHT-7)) -} - -select_camera() { - CAM=$(whiptail --title "Allsky Software Config Tool (allsky-config)" --menu "Camera Type" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ - "ZWO" "ZWO camera is used for allsky" \ - "RPiHQ" "RPiHQ camera is used for allsky" \ - 3>&1 1>&2 2>&3) - if [ $? -eq 0 ]; then - sed -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh" - if [ $? -eq 0 ]; then - whiptail --msgbox "Camera set to $CAM" 20 60 2 - return 0 - else - whiptail --msgbox "Something went wrong setting camera to ${CAM}. Does ${ALLSKY_CONFIG}/config.sh exist?" 20 60 2 - return 1 - fi - else - return 1 - fi -} - - -main_menu() { - while true; do - MAIN=$(whiptail --title "Allsky Software Config Tool (allsky-config)" --menu "Main Menu" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ - "C" "Camera Selection" \ - "E" "End of Night Processing" \ - "P" "Post Processing" \ - "U" "Upload Settings" \ - 3>&1 1>&2 2>&3) - RETVAL=$? - if [ $RETVAL -eq 1 ]; then - exit 0 - elif [ $RETVAL -eq 0 ]; then - case "$MAIN" in - C) select_camera ;; - *) whiptail --msgbox "Sorry, this function not yet implemented." 20 60 2 ;; - esac - else - exit 1 - fi - done -} - -calc_wt_size -main_menu \ No newline at end of file From 01573d4bdb94dd321bd30b5f70afdbd4505ad04b Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 18 Oct 2021 16:15:42 -0600 Subject: [PATCH 03/11] Really added install camear selection --- install.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index d0d0e7ce9..50f79a698 100755 --- a/install.sh +++ b/install.sh @@ -53,12 +53,52 @@ if [ $RETVAL -ne 0 ]; then fi echo -echo -echo "The Allsky Software is now installed. You should reboot the Raspberry Pi to finish the installation" -echo -read -p "Do you want to reboot now? [y/n] " ans_yn -case "$ans_yn" in - [Yy]|[Yy][Ee][Ss]) sudo reboot now;; +source "variables.sh" + +calc_wt_size() { + # NOTE: it's tempting to redirect stderr to /dev/null, so supress error + # output from tput. However in this case, tput detects neither stdout or + # stderr is a tty and so only gives default 80, 24 values + WT_HEIGHT=18 + WT_WIDTH=$(tput cols) + + if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then + WT_WIDTH=80 + fi + if [ "$WT_WIDTH" -gt 178 ]; then + WT_WIDTH=120 + fi + WT_MENU_HEIGHT=$(($WT_HEIGHT-7)) +} + +select_camera() { + CAM=$(whiptail --title "Allsky Software Installer" --menu "Camera Type" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ + "ZWO" "ZWO camera is used for allsky" \ + "RPiHQ" "RPiHQ camera is used for allsky" \ + 3>&1 1>&2 2>&3) + if [ $? -eq 0 ]; then + sed -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh" + if [ $? -eq 0 ]; then + whiptail --msgbox "Camera set to $CAM" 10 60 2 + return 0 + else + whiptail --msgbox "Something went wrong setting camera to ${CAM}. Does ${ALLSKY_CONFIG}/config.sh exist?" 10 60 2 + return 1 + fi + else + return 1 + fi +} + +ask_reboot() { + if (whiptail --title "Allsky Software Installer" --yesno "The Allsky Software is now installed. You should reboot the Raspberry Pi to finish the installation.\n\n Reboot now?" 10 60 \ + 3>&1 1>&2 2>&3); then + sudo reboot now + else + exit 3 + fi +} - *) exit 3;; -esac +calc_wt_size +select_camera +ask_reboot \ No newline at end of file From c85e16ddbc7091f270fbdf7c31467fe2a444a92a Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 18 Oct 2021 17:28:01 -0600 Subject: [PATCH 04/11] Fixed SED to inline modify config.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 50f79a698..fb4ba69de 100755 --- a/install.sh +++ b/install.sh @@ -77,7 +77,7 @@ select_camera() { "RPiHQ" "RPiHQ camera is used for allsky" \ 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - sed -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh" + sed -i -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh" if [ $? -eq 0 ]; then whiptail --msgbox "Camera set to $CAM" 10 60 2 return 0 @@ -101,4 +101,4 @@ ask_reboot() { calc_wt_size select_camera -ask_reboot \ No newline at end of file +ask_reboot From 6bd4ae7888207902b92cb18108760f4352abee0d Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 18 Oct 2021 19:01:34 -0600 Subject: [PATCH 05/11] Tweaking camera select sequence. --- install.sh | 98 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/install.sh b/install.sh index fb4ba69de..5ca9a6f3b 100755 --- a/install.sh +++ b/install.sh @@ -20,39 +20,14 @@ if [ "$DIR" != "$INSTALL_DIR" ] ; then exit 1 fi +CAM="" +NEEDCAM=0 + echo echo "**********************************************" echo "*** Welcome to the Allsky Camera installer ***" echo "**********************************************" echo - -echo -e "${GREEN}* Dependencies installation\n${NC}" -sudo make deps -RETVAL=$? -if [ $RETVAL -ne 0 ]; then - echo Installing dependencies failed\! - exit 1 -fi -echo - -echo -e "${GREEN}* Compile allsky software\n${NC}" -make all -RETVAL=$? -if [ $RETVAL -ne 0 ]; then - echo Compile failed\! - exit 1 -fi -echo - -echo -e "${GREEN}* Install allsky software\n${NC}" -sudo make install -RETVAL=$? -if [ $RETVAL -ne 0 ]; then - echo Install failed\! - exit 1 -fi -echo - source "variables.sh" calc_wt_size() { @@ -72,24 +47,42 @@ calc_wt_size() { } select_camera() { - CAM=$(whiptail --title "Allsky Software Installer" --menu "Camera Type" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ - "ZWO" "ZWO camera is used for allsky" \ - "RPiHQ" "RPiHQ camera is used for allsky" \ - 3>&1 1>&2 2>&3) - if [ $? -eq 0 ]; then - sed -i -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh" + NEEDCAM=0 + if [ ! -e ${ALLSKY_CONFIG}/config.sh ]; then + NEEDCAM=1 + else + source ${ALLSKY_CONFIG}/config.sh + if [ -z "${CAM}" ]; then + NEEDCAM=1 + fi + fi + if [ $NEEDCAM -eq 1 ]; then + MYCAM=$(whiptail --title "Allsky Software Installer" --menu "Camera Type" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT \ + "ZWO" "ZWO camera is used for allsky" \ + "RPiHQ" "RPiHQ camera is used for allsky" \ + 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then - whiptail --msgbox "Camera set to $CAM" 10 60 2 - return 0 + CAM=$MYCAM else - whiptail --msgbox "Something went wrong setting camera to ${CAM}. Does ${ALLSKY_CONFIG}/config.sh exist?" 10 60 2 - return 1 + whiptail --msgbox "Camera selection required. Please re-run './install.sh' and select a camera to continue." 10 60 2 + exit 1 fi + fi +} + +set_camera() { + sed -i -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh" + RETVAL=$? + if [ $RETVAL -eq 0 ]; then + whiptail --msgbox "Camera set to $CAM" 10 60 2 + return 0 else + whiptail --msgbox "Something went wrong setting camera to ${CAM}. Error code ${RETVAL}?" 10 60 2 return 1 fi } + ask_reboot() { if (whiptail --title "Allsky Software Installer" --yesno "The Allsky Software is now installed. You should reboot the Raspberry Pi to finish the installation.\n\n Reboot now?" 10 60 \ 3>&1 1>&2 2>&3); then @@ -101,4 +94,33 @@ ask_reboot() { calc_wt_size select_camera + +echo -e "${GREEN}* Dependencies installation\n${NC}" +sudo make deps +RETVAL=$? +if [ $RETVAL -ne 0 ]; then + echo Installing dependencies failed\! + exit 1 +fi +echo + +echo -e "${GREEN}* Compile allsky software\n${NC}" +make all +RETVAL=$? +if [ $RETVAL -ne 0 ]; then + echo Compile failed\! + exit 1 +fi +echo + +echo -e "${GREEN}* Install allsky software\n${NC}" +sudo make install +RETVAL=$? +if [ $RETVAL -ne 0 ]; then + echo Install failed\! + exit 1 +fi +echo + +set_camera ask_reboot From 7b87f0bbb23c45f64f0b818442637f57cb6bba43 Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 18 Oct 2021 19:02:27 -0600 Subject: [PATCH 06/11] Moved 'variables.sh' to top. --- install.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 5ca9a6f3b..492db4b11 100755 --- a/install.sh +++ b/install.sh @@ -1,8 +1,5 @@ #!/bin/bash -RED='\033[0;31m' -GREEN='\033[0;32m' -NC='\033[0m' # No Color - +source "variables.sh" if [[ $EUID -eq 0 ]]; then echo "This script must NOT be run as root" 1>&2 exit 1 @@ -28,7 +25,6 @@ echo "**********************************************" echo "*** Welcome to the Allsky Camera installer ***" echo "**********************************************" echo -source "variables.sh" calc_wt_size() { # NOTE: it's tempting to redirect stderr to /dev/null, so supress error From 9ad5057bccb1388798d41c07255107d03fab284c Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 18 Oct 2021 19:05:37 -0600 Subject: [PATCH 07/11] Make 'set_camera' conditional on need. --- install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 492db4b11..a9b710b17 100755 --- a/install.sh +++ b/install.sh @@ -118,5 +118,7 @@ if [ $RETVAL -ne 0 ]; then fi echo -set_camera +if [ $NEEDCAM -eq 1 ]; then + set_camera +fi ask_reboot From 368a477fe132f18fa4fb33e2b5c7569f69d3388f Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 18 Oct 2021 21:37:23 -0600 Subject: [PATCH 08/11] Removed extraneous parameter on whiptail --msgbox --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index a9b710b17..739104f3d 100755 --- a/install.sh +++ b/install.sh @@ -60,7 +60,7 @@ select_camera() { if [ $? -eq 0 ]; then CAM=$MYCAM else - whiptail --msgbox "Camera selection required. Please re-run './install.sh' and select a camera to continue." 10 60 2 + whiptail --msgbox "Camera selection required. Please re-run './install.sh' and select a camera to continue." 10 60 exit 1 fi fi @@ -73,7 +73,7 @@ set_camera() { whiptail --msgbox "Camera set to $CAM" 10 60 2 return 0 else - whiptail --msgbox "Something went wrong setting camera to ${CAM}. Error code ${RETVAL}?" 10 60 2 + whiptail --msgbox "Something went wrong setting camera to ${CAM}. Error code ${RETVAL}?" 10 60 return 1 fi } From 18575c74a2115a1c040201c0bfef48f323e8ba4b Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Mon, 18 Oct 2021 21:38:48 -0600 Subject: [PATCH 09/11] missed a msgbox whiptail extraneous param. --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 739104f3d..8056eea23 100755 --- a/install.sh +++ b/install.sh @@ -70,7 +70,7 @@ set_camera() { sed -i -e "s/^CAMERA=.*$/CAMERA=\"${CAM}\"/" "$ALLSKY_CONFIG/config.sh" RETVAL=$? if [ $RETVAL -eq 0 ]; then - whiptail --msgbox "Camera set to $CAM" 10 60 2 + whiptail --msgbox "Camera set to $CAM" 10 60 return 0 else whiptail --msgbox "Something went wrong setting camera to ${CAM}. Error code ${RETVAL}?" 10 60 From 1dc16e85da378787db3955e246242b62941c4b34 Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Tue, 19 Oct 2021 07:37:48 -0600 Subject: [PATCH 10/11] Add comment re: Later install of config.sh / edit --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 8056eea23..8a36b42e3 100755 --- a/install.sh +++ b/install.sh @@ -46,6 +46,8 @@ select_camera() { NEEDCAM=0 if [ ! -e ${ALLSKY_CONFIG}/config.sh ]; then NEEDCAM=1 + # NOTE: The config.sh file is put in place during the 'make install' step below. + # This flag will be checked after 'make install', and trigger an edit to set the camera value. else source ${ALLSKY_CONFIG}/config.sh if [ -z "${CAM}" ]; then From 058d4b315a32919bbaf0a1d46fcbf68b83dba79f Mon Sep 17 00:00:00 2001 From: "Michael J. Kidd" Date: Tue, 19 Oct 2021 08:08:08 -0700 Subject: [PATCH 11/11] Fixed typo ( CAM != CAMERA ), and added another comment --- install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 8a36b42e3..fbc37b5e7 100755 --- a/install.sh +++ b/install.sh @@ -50,8 +50,11 @@ select_camera() { # This flag will be checked after 'make install', and trigger an edit to set the camera value. else source ${ALLSKY_CONFIG}/config.sh - if [ -z "${CAM}" ]; then + if [ -z "${CAMERA}" ]; then NEEDCAM=1 + # NOTE: The config.sh file is present, but the CAMERA variable is empty, thus we need to query it. + else + CAM=$CAMERA fi fi if [ $NEEDCAM -eq 1 ]; then