Files
hassio-addons/birdnet-pi-zach/rootfs/helpers/timedatectl
Claude Code 748bcc7df1 Add birdnet-pi-zach addon (zach7036/BirdNET-Pi-Enhanced-Version fork)
Creates a new Home Assistant add-on that installs from zach7036's BirdNET-Pi-Enhanced-Version fork instead of the Nachtzuster/alexbelgium fork. Leaves the existing birdnet-pi addon untouched.

Key changes from birdnet-pi:
- Installer repointed to zach7036/BirdNET-Pi-Enhanced-Version/main/newinstaller.sh
- Removed alexbelgium repo rename sed (zach7036 fork already clones itself)
- Removed merge_open_prs PR-merging step (install stable main)
- Updated slug to birdnet-pi-zach, image to birdnet-pi-zach-{arch}
- Updated README/docs upstream description
- Unique apparmor profile name

The generic Dockerfile patches (strip sudo, remap my_dir, systemctl shims) apply unchanged to the new fork since it follows standard BirdNET-Pi layout.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-10 10:30:04 +02:00

108 lines
2.2 KiB
Bash

#!/bin/bash
# Function to show the current timezone using two alternative methods
show_timezone() {
if [ -f /data/timezone ]; then
cat /data/timezone
elif [ -f /etc/timezone ]; then
cat /etc/timezone
elif [ -f /etc/localtime ]; then
readlink /etc/localtime | sed 's|/usr/share/zoneinfo/||'
else
echo "Cannot determine timezone."
fi
}
# Function to set the timezone
set_timezone() {
local new_timezone="$1"
if [ ! -f "/usr/share/zoneinfo/$new_timezone" ]; then
echo "Invalid timezone: $new_timezone"
return 1
fi
echo "$new_timezone" >/data/timezone
echo "$new_timezone" >/etc/timezone
ln -sf "/usr/share/zoneinfo/$new_timezone" /etc/localtime
# Update /etc/environment if it exists
if [ -f /etc/environment ]; then
sed -i "/^TZ=/c\TZ=$new_timezone" /etc/environment
fi
# Update s6 container environment if it exists
if [ -d /var/run/s6/container_environment ]; then
echo "$new_timezone" >/var/run/s6/container_environment/TZ
fi
echo "Timezone set to: $new_timezone"
}
# Function to enable or disable NTP
set_ntp() {
case "$1" in
"false")
systemctl stop systemd-timesyncd
systemctl disable systemd-timesyncd
echo "NTP disabled"
;;
"true")
systemctl start systemd-timesyncd
systemctl enable systemd-timesyncd
# Remove the /data/timezone file when NTP is enabled
if [ -f /data/timezone ]; then
rm -f /data/timezone
echo "Timezone configuration file /data/timezone deleted."
fi
echo "NTP enabled"
;;
*)
echo "Invalid argument for set-ntp. Use 'false' or 'true'."
;;
esac
}
# Function to show detailed time settings
show_time_details() {
local local_time
local utc_time
local time_zone
local ntp_status="no"
local ntp_service="inactive"
local_time="$(date)"
utc_time="$(date -u)"
time_zone="$(show_timezone)"
# Check if NTP is used
if systemctl is-active --quiet systemd-timesyncd; then
ntp_status="yes"
ntp_service="active"
fi
# Print the information
echo "Local time: $local_time"
echo "Universal time: $utc_time"
echo "Time zone: $time_zone"
echo "Network time on: $ntp_status"
echo "NTP service: $ntp_service"
}
# Main script logic
case "$1" in
"set-ntp")
set_ntp "$2"
;;
"show")
show_timezone
;;
"set-timezone")
set_timezone "$2"
;;
*)
show_time_details
;;
esac