Browse Source

Merge pull request #120 from jekhokie/add-locale-settings

Add Timezone and Locale Configuration
master
Nico 3 years ago
committed by GitHub
parent
commit
418f9c608e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 41 additions and 8 deletions
  1. +41
    -8
      install.sh

+ 41
- 8
install.sh View File

@@ -24,6 +24,10 @@ log_running() {
echo " ${YELLOW}*${RESET} $1"
}

log_error() {
echo " ${RED}error: $1${RESET}"
}

success() {
echo "${GREEN}$1${RESET}"
}
@@ -35,7 +39,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
@@ -78,7 +82,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 +237,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"
@@ -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
@@ -257,18 +288,20 @@ 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
# 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"



Loading…
Cancel
Save