mirror of
https://github.com/karl0ss/AnotterKiosk.git
synced 2025-06-07 12:15:07 +01:00
fixes for all services and reverts
This commit is contained in:
parent
8f4762a32d
commit
cdd2bc2d02
@ -80,8 +80,7 @@ systemctl enable nginx
|
||||
systemctl enable ssh
|
||||
systemctl enable kiosk-sechedule-screen.service
|
||||
systemctl enable schedule-reboot.service
|
||||
systemctl enable screen-refresh.service
|
||||
systemctl enable setup-screen-refresh.service
|
||||
systemctl enable setup-refresh-timer.service
|
||||
|
||||
|
||||
# generate a version info/build info file
|
||||
|
@ -1,10 +0,0 @@
|
||||
[Unit]
|
||||
Description=Refresh Screen
|
||||
After=graphical.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=pi
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
ExecStart=/usr/bin/refresh-screen
|
@ -1,6 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
INI_FILE="/boot/kioskbrowser.ini"
|
||||
|
||||
remount_root() {
|
||||
local mode=$1
|
||||
echo "Remounting root filesystem as $mode..."
|
||||
mount -o remount,"$mode" / || {
|
||||
echo "Failed to remount root as $mode"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
REBOOT_ENABLED=$(awk -F '=' '/^\[reboot\]/ { in_reboot=1; next }
|
||||
in_reboot && /^\[/ { in_reboot=0 }
|
||||
in_reboot && $1 ~ /enabled/ { gsub(/ /, "", $2); print $2 }' "$INI_FILE")
|
||||
@ -12,6 +22,8 @@ REBOOT_TIME=$(awk -F '=' '/^\[reboot\]/ { in_reboot=1; next }
|
||||
if [[ "$REBOOT_ENABLED" -eq 1 ]] && [[ "$REBOOT_TIME" =~ ^[0-2][0-9]:[0-5][0-9]$ ]]; then
|
||||
echo "Scheduling reboot for $REBOOT_TIME..."
|
||||
|
||||
remount_root rw
|
||||
|
||||
TARGET_TIME=$(date -d "$REBOOT_TIME" +%s)
|
||||
NOW=$(date +%s)
|
||||
|
||||
@ -34,7 +46,6 @@ Persistent=false
|
||||
WantedBy=timers.target
|
||||
EOF
|
||||
|
||||
# Create the associated service
|
||||
cat <<EOF > /etc/systemd/system/reboot-at.service
|
||||
[Unit]
|
||||
Description=Scheduled Reboot
|
||||
@ -46,6 +57,8 @@ EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now reboot-at.timer
|
||||
|
||||
remount_root ro
|
||||
else
|
||||
echo "Reboot not scheduled (disabled or invalid time)"
|
||||
fi
|
||||
|
@ -3,6 +3,18 @@
|
||||
INI_FILE="/boot/kioskbrowser.ini"
|
||||
SYSTEMD_DIR="/etc/systemd/system"
|
||||
|
||||
|
||||
# Function to safely remount root FS
|
||||
remount_root() {
|
||||
local mode=$1
|
||||
echo "Remounting root filesystem as $mode..."
|
||||
mount -o remount,"$mode" / || {
|
||||
echo "Failed to remount root as $mode"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
get_ini_value() {
|
||||
local section=$1 key=$2
|
||||
awk -F '=' -v sec="$section" -v k="$key" '
|
||||
@ -17,6 +29,17 @@ get_ini_value() {
|
||||
create_recurring_timer() {
|
||||
local action=$1
|
||||
local time=$2
|
||||
local value
|
||||
|
||||
if [[ "$action" == "on" ]]; then
|
||||
value=1
|
||||
elif [[ "$action" == "off" ]]; then
|
||||
value=0
|
||||
else
|
||||
echo "Invalid action: $action"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local name="screen-${action}"
|
||||
|
||||
echo "Setting daily screen ${action} at ${time}"
|
||||
@ -39,9 +62,7 @@ Description=Turn screen ${action}
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Environment=DISPLAY=:0
|
||||
ExecStart=/usr/bin/xset dpms force ${action}
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
ExecStart=/usr/bin/vcgencmd display_power ${value}
|
||||
User=pi
|
||||
EOF
|
||||
|
||||
@ -49,6 +70,7 @@ EOF
|
||||
systemctl enable --now "${name}.timer"
|
||||
}
|
||||
|
||||
|
||||
cleanup_screen_timers() {
|
||||
for action in on off; do
|
||||
systemctl disable --now screen-${action}.timer 2>/dev/null
|
||||
@ -57,6 +79,8 @@ cleanup_screen_timers() {
|
||||
systemctl daemon-reload
|
||||
}
|
||||
|
||||
remount_root rw
|
||||
|
||||
# === MAIN ===
|
||||
SCREEN_ON=$(get_ini_value screen screen_on_time)
|
||||
SCREEN_OFF=$(get_ini_value screen screen_off_time)
|
||||
@ -65,3 +89,5 @@ cleanup_screen_timers
|
||||
|
||||
[[ "$SCREEN_ON" =~ ^[0-2][0-9]:[0-5][0-9]$ ]] && create_recurring_timer on "$SCREEN_ON"
|
||||
[[ "$SCREEN_OFF" =~ ^[0-2][0-9]:[0-5][0-9]$ ]] && create_recurring_timer off "$SCREEN_OFF"
|
||||
|
||||
remount_root ro
|
||||
|
@ -29,9 +29,13 @@ if [[ "$REFRESH_INTERVAL" =~ ^[0-9]+$ ]] && (( REFRESH_INTERVAL > 0 )); then
|
||||
cat <<EOF | tee "$SERVICE_UNIT" > /dev/null
|
||||
[Unit]
|
||||
Description=Refresh Screen
|
||||
After=graphical.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=pi
|
||||
Environment=DISPLAY=:0
|
||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||
ExecStart=/usr/bin/refresh-screen
|
||||
EOF
|
||||
|
||||
|
@ -1 +1 @@
|
||||
console=serial0,115200 console=tty1 root=PARTUUID=544c6228-02 rootfstype=ext4 rw rootwait logo.nologo consoleblank=0 loglevel=0 quiet
|
||||
console=serial0,115200 console=tty1 root=PARTUUID=544c6228-02 rootfstype=ext4 ro rootwait logo.nologo consoleblank=0 loglevel=0 quiet
|
Loading…
x
Reference in New Issue
Block a user