Skip to content

Commit

Permalink
Mimic timedatectl
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbelgium authored Jun 6, 2024
1 parent 79ddddb commit dd7f327
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions birdnet-pi/rootfs/usr/bin/timedatectl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Function to show the current timezone
show_timezone() {
current_timezone=$(date +%Z)
echo "Current timezone: $current_timezone"
}

# Function to set the timezone
set_timezone() {
new_timezone="$1"
sudo timedatectl set-timezone "$new_timezone"
echo "Timezone set to: $new_timezone"
}

# Main script
case "$1" in
"set-ntp")
case "$2" in
"false")
sudo timedatectl set-ntp false
echo "NTP disabled"
;;
"true")
sudo timedatectl set-ntp true
echo "NTP enabled"
;;
*)
echo "Invalid argument for set-ntp. Use 'false' or 'true'."
;;
esac
;;
"show")
case "$2" in
"--value"|"--property=Timezone")
show_timezone
;;
*)
echo "Invalid argument for show. Use '--value --property=Timezone'."
;;
esac
;;
"set-timezone")
set_timezone "$2"
;;
*)
echo "Usage: $0 {set-ntp [false|true] | show [--value --property=Timezone] | set-timezone <timezone>}"
;;
esac

0 comments on commit dd7f327

Please sign in to comment.