#1712 Add setting Timezone (#4604)

* #1712 adding blitz.time.sh
* Add Info on CHANGES
This commit is contained in:
/rootzoll 2024-06-09 22:21:47 +02:00 committed by GitHub
parent 513c759e5c
commit 36b38d5118
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 85 additions and 0 deletions

View file

@ -1,5 +1,6 @@
## What's new in Version 1.11.1 of RaspiBlitz?
- New: Set Timezone SSHMENU > SYSTEM > TIME [details](https://github.com/raspiblitz/raspiblitz/issues/1712)
- Update: LNbits 0.12.8 [details](https://github.com/lnbits/lnbits/releases/tag/0.12.8)
- Update: Specter Desktop 2.0.4 with reactivated UPDATE option [details](https://github.com/cryptoadvance/specter-desktop/releases/tag/v2.0.4)
- Update: BTCPayServer 1.13.0 [details](https://github.com/btcpayserver/btcpayserver/releases/tag/v1.13.0)

View file

@ -16,6 +16,8 @@ MENU="" # adds lines to HEIGHT
OPTIONS=() # adds lines to HEIGHt + CHOICE_HEIGHT
OPTIONS+=(BTOP "Monitor system resources with btop")
OPTIONS+=(TIME "Set Timezone")
OPTIONS+=(${network}LOG "Monitor the debug.log for ${CHAIN}")
OPTIONS+=(${network}CONF "Edit the bitcoin.conf")
@ -57,6 +59,9 @@ case $CHOICE in
# run as root to allow signal sending to any process
sudo btop
;;
TIME)
sudo /home/admin/config.scripts/blitz.time.sh choose-timezone
;;
${network}LOG)
if [ ${CHAIN} = signet ]; then
bitcoinlogpath="/mnt/hdd/bitcoin/signet/debug.log"

View file

@ -61,6 +61,9 @@ echo "deprecatedrpc=addresses" >> /mnt/hdd/bitcoin/bitcoin.conf 2>/dev/null
# backup SSH PubKeys
/home/admin/config.scripts/blitz.ssh.sh backup
# set timezone
/home/admin/config.scripts/blitz.time.sh set-by-config >> ${logFile}
# optimize mempool if RAM >1GB
kbSizeRAM=$(cat /proc/meminfo | grep "MemTotal" | sed 's/[^0-9]*//g')
if [ ${kbSizeRAM} -gt 1500000 ]; then

View file

@ -0,0 +1,76 @@
#!/usr/bin/env bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
echo "RaspiBlitz Time Tools"
echo
echo "## Parameters #######"
echo "choose-timezone --> user can choose timezone from list and it gets stored to raspiblitz config"
echo "set-by-config --> resets the time on the RaspiBlitz based on the config"
exit 1
fi
# check if started with sudo
if [ "$EUID" -ne 0 ]; then
echo "error='missing sudo'"
exit 1
fi
###################
# choose-timezone
###################
if [ "$1" = "choose-timezone" ]; then
# Prepare the list of timezones for dialog
echo "# preparing timezone list ..."
timezones=$(timedatectl list-timezones)
timezone_list=()
i=1
for tz in $timezones; do
prefix=$(echo $tz | cut -c1)
timezone_list+=("${prefix}${i}" "$tz")
i=$((i+1))
done
# Use dialog to display the list and get the user selection
choice=$(dialog --clear \
--backtitle "Timezone Selector" \
--title "Select a Timezone" \
--menu "Choose a timezone:" 20 60 15 \
"${timezone_list[@]}" 2>&1 >/dev/tty)
# Clear the screen
clear
# Set the chosen timezone
if [ -n "$choice" ]; then
index=$(echo "$choice" | sed 's/^[A-Z]//')
selected_timezone=${timezone_list[((index * 2) - 1)]}
echo "# Setting timezone to $selected_timezone ..."
timedatectl set-timezone "$selected_timezone"
echo "# Saving timezone to raspiblitz config ..."
/home/admin/config.scripts/blitz.conf.sh set "timezone" "$selected_timezone"
else
echo "# No timezone selected"
fi
sleep 2
exit 0
fi
###################
# set-by-config
###################
if [ "$1" = "set-by-config" ]; then
source /mnt/hdd/raspiblitz.conf
if [ ${#timezone} -eq 0 ]; then
echo "# no timezone set in raspiblitz.conf ... keeping default timezone"
exit 1
fi
echo "# Setting timezone to $timezone ..."
timedatectl set-timezone "$timezone"
exit 0
fi
echo "error='unknown parameter'"
exit 1