From acb63d801c94893b2118cc4c6cbd544d98437a82 Mon Sep 17 00:00:00 2001 From: Justin Karimi Date: Sat, 23 Jan 2021 21:06:51 -0500 Subject: [PATCH 1/4] Formatting Updates Few updates to files for formatting consistency (aesthetics). --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 4bc9d38..fada5ae 100755 --- a/install.sh +++ b/install.sh @@ -35,7 +35,7 @@ fi ### Verify cloned repo if [ ! -e "$HOME/raspberry-noaa" ]; then - die "Is https://github.com/reynico/raspberry-noaa cloned in your home directory?" + die "Is https://github.com/reynico/raspberry-noaa cloned in your home directory?" fi ### Install required packages @@ -257,10 +257,10 @@ echo " " read -rp "Enter your latitude (South values are negative): " - lat=$REPLY + lat=$REPLY read -rp "Enter your longitude (West values are negative): " - lon=$REPLY + lon=$REPLY read -rp "Enter your timezone (Ex: -3 for Argentina time): " timezone=$REPLY From 91df709f6d73948c63e057a2a4c6a2c182840555 Mon Sep 17 00:00:00 2001 From: Justin Karimi Date: Sat, 23 Jan 2021 21:07:28 -0500 Subject: [PATCH 2/4] Update Python3 pip Commands Update the pip3 commands to instead use the safer "python3 -m pip" method as some distros do not install pip3 as part of the python3-pip install (but calling the pip module using python3 is almost a guaranteed). --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index fada5ae..0d66feb 100755 --- a/install.sh +++ b/install.sh @@ -78,7 +78,7 @@ else sudo apt install -yq libgfortran5 fi -sudo pip3 install numpy ephem tweepy Pillow +sudo python3 -m pip install numpy ephem tweepy Pillow log_done "Packages installed" ### Create the database schema @@ -233,7 +233,7 @@ else cd /tmp unzip master.zip cd pd120_decoder-master/pd120_decoder/ - pip3 install --user -r requirements.txt + python3 -m pip install --user -r requirements.txt cp demod.py utils.py "$HOME/raspberry-noaa/" ) log_done "pd120_decoder installed" From 6123376288184f1093721c92a1fa1b8ea8abc754 Mon Sep 17 00:00:00 2001 From: Justin Karimi Date: Sat, 23 Jan 2021 21:08:37 -0500 Subject: [PATCH 3/4] Update Timezone to be Timezone Offset Update semantics of what the "timezone" parameter actually is in this context to make room for the actual timezone configuration. --- install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 0d66feb..9688914 100755 --- a/install.sh +++ b/install.sh @@ -262,13 +262,15 @@ read -rp "Enter your latitude (South values are negative): " read -rp "Enter your longitude (West values are negative): " lon=$REPLY -read -rp "Enter your timezone (Ex: -3 for Argentina time): " - timezone=$REPLY +# note: this can probably be improved by calculating this +# automatically - good for a future iteration +read -rp "Enter your timezone offset (ex: -3 for Argentina time): " + tzoffset=$REPLY sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.noaa.conf" sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "$HOME/.wxtoimgrc" sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/$(echo "$lon * -1" | bc)/g" "$HOME/.predict/predict.qth" -sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g;s/change_tz/$(echo "$timezone * -1" | bc)/g" "sun.py" +sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g;s/change_tz/$(echo "$tzoffset * -1" | bc)/g" "sun.py" success "Install done! Double check your $HOME/.noaa.conf settings" From 6a9857fc7041db358d3bda8994fa8372892a7af0 Mon Sep 17 00:00:00 2001 From: Justin Karimi Date: Sat, 23 Jan 2021 21:09:17 -0500 Subject: [PATCH 4/4] Add Timezone and Lang Configuration for Web Add functionality in the installer to enable timezone and language configuration. --- install.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/install.sh b/install.sh index 9688914..e0f36a4 100755 --- a/install.sh +++ b/install.sh @@ -24,6 +24,10 @@ log_running() { echo " ${YELLOW}*${RESET} $1" } +log_error() { + echo " ${RED}error: $1${RESET}" +} + success() { echo "${GREEN}$1${RESET}" } @@ -250,6 +254,33 @@ else sed -i -e "s/enable_bias_tee//g" "$HOME/.noaa.conf" fi +echo " + Next we'll configure your webpanel language + and locale settings - you can update these in the + future by modifying 'lang' in /var/www/wx/Config.php + and 'date_default_timezone_set' in /var/www/wx/header.php + " + +# language configuration +langs=($(find templates/webpanel/language/ -type f -printf "%f\n" | cut -f 1 -d '.')) +while : ; do + read -rp "Enter your preferred language (${langs[*]}): " + lang=$REPLY + + if [[ ! " ${langs[@]} " =~ " ${lang} " ]]; then + log_error "choice $lang is not one of the available options (${langs[*]})" + else + break + fi +done +sed -i -e "s/'lang' => '.*'$/'lang' => '${lang}'/" "/var/www/wx/Config.php" + +echo "Visit https://www.php.net/manual/en/timezones.php for a list of available timezones" +read -rp "Enter your preferred timezone: " + timezone=$REPLY +timezone=$(echo $timezone | sed 's/\//\\\//g') +sed -i -e "s/date_default_timezone_set('.*');/date_default_timezone_set('${timezone}');/" "/var/www/wx/header.php" + echo " It's time to configure your ground station You'll be asked for your latitude and longitude