Ver a proveniência

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

Add Timezone and Locale Configuration
master
Nico há 3 anos
committed by GitHub
ascendente
cometimento
418f9c608e
Não foi encontrada uma chave conhecida para esta assinatura, na base de dados ID da chave GPG: 4AEE18F83AFDEB23
1 ficheiros alterados com 41 adições e 8 eliminações
  1. +41
    -8
      install.sh

+ 41
- 8
install.sh Ver ficheiro

@@ -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"



Carregando…
Cancelar
Guardar