diff --git a/CHANGES.md b/CHANGES.md index f486b7079..52e20d1f5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/home.admin/99systemMenu.sh b/home.admin/99systemMenu.sh index 1529df77f..89536a0e0 100644 --- a/home.admin/99systemMenu.sh +++ b/home.admin/99systemMenu.sh @@ -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" diff --git a/home.admin/_provision_.sh b/home.admin/_provision_.sh index 816c2eb6e..c12e1b767 100755 --- a/home.admin/_provision_.sh +++ b/home.admin/_provision_.sh @@ -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 diff --git a/home.admin/config.scripts/blitz.time.sh b/home.admin/config.scripts/blitz.time.sh new file mode 100755 index 000000000..ae90eb17b --- /dev/null +++ b/home.admin/config.scripts/blitz.time.sh @@ -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