mirror of
https://github.com/karl0ss/AnotterKiosk.git
synced 2025-06-08 20:55: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 ssh
|
||||||
systemctl enable kiosk-sechedule-screen.service
|
systemctl enable kiosk-sechedule-screen.service
|
||||||
systemctl enable schedule-reboot.service
|
systemctl enable schedule-reboot.service
|
||||||
systemctl enable screen-refresh.service
|
systemctl enable setup-refresh-timer.service
|
||||||
systemctl enable setup-screen-refresh.service
|
|
||||||
|
|
||||||
|
|
||||||
# generate a version info/build info file
|
# 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
|
#!/bin/bash
|
||||||
|
|
||||||
INI_FILE="/boot/kioskbrowser.ini"
|
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 }
|
REBOOT_ENABLED=$(awk -F '=' '/^\[reboot\]/ { in_reboot=1; next }
|
||||||
in_reboot && /^\[/ { in_reboot=0 }
|
in_reboot && /^\[/ { in_reboot=0 }
|
||||||
in_reboot && $1 ~ /enabled/ { gsub(/ /, "", $2); print $2 }' "$INI_FILE")
|
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
|
if [[ "$REBOOT_ENABLED" -eq 1 ]] && [[ "$REBOOT_TIME" =~ ^[0-2][0-9]:[0-5][0-9]$ ]]; then
|
||||||
echo "Scheduling reboot for $REBOOT_TIME..."
|
echo "Scheduling reboot for $REBOOT_TIME..."
|
||||||
|
|
||||||
|
remount_root rw
|
||||||
|
|
||||||
TARGET_TIME=$(date -d "$REBOOT_TIME" +%s)
|
TARGET_TIME=$(date -d "$REBOOT_TIME" +%s)
|
||||||
NOW=$(date +%s)
|
NOW=$(date +%s)
|
||||||
|
|
||||||
@ -34,7 +46,6 @@ Persistent=false
|
|||||||
WantedBy=timers.target
|
WantedBy=timers.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create the associated service
|
|
||||||
cat <<EOF > /etc/systemd/system/reboot-at.service
|
cat <<EOF > /etc/systemd/system/reboot-at.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Scheduled Reboot
|
Description=Scheduled Reboot
|
||||||
@ -46,6 +57,8 @@ EOF
|
|||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable --now reboot-at.timer
|
systemctl enable --now reboot-at.timer
|
||||||
|
|
||||||
|
remount_root ro
|
||||||
else
|
else
|
||||||
echo "Reboot not scheduled (disabled or invalid time)"
|
echo "Reboot not scheduled (disabled or invalid time)"
|
||||||
fi
|
fi
|
||||||
|
@ -3,6 +3,18 @@
|
|||||||
INI_FILE="/boot/kioskbrowser.ini"
|
INI_FILE="/boot/kioskbrowser.ini"
|
||||||
SYSTEMD_DIR="/etc/systemd/system"
|
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() {
|
get_ini_value() {
|
||||||
local section=$1 key=$2
|
local section=$1 key=$2
|
||||||
awk -F '=' -v sec="$section" -v k="$key" '
|
awk -F '=' -v sec="$section" -v k="$key" '
|
||||||
@ -17,6 +29,17 @@ get_ini_value() {
|
|||||||
create_recurring_timer() {
|
create_recurring_timer() {
|
||||||
local action=$1
|
local action=$1
|
||||||
local time=$2
|
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}"
|
local name="screen-${action}"
|
||||||
|
|
||||||
echo "Setting daily screen ${action} at ${time}"
|
echo "Setting daily screen ${action} at ${time}"
|
||||||
@ -39,9 +62,7 @@ Description=Turn screen ${action}
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
Environment=DISPLAY=:0
|
ExecStart=/usr/bin/vcgencmd display_power ${value}
|
||||||
ExecStart=/usr/bin/xset dpms force ${action}
|
|
||||||
Environment=XAUTHORITY=/home/pi/.Xauthority
|
|
||||||
User=pi
|
User=pi
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@ -49,6 +70,7 @@ EOF
|
|||||||
systemctl enable --now "${name}.timer"
|
systemctl enable --now "${name}.timer"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cleanup_screen_timers() {
|
cleanup_screen_timers() {
|
||||||
for action in on off; do
|
for action in on off; do
|
||||||
systemctl disable --now screen-${action}.timer 2>/dev/null
|
systemctl disable --now screen-${action}.timer 2>/dev/null
|
||||||
@ -57,6 +79,8 @@ cleanup_screen_timers() {
|
|||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remount_root rw
|
||||||
|
|
||||||
# === MAIN ===
|
# === MAIN ===
|
||||||
SCREEN_ON=$(get_ini_value screen screen_on_time)
|
SCREEN_ON=$(get_ini_value screen screen_on_time)
|
||||||
SCREEN_OFF=$(get_ini_value screen screen_off_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_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"
|
[[ "$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
|
cat <<EOF | tee "$SERVICE_UNIT" > /dev/null
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Refresh Screen
|
Description=Refresh Screen
|
||||||
|
After=graphical.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
|
User=pi
|
||||||
|
Environment=DISPLAY=:0
|
||||||
|
Environment=XAUTHORITY=/home/pi/.Xauthority
|
||||||
ExecStart=/usr/bin/refresh-screen
|
ExecStart=/usr/bin/refresh-screen
|
||||||
EOF
|
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