From 651f9280c9a657ccc8df0c9b7834e6168445475e Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:21:21 +0100 Subject: [PATCH 01/89] usr/bin/chromium-monitor aktualisiert --- usr/bin/chromium-monitor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/bin/chromium-monitor b/usr/bin/chromium-monitor index edae130..3777eb0 100644 --- a/usr/bin/chromium-monitor +++ b/usr/bin/chromium-monitor @@ -22,12 +22,12 @@ while true; do new_monitor_md5=$(echo -n ${new_monitor^^} | sed -e 's/^[[:space:]]*//' | md5sum | awk '{print $1}') current_md5=$(echo -n ${new_current^^} | sed -e 's/^[[:space:]]*//' | md5sum | awk '{print $1}') if [ "$new_monitor_md5" != "$monitor_md5" ] && [ "$current_md5" != "$monitor_md5" ]; then - echo "Mismatch detected. Rebooting now." + echo "Mismatch detected. Rebooting now." >> /var/log/chromium-monitor sudo reboot exit 1 fi else - echo "Either monitor or current is not available, skipping check." + echo "Either monitor or current is not available, skipping check." >> /var/log/chromium-monitor fi sleep 5s done From 3cd8e0bea65c77847f10c4343480a03eb0d52df7 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:23:34 +0100 Subject: [PATCH 02/89] usr/bin/watchdog aktualisiert --- usr/bin/watchdog | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usr/bin/watchdog b/usr/bin/watchdog index 9e34575..af5ff4c 100644 --- a/usr/bin/watchdog +++ b/usr/bin/watchdog @@ -9,14 +9,14 @@ sudo sed -i '/^interval/d' "$config_file" echo "interval = 60" | sudo tee -a "$config_file" > /dev/null if [ ${#ip_array[@]} -eq 0 ]; then sudo sed -i '/interval/d' "$config_file" - echo "No IP addresses found. Watchdog configuration cleared." >&2 + echo "No IP addresses found. Watchdog configuration cleared." >> /var/log/watchdog 2>&1 sudo systemctl stop watchdog else for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null done fi -sudo systemctl restart watchdog +sudo systemctl restart watchdog >> /var/log/watchdog 2>&1 -# Version 1.0: -# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. \ No newline at end of file +# Version 1.1: +# Created 2024 by Tim Eertmoed @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. \ No newline at end of file From eb74659abfeca82c5a167349942a84384145ca1d Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:26:12 +0100 Subject: [PATCH 03/89] etc/systemd/system/chromium-monitor.service aktualisiert --- etc/systemd/system/chromium-monitor.service | 3 +++ 1 file changed, 3 insertions(+) diff --git a/etc/systemd/system/chromium-monitor.service b/etc/systemd/system/chromium-monitor.service index 280dfb6..ad01e73 100644 --- a/etc/systemd/system/chromium-monitor.service +++ b/etc/systemd/system/chromium-monitor.service @@ -7,6 +7,9 @@ ExecStartPre=-/bin/sleep 120 Type=simple ExecStart=/usr/bin/chromium-monitor Restart=on-failure +RestartSec=5s +StandardOutput=append:/var/log/chromium-monitor +StandardError=append:/var/log/chromium-monitor [Install] WantedBy=multi-user.target From eb785117d753ba33800cde350fc458f63c741bd6 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:27:11 +0100 Subject: [PATCH 04/89] etc/systemd/system/watchdog.service aktualisiert --- etc/systemd/system/watchdog.service | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etc/systemd/system/watchdog.service b/etc/systemd/system/watchdog.service index 79cee81..603c12a 100644 --- a/etc/systemd/system/watchdog.service +++ b/etc/systemd/system/watchdog.service @@ -7,9 +7,12 @@ ExecStartPre=-/bin/sleep 120 Type=simple ExecStart=/usr/bin/watchdog Restart=on-failure +RestartSec=5s +StandardOutput=append:/var/log/watchdog +StandardError=append:/var/log/watchdog [Install] WantedBy=multi-user.target -# Version 1.0: +# Version 1.1: # Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. \ No newline at end of file From 4a2afa57e0bc76d4e3276238d9a280cda30f280f Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:32:45 +0100 Subject: [PATCH 05/89] install.sh aktualisiert --- install.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 5beeb11..b701ec6 100644 --- a/install.sh +++ b/install.sh @@ -65,8 +65,15 @@ sudo systemctl daemon-reload >>/var/log/install 2>&1 && print_status "Daemon rel sudo systemctl enable watchdog chromium-monitor vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "Services enabled" sudo systemctl restart getty@tty1 >>/var/log/install 2>&1 && print_status "getty service restarted" -echo -e "${RED}→${NC} Cleaning up old kernels..." -sudo bash /root/remove_unused_kernel.sh -u -e >>/var/log/install 2>&1 && print_status "Old kernels cleaned up" +# Ask user about cleaning unused kernels +echo -e "${RED}→${NC} Do you want to clean up unused kernels? (yes/y/ye to proceed):" +read -r clean_kernels +if [[ "$clean_kernels" =~ ^[Yy](e[Ss]?)?$ ]]; then + echo -e "${RED}→${NC} Cleaning up unused kernels..." + sudo bash /root/remove_unused_kernel.sh -u -e >>/var/log/install 2>&1 && print_status "Unused kernels cleaned up" +else + echo -e "${RED}→${NC} Skipping unused kernel cleanup." +fi echo -e "${RED}→${NC} Cleaning up installer..." sudo rm -rf ./rps-client >>/var/log/install 2>&1 && print_status "Installer cleaned up" @@ -75,5 +82,5 @@ echo -e "${GREEN}✔${NC} Installation complete. Press any key to reboot..." read -n 1 -s sudo reboot -# Version 1.1: +# Version 1.2: # Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. From 5940c1e4e8dca5db3adf4da25e9c6676a755ca4c Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:33:04 +0100 Subject: [PATCH 06/89] =?UTF-8?q?.gitignore=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c674098..0000000 --- a/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -# ---> Linux -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - From b01e957dfa7c464d63155542a2e59eb868ff19e7 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:35:44 +0100 Subject: [PATCH 07/89] =?UTF-8?q?roo/.ssh/id=5Frsa.pub=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roo/.ssh/id_rsa.pub | 1 + 1 file changed, 1 insertion(+) create mode 100644 roo/.ssh/id_rsa.pub diff --git a/roo/.ssh/id_rsa.pub b/roo/.ssh/id_rsa.pub new file mode 100644 index 0000000..ddaa81d --- /dev/null +++ b/roo/.ssh/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCYDmONGe644a3bWKAyX1W704B8fCwlj4x/QjwyJX6gKpX2hmtrxZtusK729wTxP0lr1Gzll9A8LAEGqW5/sxxJqwtYDMOEfINsgE8fmvg9XSmJ9t5zOxJAuQfJB/dmE2a2mX3VSH740czvJ6NKlf9BUeu+41ZZUilyHngfgpVxEIED/6ZHRrkMUfaY09IfvwmNiYPTtK4cufLBdeEoNJPQvYdY1i+N+cJstUzlDRs179w8CqLPuPhIb0iQ3WO1S1XXQH4vUm4MaMmK+hDR4J/pfhuI3DXulwE04rZFU2izXQwl5VdYLv8w31gcegyRz68p+LprusY4QiDP62yaUCTE6JdrjjQSxbEag+OqCzozfvoO+SxMdWsxg2eViM4sKTODc0cQBSA4HJcDWeag5LU9k4WGeuVVj8BCCBqh+93IqylqyK7AKMztVZNiftSBEbfK8ZoHawg5PM26LtCTz6YcmGhn/dHpcpyC8606+SHSTl5YinDaRjarCBM4nppD3o5pizVFKutI28Ys3wkVAe96njnJqIi/J5tNQgrbJmteCE3/9SWhpsXjnuZX1RaZYLE3bBg8Gisz/sm7rN3acVXe6QD03PIxwn9Xp8r3avzDkQKo4vqxoYK6JF6j3vs+U4WLElq+NtvuMewfAWF2cgL2quognLWUM5s0p1/zLzxa8w== \ No newline at end of file From 67e55e37bbdc0a20b3cb7da7cb48e52cf7003755 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:36:02 +0100 Subject: [PATCH 08/89] =?UTF-8?q?roo/.ssh/id=5Frsa.pub=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roo/.ssh/id_rsa.pub | 1 - 1 file changed, 1 deletion(-) delete mode 100644 roo/.ssh/id_rsa.pub diff --git a/roo/.ssh/id_rsa.pub b/roo/.ssh/id_rsa.pub deleted file mode 100644 index ddaa81d..0000000 --- a/roo/.ssh/id_rsa.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCYDmONGe644a3bWKAyX1W704B8fCwlj4x/QjwyJX6gKpX2hmtrxZtusK729wTxP0lr1Gzll9A8LAEGqW5/sxxJqwtYDMOEfINsgE8fmvg9XSmJ9t5zOxJAuQfJB/dmE2a2mX3VSH740czvJ6NKlf9BUeu+41ZZUilyHngfgpVxEIED/6ZHRrkMUfaY09IfvwmNiYPTtK4cufLBdeEoNJPQvYdY1i+N+cJstUzlDRs179w8CqLPuPhIb0iQ3WO1S1XXQH4vUm4MaMmK+hDR4J/pfhuI3DXulwE04rZFU2izXQwl5VdYLv8w31gcegyRz68p+LprusY4QiDP62yaUCTE6JdrjjQSxbEag+OqCzozfvoO+SxMdWsxg2eViM4sKTODc0cQBSA4HJcDWeag5LU9k4WGeuVVj8BCCBqh+93IqylqyK7AKMztVZNiftSBEbfK8ZoHawg5PM26LtCTz6YcmGhn/dHpcpyC8606+SHSTl5YinDaRjarCBM4nppD3o5pizVFKutI28Ys3wkVAe96njnJqIi/J5tNQgrbJmteCE3/9SWhpsXjnuZX1RaZYLE3bBg8Gisz/sm7rN3acVXe6QD03PIxwn9Xp8r3avzDkQKo4vqxoYK6JF6j3vs+U4WLElq+NtvuMewfAWF2cgL2quognLWUM5s0p1/zLzxa8w== \ No newline at end of file From ef29887a400e8a46df085f6ef0feaa4d284516a0 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sun, 27 Oct 2024 18:36:19 +0100 Subject: [PATCH 09/89] =?UTF-8?q?root/.ssh/id=5Frsa.pub=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- root/.ssh/id_rsa.pub | 1 + 1 file changed, 1 insertion(+) create mode 100644 root/.ssh/id_rsa.pub diff --git a/root/.ssh/id_rsa.pub b/root/.ssh/id_rsa.pub new file mode 100644 index 0000000..ddaa81d --- /dev/null +++ b/root/.ssh/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCYDmONGe644a3bWKAyX1W704B8fCwlj4x/QjwyJX6gKpX2hmtrxZtusK729wTxP0lr1Gzll9A8LAEGqW5/sxxJqwtYDMOEfINsgE8fmvg9XSmJ9t5zOxJAuQfJB/dmE2a2mX3VSH740czvJ6NKlf9BUeu+41ZZUilyHngfgpVxEIED/6ZHRrkMUfaY09IfvwmNiYPTtK4cufLBdeEoNJPQvYdY1i+N+cJstUzlDRs179w8CqLPuPhIb0iQ3WO1S1XXQH4vUm4MaMmK+hDR4J/pfhuI3DXulwE04rZFU2izXQwl5VdYLv8w31gcegyRz68p+LprusY4QiDP62yaUCTE6JdrjjQSxbEag+OqCzozfvoO+SxMdWsxg2eViM4sKTODc0cQBSA4HJcDWeag5LU9k4WGeuVVj8BCCBqh+93IqylqyK7AKMztVZNiftSBEbfK8ZoHawg5PM26LtCTz6YcmGhn/dHpcpyC8606+SHSTl5YinDaRjarCBM4nppD3o5pizVFKutI28Ys3wkVAe96njnJqIi/J5tNQgrbJmteCE3/9SWhpsXjnuZX1RaZYLE3bBg8Gisz/sm7rN3acVXe6QD03PIxwn9Xp8r3avzDkQKo4vqxoYK6JF6j3vs+U4WLElq+NtvuMewfAWF2cgL2quognLWUM5s0p1/zLzxa8w== \ No newline at end of file From 54d218451a5446130edf2f1afc140d181d33aa6f Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 09:54:46 +0100 Subject: [PATCH 10/89] etc/systemd/system/watchdog.service aktualisiert --- etc/systemd/system/watchdog.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/systemd/system/watchdog.service b/etc/systemd/system/watchdog.service index 603c12a..1146e9e 100644 --- a/etc/systemd/system/watchdog.service +++ b/etc/systemd/system/watchdog.service @@ -5,7 +5,7 @@ After=network.target getty@tty1.service [Service] ExecStartPre=-/bin/sleep 120 Type=simple -ExecStart=/usr/bin/watchdog +ExecStart=/usr/bin/watchdog/watchdog Restart=on-failure RestartSec=5s StandardOutput=append:/var/log/watchdog From d96260222c0ea1b5ad314957fb6f64395474b0bd Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:01:36 +0100 Subject: [PATCH 11/89] usr/bin/chromium-monitor aktualisiert --- usr/bin/chromium-monitor | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/usr/bin/chromium-monitor b/usr/bin/chromium-monitor index 3777eb0..cf276a1 100644 --- a/usr/bin/chromium-monitor +++ b/usr/bin/chromium-monitor @@ -1,36 +1,58 @@ #!/bin/bash + +LOGFILE="/var/log/chromium-monitor.log" + get_monitor() { sudo cat /var/lib/dhcp/* | grep -a "option monitor" | tail -1 | \ awk '{ s = ""; for (i = 3; i <= NF; i++) s = s $i " "; print s}' | \ awk -F '"' '{print $2}' } + get_current_window() { DISPLAY=:0 xdotool getwindowfocus getwindowname | awk -F '- Chromium' '{print $1}' } + monitor="" while [ -z "$monitor" ]; do monitor=$(get_monitor) + echo "Current monitor: $monitor" >> $LOGFILE # Debug output if [ -z "$monitor" ]; then sleep 5 fi done + monitor_md5=$(echo -n ${monitor^^} | sed -e 's/^[[:space:]]*//' | md5sum | awk '{print $1}') +echo "Monitor MD5: $monitor_md5" >> $LOGFILE # Debug output + while true; do new_monitor=$(get_monitor) new_current=$(get_current_window) + + # Log the current state + echo "New monitor: $new_monitor" >> $LOGFILE # Debug output + echo "New current window: $new_current" >> $LOGFILE # Debug output + if [ -n "$new_monitor" ] && [ -n "$new_current" ]; then new_monitor_md5=$(echo -n ${new_monitor^^} | sed -e 's/^[[:space:]]*//' | md5sum | awk '{print $1}') current_md5=$(echo -n ${new_current^^} | sed -e 's/^[[:space:]]*//' | md5sum | awk '{print $1}') + + # Log the computed MD5 hashes + echo "New monitor MD5: $new_monitor_md5" >> $LOGFILE # Debug output + echo "Current window MD5: $current_md5" >> $LOGFILE # Debug output + if [ "$new_monitor_md5" != "$monitor_md5" ] && [ "$current_md5" != "$monitor_md5" ]; then - echo "Mismatch detected. Rebooting now." >> /var/log/chromium-monitor + echo "Mismatch detected. Rebooting now." >> $LOGFILE sudo reboot exit 1 fi else - echo "Either monitor or current is not available, skipping check." >> /var/log/chromium-monitor + echo "Either monitor or current is not available, skipping check." >> $LOGFILE fi + + # Log the status before sleeping + echo "Sleeping for 5 seconds before the next check..." >> $LOGFILE sleep 5s done # Version 1.0: -# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. \ No newline at end of file +# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. From 0d1a2b7c21004089129df24f3d63e631cea5f0ce Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:02:32 +0100 Subject: [PATCH 12/89] usr/bin/watchdog aktualisiert --- usr/bin/watchdog | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/usr/bin/watchdog b/usr/bin/watchdog index af5ff4c..b457f0a 100644 --- a/usr/bin/watchdog +++ b/usr/bin/watchdog @@ -1,22 +1,46 @@ #!/bin/bash + +# Log file +log_file="/var/log/watchdog.log" + +# Extract watchdog IP addresses watchdog=$(sudo cat /var/lib/dhcp/* | grep -a "option watchdog" | tail -1 | \ awk '{for (i=3; i<=NF; i++) printf "%s ", $i}' | tr -d '";') IFS=' ' read -r -a ip_array <<< "$watchdog" + +# Configuration file config_file="/etc/watchdog.conf" -sudo cp "$config_file" "$config_file.bak" + +# Backup current configuration +if sudo cp "$config_file" "$config_file.bak"; then + echo "Backup of $config_file created successfully." >> "$log_file" +else + echo "Failed to create backup of $config_file." >> "$log_file" +fi + +# Clean existing configurations sudo sed -i '/ping/d' "$config_file" sudo sed -i '/^interval/d' "$config_file" + +# Set interval echo "interval = 60" | sudo tee -a "$config_file" > /dev/null + if [ ${#ip_array[@]} -eq 0 ]; then - sudo sed -i '/interval/d' "$config_file" - echo "No IP addresses found. Watchdog configuration cleared." >> /var/log/watchdog 2>&1 + echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" sudo systemctl stop watchdog else for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null done + echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file" +fi + +# Restart watchdog service +if sudo systemctl restart watchdog; then + echo "Watchdog service restarted successfully." >> "$log_file" +else + echo "Failed to restart watchdog service." >> "$log_file" fi -sudo systemctl restart watchdog >> /var/log/watchdog 2>&1 # Version 1.1: -# Created 2024 by Tim Eertmoed @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. \ No newline at end of file +# Created 2024 by Tim Eertmoed @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. From dece859ca8c5d7544174030c3eabe98e5af689b6 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:04:35 +0100 Subject: [PATCH 13/89] install.sh aktualisiert --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index b701ec6..d9adf54 100644 --- a/install.sh +++ b/install.sh @@ -55,7 +55,7 @@ sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ ./rps-client/root/remove_unused_kernel.sh /root/remove_unused_kernel.sh \ ./rps-client/root/.vnc/config.d/vncserver-x11 /root/.vnc/config.d/vncserver-x11 \ ./rps-client/usr/bin/chromium-monitor /usr/bin/chromium-monitor \ - ./rps-client/usr/bin/watchdog /usr/bin/watchdog >>/var/log/install 2>&1 && print_status "Required files copied" + ./rps-client/usr/bin/watchdog /usr/bin/watchdog/watchdog >>/var/log/install 2>&1 && print_status "Required files copied" echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" From 83c6f7de7068d94f176727b0a1a8b32e3cd54b4a Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:41:40 +0100 Subject: [PATCH 14/89] install.sh aktualisiert --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d9adf54..b701ec6 100644 --- a/install.sh +++ b/install.sh @@ -55,7 +55,7 @@ sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ ./rps-client/root/remove_unused_kernel.sh /root/remove_unused_kernel.sh \ ./rps-client/root/.vnc/config.d/vncserver-x11 /root/.vnc/config.d/vncserver-x11 \ ./rps-client/usr/bin/chromium-monitor /usr/bin/chromium-monitor \ - ./rps-client/usr/bin/watchdog /usr/bin/watchdog/watchdog >>/var/log/install 2>&1 && print_status "Required files copied" + ./rps-client/usr/bin/watchdog /usr/bin/watchdog >>/var/log/install 2>&1 && print_status "Required files copied" echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" From 8fe03e7cadaedb527f10af320df0f9d3744c3d16 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:43:36 +0100 Subject: [PATCH 15/89] usr/bin/custom/chromium-monitor aktualisiert --- usr/bin/{ => custom}/chromium-monitor | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename usr/bin/{ => custom}/chromium-monitor (100%) diff --git a/usr/bin/chromium-monitor b/usr/bin/custom/chromium-monitor similarity index 100% rename from usr/bin/chromium-monitor rename to usr/bin/custom/chromium-monitor From 8038479898dc7c485506063e44627c0fc8db038f Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:43:46 +0100 Subject: [PATCH 16/89] usr/bin/custom/watchdog aktualisiert --- usr/bin/{ => custom}/watchdog | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename usr/bin/{ => custom}/watchdog (100%) diff --git a/usr/bin/watchdog b/usr/bin/custom/watchdog similarity index 100% rename from usr/bin/watchdog rename to usr/bin/custom/watchdog From 0d081f2380b1ab679e6c41a5264d30c7f9a5ff16 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:45:03 +0100 Subject: [PATCH 17/89] install.sh aktualisiert --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index b701ec6..49a9e0c 100644 --- a/install.sh +++ b/install.sh @@ -54,8 +54,8 @@ sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ ./rps-client/home/wis/.ssh/id_rsa.pub /home/wis/.ssh/id_rsa.pub \ ./rps-client/root/remove_unused_kernel.sh /root/remove_unused_kernel.sh \ ./rps-client/root/.vnc/config.d/vncserver-x11 /root/.vnc/config.d/vncserver-x11 \ - ./rps-client/usr/bin/chromium-monitor /usr/bin/chromium-monitor \ - ./rps-client/usr/bin/watchdog /usr/bin/watchdog >>/var/log/install 2>&1 && print_status "Required files copied" + ./rps-client/usr/bin/custom/chromium-monitor /usr/bin/custom/chromium-monitor \ + ./rps-client/usr/bin/custom/watchdog /usr/bin/custom/watchdog >>/var/log/install 2>&1 && print_status "Required files copied" echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" From b39edf634370d57fb786eb47fd44e610d225ed2d Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:45:43 +0100 Subject: [PATCH 18/89] etc/systemd/system/chromium-monitor.service aktualisiert --- etc/systemd/system/chromium-monitor.service | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/etc/systemd/system/chromium-monitor.service b/etc/systemd/system/chromium-monitor.service index ad01e73..7f1c799 100644 --- a/etc/systemd/system/chromium-monitor.service +++ b/etc/systemd/system/chromium-monitor.service @@ -3,13 +3,14 @@ Description=A Service to monitor the Kiosk's current site After=network.target getty@tty1.service [Service] -ExecStartPre=-/bin/sleep 120 +ExecStartPre=-/bin/sleep 10 Type=simple -ExecStart=/usr/bin/chromium-monitor +User=loginuser +ExecStart=/usr/bin/custom/chromium-monitor Restart=on-failure RestartSec=5s -StandardOutput=append:/var/log/chromium-monitor -StandardError=append:/var/log/chromium-monitor +StandardOutput=append:/var/log/chromium-monitor.log +StandardError=append:/var/log/chromium-monitor.log [Install] WantedBy=multi-user.target From b92150590662ea974ce9aafd9a2138181ae519c9 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:45:55 +0100 Subject: [PATCH 19/89] etc/systemd/system/watchdog.service aktualisiert --- etc/systemd/system/watchdog.service | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/systemd/system/watchdog.service b/etc/systemd/system/watchdog.service index 1146e9e..dd878e8 100644 --- a/etc/systemd/system/watchdog.service +++ b/etc/systemd/system/watchdog.service @@ -3,8 +3,9 @@ Description=Watchdog Monitor Service After=network.target getty@tty1.service [Service] -ExecStartPre=-/bin/sleep 120 +ExecStartPre=-/bin/sleep 10 Type=simple +User=loginuser ExecStart=/usr/bin/watchdog/watchdog Restart=on-failure RestartSec=5s From 0b8a9d2ba645e44fdd815bd5dc13335654d4b1b9 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 13:51:09 +0100 Subject: [PATCH 20/89] install.sh aktualisiert --- install.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 49a9e0c..33358ea 100644 --- a/install.sh +++ b/install.sh @@ -60,12 +60,20 @@ sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" +echo -e "${RED}→${NC} Creating log files..." +sudo touch /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Log files created" + +echo -e "${RED}→${NC} Setting ownership for log files..." +sudo chown loginuser:loginuser /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Ownership set for log files" + +echo -e "${RED}→${NC} Setting permissions for log files..." +sudo chmod 664 /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Permissions set for log files" + echo -e "${RED}→${NC} Enabling services..." sudo systemctl daemon-reload >>/var/log/install 2>&1 && print_status "Daemon reloaded" sudo systemctl enable watchdog chromium-monitor vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "Services enabled" sudo systemctl restart getty@tty1 >>/var/log/install 2>&1 && print_status "getty service restarted" -# Ask user about cleaning unused kernels echo -e "${RED}→${NC} Do you want to clean up unused kernels? (yes/y/ye to proceed):" read -r clean_kernels if [[ "$clean_kernels" =~ ^[Yy](e[Ss]?)?$ ]]; then From 1d22c6dc076c8b8efd5a6fd4addc3cbc85182a37 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 14:02:25 +0100 Subject: [PATCH 21/89] =?UTF-8?q?usr/bin/hostname=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/bin/hostname | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 usr/bin/hostname diff --git a/usr/bin/hostname b/usr/bin/hostname new file mode 100644 index 0000000..768edcd --- /dev/null +++ b/usr/bin/hostname @@ -0,0 +1,32 @@ +#!/bin/bash + +LOGFILE="/var/log/hostname.log" + +# Function to read the hostname from the DHCP lease file +get_hostname() { + sudo cat /var/lib/dhcp/* | grep -a "option host-name" | tail -1 | \ + awk -F '"' '{print $2}' +} + +# Function to update /etc/hosts with the new hostname +update_hosts() { + local hostname="$1" + # Replace the second line with the new hostname + sudo sed -i "2s/.*/127.0.1.1 ${hostname}/" /etc/hosts + echo "Updated /etc/hosts with hostname: $hostname" >> $LOGFILE +} + +# Read the hostname from DHCP +hostname=$(get_hostname) + +if [ -n "$hostname" ]; then + update_hosts "$hostname" +else + echo "No hostname found." >> $LOGFILE +fi + +# Log completion +echo "Hostname update script completed." >> $LOGFILE + +# Version 1.0: +# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. From 4b607c3ad8956a1715092d3cbc20ce8be0ca91b8 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 14:03:39 +0100 Subject: [PATCH 22/89] =?UTF-8?q?etc/systemd/system/hostname.service=20hin?= =?UTF-8?q?zugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- etc/systemd/system/hostname.service | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 etc/systemd/system/hostname.service diff --git a/etc/systemd/system/hostname.service b/etc/systemd/system/hostname.service new file mode 100644 index 0000000..c3eeabe --- /dev/null +++ b/etc/systemd/system/hostname.service @@ -0,0 +1,11 @@ +[Unit] +Description=Set Hostname from DHCP +After=network.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/custom/hostname +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target From 134a398fb9242e0b9b9e6027a56debf0ff6c2312 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 14:05:07 +0100 Subject: [PATCH 23/89] usr/bin/custom/hostname aktualisiert --- usr/bin/{ => custom}/hostname | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename usr/bin/{ => custom}/hostname (100%) diff --git a/usr/bin/hostname b/usr/bin/custom/hostname similarity index 100% rename from usr/bin/hostname rename to usr/bin/custom/hostname From 26058e12f776ae0bcd0fa56f284592b1ba44b406 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 14:06:16 +0100 Subject: [PATCH 24/89] usr/bin/custom/hostname aktualisiert --- usr/bin/custom/hostname | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usr/bin/custom/hostname b/usr/bin/custom/hostname index 768edcd..fec09f9 100644 --- a/usr/bin/custom/hostname +++ b/usr/bin/custom/hostname @@ -20,6 +20,9 @@ update_hosts() { hostname=$(get_hostname) if [ -n "$hostname" ]; then + # Set the hostname using hostnamectl + sudo hostnamectl set-hostname "$hostname" + echo "Set hostname to: $hostname" >> $LOGFILE update_hosts "$hostname" else echo "No hostname found." >> $LOGFILE From 57b5cd53974ae1006d1f3469da3eba7ce9687d4d Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 14:11:42 +0100 Subject: [PATCH 25/89] install.sh aktualisiert --- install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 33358ea..10021c0 100644 --- a/install.sh +++ b/install.sh @@ -45,6 +45,7 @@ sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ ./rps-client/boot/ro-root.sh /boot/ro-root.sh \ ./rps-client/boot/firmware/ro-root.sh /boot/firmware/ro-root.sh \ ./rps-client/etc/dhcp/dhclient.conf /etc/dhcp/dhclient.conf \ + ./rps-client/etc/systemd/system/hostname.service /etc/systemd/system/hostname.service \ ./rps-client/etc/systemd/system/watchdog.service /etc/systemd/system/watchdog.service \ ./rps-client/etc/systemd/system/chromium-monitor.service /etc/systemd/system/chromium-monitor.service \ ./rps-client/etc/systemd/system/getty@tty1.service.d/override.conf /etc/systemd/system/getty@tty1.service.d/override.conf \ @@ -54,6 +55,7 @@ sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ ./rps-client/home/wis/.ssh/id_rsa.pub /home/wis/.ssh/id_rsa.pub \ ./rps-client/root/remove_unused_kernel.sh /root/remove_unused_kernel.sh \ ./rps-client/root/.vnc/config.d/vncserver-x11 /root/.vnc/config.d/vncserver-x11 \ + ./rps-client/usr/bin/custom/hostname /usr/bin/custom/hostname \ ./rps-client/usr/bin/custom/chromium-monitor /usr/bin/custom/chromium-monitor \ ./rps-client/usr/bin/custom/watchdog /usr/bin/custom/watchdog >>/var/log/install 2>&1 && print_status "Required files copied" @@ -71,7 +73,7 @@ sudo chmod 664 /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/in echo -e "${RED}→${NC} Enabling services..." sudo systemctl daemon-reload >>/var/log/install 2>&1 && print_status "Daemon reloaded" -sudo systemctl enable watchdog chromium-monitor vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "Services enabled" +sudo systemctl enable hostname watchdog chromium-monitor vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "Services enabled" sudo systemctl restart getty@tty1 >>/var/log/install 2>&1 && print_status "getty service restarted" echo -e "${RED}→${NC} Do you want to clean up unused kernels? (yes/y/ye to proceed):" From e511fcb885845f86fd1702ce469f54769dc7f869 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 15:23:43 +0100 Subject: [PATCH 26/89] install.sh aktualisiert --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 10021c0..e96778b 100644 --- a/install.sh +++ b/install.sh @@ -17,17 +17,18 @@ sudo apt upgrade -y >>/var/log/install 2>&1 && print_status "System Upgrade" sudo apt dist-upgrade -y >>/var/log/install 2>&1 && print_status "System Dist-Upgrade" sudo apt autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove" sudo apt clean >>/var/log/install 2>&1 && print_status "Clean" + rm -rf /var/lib/apt/lists/* "Clear cache" echo -e "${RED}→${NC} Installing required packages..." sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit chromium-browser fonts-noto-color-emoji nfs-common watchdog xdotool rsync -y >>/var/log/install 2>&1 && print_status "Required packages installed" -sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" +sudo apt install realvnc-vnc-server -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" echo -e "${RED}→${NC} Creating user 'loginuser'..." sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' -loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart watchdog, /usr/bin/systemctl restart chromium-monitor +loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart watchdog, /usr/bin/systemctl status watchdog, /usr/bin/systemctl restart chromium-monitor, /usr/bin/systemctl status chromium-monitor loginuser ALL=(ALL) NOPASSWD: /usr/bin/echo, /usr/bin/cp, /usr/bin/sed loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* From b6d889a34874ed2644e896c3f1bb064d70133fbf Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 15:29:05 +0100 Subject: [PATCH 27/89] etc/systemd/system/watchdog.service aktualisiert --- etc/systemd/system/watchdog.service | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/systemd/system/watchdog.service b/etc/systemd/system/watchdog.service index dd878e8..82be632 100644 --- a/etc/systemd/system/watchdog.service +++ b/etc/systemd/system/watchdog.service @@ -3,14 +3,14 @@ Description=Watchdog Monitor Service After=network.target getty@tty1.service [Service] -ExecStartPre=-/bin/sleep 10 +ExecStartPre=-/usr/bin/sleep 10 Type=simple User=loginuser -ExecStart=/usr/bin/watchdog/watchdog +ExecStart=/usr/bin/custom/watchdog Restart=on-failure RestartSec=5s -StandardOutput=append:/var/log/watchdog -StandardError=append:/var/log/watchdog +StandardOutput=append:/var/log/watchdog.log +StandardError=append:/var/log/watchdog.log [Install] WantedBy=multi-user.target From 5f9f63d026f29d5fdf4ef3135027fa6c544897cd Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 15:29:25 +0100 Subject: [PATCH 28/89] etc/systemd/system/chromium-monitor.service aktualisiert --- etc/systemd/system/chromium-monitor.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/systemd/system/chromium-monitor.service b/etc/systemd/system/chromium-monitor.service index 7f1c799..ca863e1 100644 --- a/etc/systemd/system/chromium-monitor.service +++ b/etc/systemd/system/chromium-monitor.service @@ -3,7 +3,7 @@ Description=A Service to monitor the Kiosk's current site After=network.target getty@tty1.service [Service] -ExecStartPre=-/bin/sleep 10 +ExecStartPre=-/usr/bin/sleep 10 Type=simple User=loginuser ExecStart=/usr/bin/custom/chromium-monitor From 7276958e0b7d2a699b8b831c87a3d3ee3ab9ca64 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 15:40:26 +0100 Subject: [PATCH 29/89] install.sh aktualisiert --- install.sh | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index e96778b..7966d70 100644 --- a/install.sh +++ b/install.sh @@ -41,6 +41,40 @@ PermitRootLogin no EOF sudo passwd -l root >>/var/log/install 2>&1 && print_status "Root login disabled" +# Array of source and destination pairs +declare -A files=( + ["./rps-client/boot/ro-root.sh"]="/boot/ro-root.sh" + ["./rps-client/boot/firmware/ro-root.sh"]="/boot/firmware/ro-root.sh" + ["./rps-client/etc/dhcp/dhclient.conf"]="/etc/dhcp/dhclient.conf" + ["./rps-client/etc/systemd/system/hostname.service"]="/etc/systemd/system/hostname.service" + ["./rps-client/etc/systemd/system/watchdog.service"]="/etc/systemd/system/watchdog.service" + ["./rps-client/etc/systemd/system/chromium-monitor.service"]="/etc/systemd/system/chromium-monitor.service" + ["./rps-client/etc/systemd/system/getty@tty1.service.d/override.conf"]="/etc/systemd/system/getty@tty1.service.d/override.conf" + ["./rps-client/etc/chromium/policies/managed/disable_password_saving.json"]="/etc/chromium/policies/managed/disable_password_saving.json" + ["./rps-client/home/loginuser/.bash_profile"]="/home/loginuser/.bash_profile" + ["./rps-client/home/loginuser/.xinitrc"]="/home/loginuser/.xinitrc" + ["./rps-client/home/wis/.ssh/id_rsa.pub"]="/home/wis/.ssh/id_rsa.pub" + ["./rps-client/root/remove_unused_kernel.sh"]="/root/remove_unused_kernel.sh" + ["./rps-client/root/.vnc/config.d/vncserver-x11"]="/root/.vnc/config.d/vncserver-x11" + ["./rps-client/usr/bin/hostname"]="/usr/bin/custom/hostname" + ["./rps-client/usr/bin/chromium-monitor"]="/usr/bin/custom/chromium-monitor" + ["./rps-client/usr/bin/watchdog"]="/usr/bin/custom/watchdog" +) + +# Rsync options +RSYNC_OPTS="-a --numeric-ids --info=progress2 --no-owner --no-group" + +# Loop through and sync each file +for src in "${!files[@]}"; do + dst="${files[$src]}" + echo "Copying $src to $dst..." + sudo rsync $RSYNC_OPTS "$src" "$dst" >>/var/log/install 2>&1 && print_status "$src copied to $dst" +done + +# Final status message +print_status "All required files copied" + + echo -e "${RED}→${NC} Copying required files..." sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ ./rps-client/boot/ro-root.sh /boot/ro-root.sh \ @@ -56,9 +90,7 @@ sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ ./rps-client/home/wis/.ssh/id_rsa.pub /home/wis/.ssh/id_rsa.pub \ ./rps-client/root/remove_unused_kernel.sh /root/remove_unused_kernel.sh \ ./rps-client/root/.vnc/config.d/vncserver-x11 /root/.vnc/config.d/vncserver-x11 \ - ./rps-client/usr/bin/custom/hostname /usr/bin/custom/hostname \ - ./rps-client/usr/bin/custom/chromium-monitor /usr/bin/custom/chromium-monitor \ - ./rps-client/usr/bin/custom/watchdog /usr/bin/custom/watchdog >>/var/log/install 2>&1 && print_status "Required files copied" + echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" From 6a631c3aeed7cdf3bfaf6c4e207a9dc9e7077edb Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 16:08:29 +0100 Subject: [PATCH 30/89] install.sh aktualisiert --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 7966d70..d0f87e2 100644 --- a/install.sh +++ b/install.sh @@ -56,9 +56,9 @@ declare -A files=( ["./rps-client/home/wis/.ssh/id_rsa.pub"]="/home/wis/.ssh/id_rsa.pub" ["./rps-client/root/remove_unused_kernel.sh"]="/root/remove_unused_kernel.sh" ["./rps-client/root/.vnc/config.d/vncserver-x11"]="/root/.vnc/config.d/vncserver-x11" - ["./rps-client/usr/bin/hostname"]="/usr/bin/custom/hostname" - ["./rps-client/usr/bin/chromium-monitor"]="/usr/bin/custom/chromium-monitor" - ["./rps-client/usr/bin/watchdog"]="/usr/bin/custom/watchdog" + ["./rps-client/usr/bin/custom/hostname"]="/usr/bin/custom/hostname" + ["./rps-client/usr/bin/custom/chromium-monitor"]="/usr/bin/custom/chromium-monitor" + ["./rps-client/usr/bin/custom/watchdog"]="/usr/bin/custom/watchdog" ) # Rsync options From d012e5193de467951ba011b5cca2cc59ee2ba915 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 16:41:08 +0100 Subject: [PATCH 31/89] usr/bin/custom/chromium-monitor aktualisiert --- usr/bin/custom/chromium-monitor | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/usr/bin/custom/chromium-monitor b/usr/bin/custom/chromium-monitor index cf276a1..1308e40 100644 --- a/usr/bin/custom/chromium-monitor +++ b/usr/bin/custom/chromium-monitor @@ -21,26 +21,20 @@ while [ -z "$monitor" ]; do fi done -monitor_md5=$(echo -n ${monitor^^} | sed -e 's/^[[:space:]]*//' | md5sum | awk '{print $1}') -echo "Monitor MD5: $monitor_md5" >> $LOGFILE # Debug output +# Filter the first word from the initial monitor +initial_monitor_first_word=$(echo "$monitor" | awk '{print $1}') +echo "Monitor (first word): $initial_monitor_first_word" >> $LOGFILE # Debug output while true; do - new_monitor=$(get_monitor) - new_current=$(get_current_window) + new_monitor=$(get_monitor | awk '{print $1}') + new_current=$(get_current_window | awk '{print $1}') # Log the current state - echo "New monitor: $new_monitor" >> $LOGFILE # Debug output - echo "New current window: $new_current" >> $LOGFILE # Debug output + echo "New monitor (first word): '$new_monitor'" >> $LOGFILE # Debug output + echo "New current window (first word): '$new_current'" >> $LOGFILE # Debug output if [ -n "$new_monitor" ] && [ -n "$new_current" ]; then - new_monitor_md5=$(echo -n ${new_monitor^^} | sed -e 's/^[[:space:]]*//' | md5sum | awk '{print $1}') - current_md5=$(echo -n ${new_current^^} | sed -e 's/^[[:space:]]*//' | md5sum | awk '{print $1}') - - # Log the computed MD5 hashes - echo "New monitor MD5: $new_monitor_md5" >> $LOGFILE # Debug output - echo "Current window MD5: $current_md5" >> $LOGFILE # Debug output - - if [ "$new_monitor_md5" != "$monitor_md5" ] && [ "$current_md5" != "$monitor_md5" ]; then + if [ "$new_monitor" != "$initial_monitor_first_word" ] || [ "$new_current" != "$initial_monitor_first_word" ]; then echo "Mismatch detected. Rebooting now." >> $LOGFILE sudo reboot exit 1 @@ -54,5 +48,5 @@ while true; do sleep 5s done -# Version 1.0: -# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. +# Version 1.0: +# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. From 73ea27ac67fc8793f9feb35117fb9ea35b7cca17 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 16:59:11 +0100 Subject: [PATCH 32/89] usr/bin/custom/chromium-monitor aktualisiert --- usr/bin/custom/chromium-monitor | 38 ++++++++++++++------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/usr/bin/custom/chromium-monitor b/usr/bin/custom/chromium-monitor index 1308e40..57ab03f 100644 --- a/usr/bin/custom/chromium-monitor +++ b/usr/bin/custom/chromium-monitor @@ -2,51 +2,45 @@ LOGFILE="/var/log/chromium-monitor.log" +# Function to get the monitor value from DHCP get_monitor() { sudo cat /var/lib/dhcp/* | grep -a "option monitor" | tail -1 | \ awk '{ s = ""; for (i = 3; i <= NF; i++) s = s $i " "; print s}' | \ awk -F '"' '{print $2}' } +# Function to get the current window name get_current_window() { DISPLAY=:0 xdotool getwindowfocus getwindowname | awk -F '- Chromium' '{print $1}' } +# Initialize monitor variable monitor="" while [ -z "$monitor" ]; do monitor=$(get_monitor) - echo "Current monitor: $monitor" >> $LOGFILE # Debug output - if [ -z "$monitor" ]; then - sleep 5 + if [ -n "$monitor" ]; then + echo "Initial monitor detected: $monitor" >> $LOGFILE # Log initial monitor fi + sleep 5 done -# Filter the first word from the initial monitor -initial_monitor_first_word=$(echo "$monitor" | awk '{print $1}') -echo "Monitor (first word): $initial_monitor_first_word" >> $LOGFILE # Debug output - +# Main loop to continuously check the current window while true; do - new_monitor=$(get_monitor | awk '{print $1}') - new_current=$(get_current_window | awk '{print $1}') + new_current=$(get_current_window | awk '{print $1}') # Get the first word of the current window - # Log the current state - echo "New monitor (first word): '$new_monitor'" >> $LOGFILE # Debug output - echo "New current window (first word): '$new_current'" >> $LOGFILE # Debug output - - if [ -n "$new_monitor" ] && [ -n "$new_current" ]; then - if [ "$new_monitor" != "$initial_monitor_first_word" ] || [ "$new_current" != "$initial_monitor_first_word" ]; then - echo "Mismatch detected. Rebooting now." >> $LOGFILE + if [ -n "$new_current" ]; then + # Check for mismatch + if [ "$new_current" != "$monitor" ]; then + echo "Mismatch detected! Monitor: $monitor, Current: $new_current" >> $LOGFILE + echo "Rebooting now." >> $LOGFILE sudo reboot exit 1 fi - else - echo "Either monitor or current is not available, skipping check." >> $LOGFILE fi - # Log the status before sleeping - echo "Sleeping for 5 seconds before the next check..." >> $LOGFILE - sleep 5s + # Sleep for a short duration before the next check + sleep 5 done # Version 1.0: -# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. +# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspbian as custom PXE init script. From f65185644d349e07600e9373632f418b79fdd7ac Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 17:15:43 +0100 Subject: [PATCH 33/89] install.sh aktualisiert --- install.sh | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index d0f87e2..4641417 100644 --- a/install.sh +++ b/install.sh @@ -74,39 +74,18 @@ done # Final status message print_status "All required files copied" - -echo -e "${RED}→${NC} Copying required files..." -sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \ - ./rps-client/boot/ro-root.sh /boot/ro-root.sh \ - ./rps-client/boot/firmware/ro-root.sh /boot/firmware/ro-root.sh \ - ./rps-client/etc/dhcp/dhclient.conf /etc/dhcp/dhclient.conf \ - ./rps-client/etc/systemd/system/hostname.service /etc/systemd/system/hostname.service \ - ./rps-client/etc/systemd/system/watchdog.service /etc/systemd/system/watchdog.service \ - ./rps-client/etc/systemd/system/chromium-monitor.service /etc/systemd/system/chromium-monitor.service \ - ./rps-client/etc/systemd/system/getty@tty1.service.d/override.conf /etc/systemd/system/getty@tty1.service.d/override.conf \ - ./rps-client/etc/chromium/policies/managed/disable_password_saving.json /etc/chromium/policies/managed/disable_password_saving.json \ - ./rps-client/home/loginuser/.bash_profile /home/loginuser/.bash_profile \ - ./rps-client/home/loginuser/.xinitrc /home/loginuser/.xinitrc \ - ./rps-client/home/wis/.ssh/id_rsa.pub /home/wis/.ssh/id_rsa.pub \ - ./rps-client/root/remove_unused_kernel.sh /root/remove_unused_kernel.sh \ - ./rps-client/root/.vnc/config.d/vncserver-x11 /root/.vnc/config.d/vncserver-x11 \ - - echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" echo -e "${RED}→${NC} Creating log files..." sudo touch /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Log files created" - -echo -e "${RED}→${NC} Setting ownership for log files..." sudo chown loginuser:loginuser /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Ownership set for log files" - -echo -e "${RED}→${NC} Setting permissions for log files..." -sudo chmod 664 /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Permissions set for log files" +sudo chmod 775 /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Permissions set for log files" +sudo chmod +x /usr/bin/custom/* >>/var/log/install 2>&1 && print_status "Permissions set for script files" echo -e "${RED}→${NC} Enabling services..." sudo systemctl daemon-reload >>/var/log/install 2>&1 && print_status "Daemon reloaded" -sudo systemctl enable hostname watchdog chromium-monitor vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "Services enabled" +sudo systemctl enable hostname watchdog chromium-monitor vncserver-x11-serviced.service getty@tty1 >>/var/log/install 2>&1 && print_status "Services enabled" sudo systemctl restart getty@tty1 >>/var/log/install 2>&1 && print_status "getty service restarted" echo -e "${RED}→${NC} Do you want to clean up unused kernels? (yes/y/ye to proceed):" From 0dc0236f40c44cbee9644425c6e8c3833d76013c Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 17:21:55 +0100 Subject: [PATCH 34/89] etc/systemd/system/watchdog.service aktualisiert --- etc/systemd/system/watchdog.service | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/etc/systemd/system/watchdog.service b/etc/systemd/system/watchdog.service index 82be632..65f2427 100644 --- a/etc/systemd/system/watchdog.service +++ b/etc/systemd/system/watchdog.service @@ -1,14 +1,12 @@ [Unit] Description=Watchdog Monitor Service -After=network.target getty@tty1.service +#After=network.target getty@tty1.service [Service] ExecStartPre=-/usr/bin/sleep 10 Type=simple User=loginuser ExecStart=/usr/bin/custom/watchdog -Restart=on-failure -RestartSec=5s StandardOutput=append:/var/log/watchdog.log StandardError=append:/var/log/watchdog.log From 7d05ae6fa4b53ae5b257f9ce76b3ddf49f778cbf Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 17:22:16 +0100 Subject: [PATCH 35/89] etc/systemd/system/chromium-monitor.service aktualisiert --- etc/systemd/system/chromium-monitor.service | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/etc/systemd/system/chromium-monitor.service b/etc/systemd/system/chromium-monitor.service index ca863e1..6e14f4a 100644 --- a/etc/systemd/system/chromium-monitor.service +++ b/etc/systemd/system/chromium-monitor.service @@ -1,14 +1,12 @@ [Unit] Description=A Service to monitor the Kiosk's current site -After=network.target getty@tty1.service +#After=network.target getty@tty1.service [Service] ExecStartPre=-/usr/bin/sleep 10 Type=simple User=loginuser ExecStart=/usr/bin/custom/chromium-monitor -Restart=on-failure -RestartSec=5s StandardOutput=append:/var/log/chromium-monitor.log StandardError=append:/var/log/chromium-monitor.log From 0d5e790cd2c34913360936afb6fd4db186b8b183 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 18:29:13 +0100 Subject: [PATCH 36/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/{watchdog => watchdog-monitor} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename usr/bin/custom/{watchdog => watchdog-monitor} (100%) diff --git a/usr/bin/custom/watchdog b/usr/bin/custom/watchdog-monitor similarity index 100% rename from usr/bin/custom/watchdog rename to usr/bin/custom/watchdog-monitor From 9b85eddf0991ca69634df6c39de6b73065a6e029 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 18:45:05 +0100 Subject: [PATCH 37/89] usr/bin/custom/watchdog aktualisiert --- usr/bin/custom/{watchdog-monitor => watchdog} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename usr/bin/custom/{watchdog-monitor => watchdog} (100%) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog similarity index 100% rename from usr/bin/custom/watchdog-monitor rename to usr/bin/custom/watchdog From bf0b5e857fa14831252c5d0d929be8bdff626067 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 18:53:03 +0100 Subject: [PATCH 38/89] usr/bin/custom/watchdog aktualisiert --- usr/bin/custom/watchdog | 90 ++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/usr/bin/custom/watchdog b/usr/bin/custom/watchdog index b457f0a..316b9f8 100644 --- a/usr/bin/custom/watchdog +++ b/usr/bin/custom/watchdog @@ -3,44 +3,68 @@ # Log file log_file="/var/log/watchdog.log" -# Extract watchdog IP addresses -watchdog=$(sudo cat /var/lib/dhcp/* | grep -a "option watchdog" | tail -1 | \ -awk '{for (i=3; i<=NF; i++) printf "%s ", $i}' | tr -d '";') -IFS=' ' read -r -a ip_array <<< "$watchdog" - # Configuration file config_file="/etc/watchdog.conf" -# Backup current configuration -if sudo cp "$config_file" "$config_file.bak"; then - echo "Backup of $config_file created successfully." >> "$log_file" -else - echo "Failed to create backup of $config_file." >> "$log_file" -fi +# Function to update watchdog configuration +update_watchdog_config() { + # Extract watchdog IP addresses + watchdog=$(sudo cat /var/lib/dhcp/* | grep -a "option watchdog" | tail -1 | \ + awk '{for (i=3; i<=NF; i++) printf "%s ", $i}' | tr -d '";') + + IFS=' ' read -r -a ip_array <<< "$watchdog" -# Clean existing configurations -sudo sed -i '/ping/d' "$config_file" -sudo sed -i '/^interval/d' "$config_file" + # Backup current configuration + if sudo cp "$config_file" "$config_file.bak"; then + echo "Backup of $config_file created successfully." >> "$log_file" + else + echo "Failed to create backup of $config_file." >> "$log_file" + fi -# Set interval -echo "interval = 60" | sudo tee -a "$config_file" > /dev/null + # Clean existing configurations + sudo sed -i '/ping/d' "$config_file" + sudo sed -i '/^interval/d' "$config_file" -if [ ${#ip_array[@]} -eq 0 ]; then - echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" - sudo systemctl stop watchdog -else - for ip in "${ip_array[@]}"; do - echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null - done - echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file" -fi + # Set interval + echo "interval = 60" | sudo tee -a "$config_file" > /dev/null -# Restart watchdog service -if sudo systemctl restart watchdog; then - echo "Watchdog service restarted successfully." >> "$log_file" -else - echo "Failed to restart watchdog service." >> "$log_file" -fi + if [ ${#ip_array[@]} -eq 0 ]; then + echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" + else + for ip in "${ip_array[@]}"; do + echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null + done + echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file" + fi -# Version 1.1: -# Created 2024 by Tim Eertmoed @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. + # Restart watchdog service + if sudo systemctl restart watchdog; then + echo "Watchdog service restarted successfully." >> "$log_file" + else + echo "Failed to restart watchdog service." >> "$log_file" + fi +} + +# Main loop +start_time=$(date +%s) +end_time=$((start_time + 300)) # 5 minutes in seconds +interval=30 # Initial interval of 30 seconds + +while true; do + update_watchdog_config + + current_time=$(date +%s) + + # Check if 5 minutes have passed + if [ "$current_time" -ge "$end_time" ]; then + echo "5 minutes have passed. Stopping the watchdog service." >> "$log_file" + sudo systemctl stop watchdog + break # Exit the loop + fi + + echo "Waiting for $interval seconds before checking for IP addresses again..." >> "$log_file" + sleep $interval +done + +# Version 1.4: +# Created 2024 by Tim Eertmoed @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom PXE init script. From cdfd6359da9ebd27ceae3fb67b69820ef3d4d8f6 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 18:59:56 +0100 Subject: [PATCH 39/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/{watchdog => watchdog-monitor} | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) rename usr/bin/custom/{watchdog => watchdog-monitor} (76%) diff --git a/usr/bin/custom/watchdog b/usr/bin/custom/watchdog-monitor similarity index 76% rename from usr/bin/custom/watchdog rename to usr/bin/custom/watchdog-monitor index 316b9f8..dc1cc90 100644 --- a/usr/bin/custom/watchdog +++ b/usr/bin/custom/watchdog-monitor @@ -35,14 +35,18 @@ update_watchdog_config() { echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null done echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file" + + # Restart watchdog service since IP addresses were found + if sudo systemctl restart watchdog; then + echo "Watchdog service restarted successfully." >> "$log_file" + else + echo "Failed to restart watchdog service." >> "$log_file" + fi + + return 1 # Indicate that IP addresses were found fi - # Restart watchdog service - if sudo systemctl restart watchdog; then - echo "Watchdog service restarted successfully." >> "$log_file" - else - echo "Failed to restart watchdog service." >> "$log_file" - fi + return 0 # Indicate that no IP addresses were found } # Main loop @@ -51,8 +55,11 @@ end_time=$((start_time + 300)) # 5 minutes in seconds interval=30 # Initial interval of 30 seconds while true; do - update_watchdog_config - + if update_watchdog_config; then + echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file" + break # Exit the loop if IP addresses were found + fi + current_time=$(date +%s) # Check if 5 minutes have passed From 86b3bdae710a4bb13588f111951646f29f03b289 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:00:47 +0100 Subject: [PATCH 40/89] etc/systemd/system/watchdog-monitor.service aktualisiert --- .../system/{watchdog.service => watchdog-monitor.service} | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) rename etc/systemd/system/{watchdog.service => watchdog-monitor.service} (57%) diff --git a/etc/systemd/system/watchdog.service b/etc/systemd/system/watchdog-monitor.service similarity index 57% rename from etc/systemd/system/watchdog.service rename to etc/systemd/system/watchdog-monitor.service index 65f2427..aa0b0a1 100644 --- a/etc/systemd/system/watchdog.service +++ b/etc/systemd/system/watchdog-monitor.service @@ -1,14 +1,11 @@ [Unit] Description=Watchdog Monitor Service -#After=network.target getty@tty1.service +After=network.target [Service] -ExecStartPre=-/usr/bin/sleep 10 Type=simple User=loginuser -ExecStart=/usr/bin/custom/watchdog -StandardOutput=append:/var/log/watchdog.log -StandardError=append:/var/log/watchdog.log +ExecStart=/usr/bin/custom/watchdog-monitor [Install] WantedBy=multi-user.target From b58147b391c86808bf84da530c351602ac0db9ee Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:01:11 +0100 Subject: [PATCH 41/89] etc/systemd/system/chromium-monitor.service aktualisiert --- etc/systemd/system/chromium-monitor.service | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/etc/systemd/system/chromium-monitor.service b/etc/systemd/system/chromium-monitor.service index 6e14f4a..8faa16e 100644 --- a/etc/systemd/system/chromium-monitor.service +++ b/etc/systemd/system/chromium-monitor.service @@ -1,14 +1,11 @@ [Unit] Description=A Service to monitor the Kiosk's current site -#After=network.target getty@tty1.service +After=network.target [Service] -ExecStartPre=-/usr/bin/sleep 10 Type=simple User=loginuser ExecStart=/usr/bin/custom/chromium-monitor -StandardOutput=append:/var/log/chromium-monitor.log -StandardError=append:/var/log/chromium-monitor.log [Install] WantedBy=multi-user.target From 068d6ac9a581a2d7a337d32d90914f3869cd5e8d Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:04:08 +0100 Subject: [PATCH 42/89] install.sh aktualisiert --- install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 4641417..3e719fa 100644 --- a/install.sh +++ b/install.sh @@ -47,7 +47,7 @@ declare -A files=( ["./rps-client/boot/firmware/ro-root.sh"]="/boot/firmware/ro-root.sh" ["./rps-client/etc/dhcp/dhclient.conf"]="/etc/dhcp/dhclient.conf" ["./rps-client/etc/systemd/system/hostname.service"]="/etc/systemd/system/hostname.service" - ["./rps-client/etc/systemd/system/watchdog.service"]="/etc/systemd/system/watchdog.service" + ["./rps-client/etc/systemd/system/watchdog-monitor.service"]="/etc/systemd/system/watchdog-monitor.service" ["./rps-client/etc/systemd/system/chromium-monitor.service"]="/etc/systemd/system/chromium-monitor.service" ["./rps-client/etc/systemd/system/getty@tty1.service.d/override.conf"]="/etc/systemd/system/getty@tty1.service.d/override.conf" ["./rps-client/etc/chromium/policies/managed/disable_password_saving.json"]="/etc/chromium/policies/managed/disable_password_saving.json" @@ -58,7 +58,7 @@ declare -A files=( ["./rps-client/root/.vnc/config.d/vncserver-x11"]="/root/.vnc/config.d/vncserver-x11" ["./rps-client/usr/bin/custom/hostname"]="/usr/bin/custom/hostname" ["./rps-client/usr/bin/custom/chromium-monitor"]="/usr/bin/custom/chromium-monitor" - ["./rps-client/usr/bin/custom/watchdog"]="/usr/bin/custom/watchdog" + ["./rps-client/usr/bin/custom/watchdog-monitor"]="/usr/bin/custom/watchdog-monitor" ) # Rsync options @@ -80,7 +80,7 @@ sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && pri echo -e "${RED}→${NC} Creating log files..." sudo touch /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Log files created" sudo chown loginuser:loginuser /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Ownership set for log files" -sudo chmod 775 /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Permissions set for log files" +sudo chmod 777 /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Permissions set for log files" sudo chmod +x /usr/bin/custom/* >>/var/log/install 2>&1 && print_status "Permissions set for script files" echo -e "${RED}→${NC} Enabling services..." From 11451b03be3039f1959cce4f60ded527f347a165 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:04:32 +0100 Subject: [PATCH 43/89] etc/systemd/system/watchdog-monitor.service aktualisiert --- etc/systemd/system/watchdog-monitor.service | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/systemd/system/watchdog-monitor.service b/etc/systemd/system/watchdog-monitor.service index aa0b0a1..4f95c51 100644 --- a/etc/systemd/system/watchdog-monitor.service +++ b/etc/systemd/system/watchdog-monitor.service @@ -4,7 +4,6 @@ After=network.target [Service] Type=simple -User=loginuser ExecStart=/usr/bin/custom/watchdog-monitor [Install] From d754b932503aadc9c2f9aff8142a56ee8c8b119b Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:19:44 +0100 Subject: [PATCH 44/89] install.sh aktualisiert --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 3e719fa..f04b0fe 100644 --- a/install.sh +++ b/install.sh @@ -30,7 +30,7 @@ echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart watchdog, /usr/bin/systemctl status watchdog, /usr/bin/systemctl restart chromium-monitor, /usr/bin/systemctl status chromium-monitor loginuser ALL=(ALL) NOPASSWD: /usr/bin/echo, /usr/bin/cp, /usr/bin/sed -loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset +loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset, /usr/bin/sed loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* EOF sudo usermod -aG video loginuser >>/var/log/install 2>&1 && print_status "Permissions for 'loginuser' set" From fc1f25477d8b0f061f93b52427dd11b8292629e9 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:22:05 +0100 Subject: [PATCH 45/89] install.sh aktualisiert --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index f04b0fe..b7a1ba0 100644 --- a/install.sh +++ b/install.sh @@ -29,8 +29,9 @@ sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart watchdog, /usr/bin/systemctl status watchdog, /usr/bin/systemctl restart chromium-monitor, /usr/bin/systemctl status chromium-monitor -loginuser ALL=(ALL) NOPASSWD: /usr/bin/echo, /usr/bin/cp, /usr/bin/sed -loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset, /usr/bin/sed +loginuser ALL=(ALL) NOPASSWD: /usr/bin/echo, /usr/bin/cp +loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed /etc/watchdog.conf +loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* EOF sudo usermod -aG video loginuser >>/var/log/install 2>&1 && print_status "Permissions for 'loginuser' set" From 259e0d7f3aaef990e4d8bce0313f1371dae4228d Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:26:53 +0100 Subject: [PATCH 46/89] install.sh aktualisiert --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index b7a1ba0..20f40e5 100644 --- a/install.sh +++ b/install.sh @@ -31,6 +31,7 @@ sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart watchdog, /usr/bin/systemctl status watchdog, /usr/bin/systemctl restart chromium-monitor, /usr/bin/systemctl status chromium-monitor loginuser ALL=(ALL) NOPASSWD: /usr/bin/echo, /usr/bin/cp loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed /etc/watchdog.conf +loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee -a /etc/watchdog.conf loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* EOF From af0b0c7bb14e5a1cce2a11d34bb5549e1108c5b0 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:29:33 +0100 Subject: [PATCH 47/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index dc1cc90..54361e9 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -30,6 +30,7 @@ update_watchdog_config() { if [ ${#ip_array[@]} -eq 0 ]; then echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" + return 0 # Indicate that no IP addresses were found else for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null @@ -45,8 +46,6 @@ update_watchdog_config() { return 1 # Indicate that IP addresses were found fi - - return 0 # Indicate that no IP addresses were found } # Main loop @@ -56,6 +55,8 @@ interval=30 # Initial interval of 30 seconds while true; do if update_watchdog_config; then + echo "No IP addresses found. Waiting for $interval seconds before checking again..." >> "$log_file" + else echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file" break # Exit the loop if IP addresses were found fi From c5ed7dde10d6c5d51e9909bb413ca4c426725658 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:37:17 +0100 Subject: [PATCH 48/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index 54361e9..fdee08f 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -26,7 +26,7 @@ update_watchdog_config() { sudo sed -i '/^interval/d' "$config_file" # Set interval - echo "interval = 60" | sudo tee -a "$config_file" > /dev/null + echo "interval = 59" | sudo tee -a "$config_file" > /dev/null if [ ${#ip_array[@]} -eq 0 ]; then echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" From 2a1dac448aabb81b665c636ac04b1445e3eb94a1 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:47:12 +0100 Subject: [PATCH 49/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index fdee08f..dc6c0a4 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -28,9 +28,9 @@ update_watchdog_config() { # Set interval echo "interval = 59" | sudo tee -a "$config_file" > /dev/null + if [ ${#ip_array[@]} -eq 0 ]; then echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" - return 0 # Indicate that no IP addresses were found else for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null From 39ee07fe1403b9838994eff4f702204dfe4b935b Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:48:27 +0100 Subject: [PATCH 50/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index dc6c0a4..1d9ef72 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -28,7 +28,6 @@ update_watchdog_config() { # Set interval echo "interval = 59" | sudo tee -a "$config_file" > /dev/null - if [ ${#ip_array[@]} -eq 0 ]; then echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" else @@ -46,6 +45,8 @@ update_watchdog_config() { return 1 # Indicate that IP addresses were found fi + + return 0 # Indicate that no IP addresses were found } # Main loop @@ -54,7 +55,7 @@ end_time=$((start_time + 300)) # 5 minutes in seconds interval=30 # Initial interval of 30 seconds while true; do - if update_watchdog_config; then + if ! update_watchdog_config; then echo "No IP addresses found. Waiting for $interval seconds before checking again..." >> "$log_file" else echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file" From 63a40835b6d9099d1b407a2c5c79075614299861 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:58:33 +0100 Subject: [PATCH 51/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index 1d9ef72..43eb4ce 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -11,8 +11,9 @@ update_watchdog_config() { # Extract watchdog IP addresses watchdog=$(sudo cat /var/lib/dhcp/* | grep -a "option watchdog" | tail -1 | \ awk '{for (i=3; i<=NF; i++) printf "%s ", $i}' | tr -d '";') - - IFS=' ' read -r -a ip_array <<< "$watchdog" + + # Split the watchdog IPs into an array + IFS=',' read -r -a ip_array <<< "$watchdog" # Backup current configuration if sudo cp "$config_file" "$config_file.bak"; then @@ -28,27 +29,27 @@ update_watchdog_config() { # Set interval echo "interval = 59" | sudo tee -a "$config_file" > /dev/null - if [ ${#ip_array[@]} -eq 0 ]; then - echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" - else + # Check if IP addresses are found and add them to the config + if [ ${#ip_array[@]} -gt 0 ]; then for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null + echo "Configured watchdog to ping: $ip" >> "$log_file" done - echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file" - + # Restart watchdog service since IP addresses were found if sudo systemctl restart watchdog; then echo "Watchdog service restarted successfully." >> "$log_file" else echo "Failed to restart watchdog service." >> "$log_file" fi - return 1 # Indicate that IP addresses were found fi + echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" return 0 # Indicate that no IP addresses were found } + # Main loop start_time=$(date +%s) end_time=$((start_time + 300)) # 5 minutes in seconds From 7b46dc4e73f3cc294fa65427fa45c7dee77646d8 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 19:59:31 +0100 Subject: [PATCH 52/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index 43eb4ce..7ffedf3 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -27,7 +27,7 @@ update_watchdog_config() { sudo sed -i '/^interval/d' "$config_file" # Set interval - echo "interval = 59" | sudo tee -a "$config_file" > /dev/null + echo "interval = 58" | sudo tee -a "$config_file" > /dev/null # Check if IP addresses are found and add them to the config if [ ${#ip_array[@]} -gt 0 ]; then From a20d85f54306fb3f4d676f64c72ff73ec226646c Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 20:05:13 +0100 Subject: [PATCH 53/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index 7ffedf3..91b2335 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -56,11 +56,12 @@ end_time=$((start_time + 300)) # 5 minutes in seconds interval=30 # Initial interval of 30 seconds while true; do - if ! update_watchdog_config; then - echo "No IP addresses found. Waiting for $interval seconds before checking again..." >> "$log_file" - else + # Check if IP addresses are found and watchdog is updated + if update_watchdog_config; then echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file" break # Exit the loop if IP addresses were found + else + echo "No IP addresses found. Waiting for $interval seconds before checking again..." >> "$log_file" fi current_time=$(date +%s) @@ -76,5 +77,5 @@ while true; do sleep $interval done -# Version 1.4: +# Version 1.5: # Created 2024 by Tim Eertmoed @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom PXE init script. From 859759a253e0b8643c92cc77fe3f6f1cb4b11e29 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 20:10:09 +0100 Subject: [PATCH 54/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 50 +++++++++++---------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index 91b2335..801ae21 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -11,16 +11,11 @@ update_watchdog_config() { # Extract watchdog IP addresses watchdog=$(sudo cat /var/lib/dhcp/* | grep -a "option watchdog" | tail -1 | \ awk '{for (i=3; i<=NF; i++) printf "%s ", $i}' | tr -d '";') - - # Split the watchdog IPs into an array - IFS=',' read -r -a ip_array <<< "$watchdog" + + IFS=', ' read -r -a ip_array <<< "$watchdog" # Split IPs by comma or space # Backup current configuration - if sudo cp "$config_file" "$config_file.bak"; then - echo "Backup of $config_file created successfully." >> "$log_file" - else - echo "Failed to create backup of $config_file." >> "$log_file" - fi + sudo cp "$config_file" "$config_file.bak" # Clean existing configurations sudo sed -i '/ping/d' "$config_file" @@ -29,48 +24,35 @@ update_watchdog_config() { # Set interval echo "interval = 58" | sudo tee -a "$config_file" > /dev/null - # Check if IP addresses are found and add them to the config - if [ ${#ip_array[@]} -gt 0 ]; then + if [ ${#ip_array[@]} -eq 0 ]; then + echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" + return 0 # No IP addresses to configure + else + # Insert IPs into config for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null - echo "Configured watchdog to ping: $ip" >> "$log_file" done + echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file" - # Restart watchdog service since IP addresses were found - if sudo systemctl restart watchdog; then - echo "Watchdog service restarted successfully." >> "$log_file" - else - echo "Failed to restart watchdog service." >> "$log_file" - fi - return 1 # Indicate that IP addresses were found + # Restart watchdog service + sudo systemctl restart watchdog + return 1 # IP addresses were configured fi - - echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" - return 0 # Indicate that no IP addresses were found } - -# Main loop -start_time=$(date +%s) -end_time=$((start_time + 300)) # 5 minutes in seconds -interval=30 # Initial interval of 30 seconds - while true; do - # Check if IP addresses are found and watchdog is updated if update_watchdog_config; then echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file" - break # Exit the loop if IP addresses were found + break else echo "No IP addresses found. Waiting for $interval seconds before checking again..." >> "$log_file" fi - current_time=$(date +%s) - - # Check if 5 minutes have passed - if [ "$current_time" -ge "$end_time" ]; then + # Check time limit + if [ "$(date +%s)" -ge "$end_time" ]; then echo "5 minutes have passed. Stopping the watchdog service." >> "$log_file" sudo systemctl stop watchdog - break # Exit the loop + break fi echo "Waiting for $interval seconds before checking for IP addresses again..." >> "$log_file" From b2d2a89ca317c5f3835954eceb7b52380575b335 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 20:18:11 +0100 Subject: [PATCH 55/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index 801ae21..2ee136d 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -26,7 +26,7 @@ update_watchdog_config() { if [ ${#ip_array[@]} -eq 0 ]; then echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" - return 0 # No IP addresses to configure + return 1 # No IP addresses to configure, return 1 to continue loop else # Insert IPs into config for ip in "${ip_array[@]}"; do @@ -35,26 +35,37 @@ update_watchdog_config() { echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file" # Restart watchdog service - sudo systemctl restart watchdog - return 1 # IP addresses were configured + if sudo systemctl restart watchdog; then + echo "Watchdog service restarted successfully." >> "$log_file" + return 0 # Successful restart, exit function with 0 to break main loop + else + echo "Failed to restart watchdog service." >> "$log_file" + return 1 # Failed restart, continue main loop + fi fi } +# Loop parameters +interval=30 # Interval to wait between checks +start_time=$(date +%s) +end_time=$((start_time + 300)) # 5 minutes in seconds + +# Main loop while true; do - if update_watchdog_config; then + if ! update_watchdog_config; then echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file" break else - echo "No IP addresses found. Waiting for $interval seconds before checking again..." >> "$log_file" + echo "No IP addresses found or restart failed. Waiting for $interval seconds before checking again..." >> "$log_file" fi - # Check time limit + # Check if 5 minutes have passed if [ "$(date +%s)" -ge "$end_time" ]; then echo "5 minutes have passed. Stopping the watchdog service." >> "$log_file" sudo systemctl stop watchdog break fi - + echo "Waiting for $interval seconds before checking for IP addresses again..." >> "$log_file" sleep $interval done From 5f2cd53026a482c5d1e5616295c3bc5403becd26 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 28 Oct 2024 20:21:20 +0100 Subject: [PATCH 56/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index 2ee136d..d6b6535 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -6,6 +6,11 @@ log_file="/var/log/watchdog.log" # Configuration file config_file="/etc/watchdog.conf" +# Function to log messages with timestamp +log() { + echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$log_file" +} + # Function to update watchdog configuration update_watchdog_config() { # Extract watchdog IP addresses @@ -16,6 +21,7 @@ update_watchdog_config() { # Backup current configuration sudo cp "$config_file" "$config_file.bak" + log "Backup of $config_file created successfully." # Clean existing configurations sudo sed -i '/ping/d' "$config_file" @@ -25,22 +31,22 @@ update_watchdog_config() { echo "interval = 58" | sudo tee -a "$config_file" > /dev/null if [ ${#ip_array[@]} -eq 0 ]; then - echo "No IP addresses found. Watchdog configuration cleared." >> "$log_file" - return 1 # No IP addresses to configure, return 1 to continue loop + log "No IP addresses found. Watchdog configuration cleared." + return 1 # No IP addresses to configure else # Insert IPs into config for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null done - echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file" + log "Configured watchdog to ping: ${ip_array[*]}" # Restart watchdog service if sudo systemctl restart watchdog; then - echo "Watchdog service restarted successfully." >> "$log_file" - return 0 # Successful restart, exit function with 0 to break main loop + log "Watchdog service restarted successfully." + return 0 # Successful restart else - echo "Failed to restart watchdog service." >> "$log_file" - return 1 # Failed restart, continue main loop + log "Failed to restart watchdog service." + return 1 # Failed restart fi fi } @@ -53,20 +59,20 @@ end_time=$((start_time + 300)) # 5 minutes in seconds # Main loop while true; do if ! update_watchdog_config; then - echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file" + log "IP addresses found and watchdog restarted. Exiting loop." break else - echo "No IP addresses found or restart failed. Waiting for $interval seconds before checking again..." >> "$log_file" + log "No IP addresses found or restart failed. Waiting for $interval seconds before checking again..." fi # Check if 5 minutes have passed if [ "$(date +%s)" -ge "$end_time" ]; then - echo "5 minutes have passed. Stopping the watchdog service." >> "$log_file" + log "5 minutes have passed. Stopping the watchdog service." sudo systemctl stop watchdog break fi - echo "Waiting for $interval seconds before checking for IP addresses again..." >> "$log_file" + log "Waiting for $interval seconds before checking for IP addresses again..." sleep $interval done From 0378024409747950f90a177f650cb4d2e39c77c9 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 13:22:34 +0100 Subject: [PATCH 57/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index d6b6535..a7e9d63 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -23,18 +23,21 @@ update_watchdog_config() { sudo cp "$config_file" "$config_file.bak" log "Backup of $config_file created successfully." - # Clean existing configurations - sudo sed -i '/ping/d' "$config_file" - sudo sed -i '/^interval/d' "$config_file" - - # Set interval - echo "interval = 58" | sudo tee -a "$config_file" > /dev/null + # Write static configuration to file + { + echo "realtime = yes" + echo "priority = 1" + echo "interface = eth0" + echo "interval = 58" + echo "ping-count = 1" + } | sudo tee "$config_file" > /dev/null + log "Static configuration written to $config_file." if [ ${#ip_array[@]} -eq 0 ]; then log "No IP addresses found. Watchdog configuration cleared." return 1 # No IP addresses to configure else - # Insert IPs into config + # Append IPs to config for ip in "${ip_array[@]}"; do echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null done @@ -43,6 +46,14 @@ update_watchdog_config() { # Restart watchdog service if sudo systemctl restart watchdog; then log "Watchdog service restarted successfully." + + # Stop watchdog-monitor service + if sudo systemctl stop watchdog-monitor; then + log "watchdog-monitor service stopped successfully." + else + log "Failed to stop watchdog-monitor service." + fi + return 0 # Successful restart else log "Failed to restart watchdog service." From 514cc91ed5b0869cb99853832225e99d07721daf Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 13:41:05 +0100 Subject: [PATCH 58/89] usr/bin/custom/watchdog-monitor aktualisiert --- usr/bin/custom/watchdog-monitor | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/usr/bin/custom/watchdog-monitor b/usr/bin/custom/watchdog-monitor index a7e9d63..3797fe1 100644 --- a/usr/bin/custom/watchdog-monitor +++ b/usr/bin/custom/watchdog-monitor @@ -43,22 +43,30 @@ update_watchdog_config() { done log "Configured watchdog to ping: ${ip_array[*]}" - # Restart watchdog service - if sudo systemctl restart watchdog; then - log "Watchdog service restarted successfully." + # Attempt to restart watchdog service + if ! sudo systemctl restart watchdog; then + log "Failed to restart watchdog service. Attempting to stop and start." - # Stop watchdog-monitor service - if sudo systemctl stop watchdog-monitor; then - log "watchdog-monitor service stopped successfully." + # Fallback: stop then start the service + sudo systemctl stop watchdog + if sudo systemctl start watchdog; then + log "Watchdog service started successfully after stop." else - log "Failed to stop watchdog-monitor service." + log "Failed to start watchdog service after stop." + return 1 fi - - return 0 # Successful restart else - log "Failed to restart watchdog service." - return 1 # Failed restart + log "Watchdog service restarted successfully." fi + + # Stop watchdog-monitor service if restart/start was successful + if sudo systemctl stop watchdog-monitor; then + log "watchdog-monitor service stopped successfully." + else + log "Failed to stop watchdog-monitor service." + fi + + return 0 # Successful restart/start fi } From 6f1498f42290900910ec2781258ed8ea7152cd21 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 13:41:46 +0100 Subject: [PATCH 59/89] install.sh aktualisiert --- install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 20f40e5..d5199f9 100644 --- a/install.sh +++ b/install.sh @@ -28,12 +28,16 @@ sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' -loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart watchdog, /usr/bin/systemctl status watchdog, /usr/bin/systemctl restart chromium-monitor, /usr/bin/systemctl status chromium-monitor +loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status watchdog, /usr/bin/systemctl start watchdog, /usr/bin/systemctl stop watchdog, /usr/bin/systemctl restart watchdog +loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status watchdog-monitor, /usr/bin/systemctl start watchdog-monitor, /usr/bin/systemctl stop watchdog-monitor, /usr/bin/systemctl restart watchdog-monitor +loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status chromium-monitor, /usr/bin/systemctl start chromium-monitor, /usr/bin/systemctl stop chromium-monitor, /usr/bin/systemctl restart chromium-monitor loginuser ALL=(ALL) NOPASSWD: /usr/bin/echo, /usr/bin/cp -loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed /etc/watchdog.conf -loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee -a /etc/watchdog.conf +loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed +loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* +loginuser ALL=(ALL) NOPASSWD: /usr/bin/custom/watchdog-monitor +loginuser ALL=(ALL) NOPASSWD: /usr/bin/custom/chromium-monitor EOF sudo usermod -aG video loginuser >>/var/log/install 2>&1 && print_status "Permissions for 'loginuser' set" From 777d3981f06f9202e5c09d07725764d7b30bb8bd Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 13:52:37 +0100 Subject: [PATCH 60/89] install.sh aktualisiert --- install.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index d5199f9..5fc5efa 100644 --- a/install.sh +++ b/install.sh @@ -31,13 +31,12 @@ sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status watchdog, /usr/bin/systemctl start watchdog, /usr/bin/systemctl stop watchdog, /usr/bin/systemctl restart watchdog loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status watchdog-monitor, /usr/bin/systemctl start watchdog-monitor, /usr/bin/systemctl stop watchdog-monitor, /usr/bin/systemctl restart watchdog-monitor loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status chromium-monitor, /usr/bin/systemctl start chromium-monitor, /usr/bin/systemctl stop chromium-monitor, /usr/bin/systemctl restart chromium-monitor -loginuser ALL=(ALL) NOPASSWD: /usr/bin/echo, /usr/bin/cp -loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed -loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee -loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* -loginuser ALL=(ALL) NOPASSWD: /usr/bin/custom/watchdog-monitor -loginuser ALL=(ALL) NOPASSWD: /usr/bin/custom/chromium-monitor +loginuser ALL=(ALL) NOPASSWD: /usr/bin/cp /etc/watchdog.conf /etc/watchdog.conf.bak +loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee /etc/watchdog.conf, /usr/bin/tee -a /etc/watchdog.conf +loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed -i * /etc/hosts +loginuser ALL=(ALL) NOPASSWD: /usr/bin/hostnamectl set-hostname +loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset EOF sudo usermod -aG video loginuser >>/var/log/install 2>&1 && print_status "Permissions for 'loginuser' set" From b239b564f165d4909a8662a906d4e71942ad1dcd Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 14:13:57 +0100 Subject: [PATCH 61/89] install.sh aktualisiert --- install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 5fc5efa..983a6f7 100644 --- a/install.sh +++ b/install.sh @@ -34,9 +34,11 @@ loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status chromium-monitor, /usr/b loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* loginuser ALL=(ALL) NOPASSWD: /usr/bin/cp /etc/watchdog.conf /etc/watchdog.conf.bak loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee /etc/watchdog.conf, /usr/bin/tee -a /etc/watchdog.conf -loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed -i * /etc/hosts +loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed -i * /etc/hosts, /usr/bin/sed -r +loginuser ALL=(ALL) NOPASSWD: /usr/bin/fbset -s loginuser ALL=(ALL) NOPASSWD: /usr/bin/hostnamectl set-hostname -loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset +loginuser ALL=(ALL) NOPASSWD: /usr/sbin/dhclient eth0 +loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot EOF sudo usermod -aG video loginuser >>/var/log/install 2>&1 && print_status "Permissions for 'loginuser' set" From 3e711f04feeb838a6141477366b966bdf9282acd Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 14:24:31 +0100 Subject: [PATCH 62/89] install.sh aktualisiert --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 983a6f7..a89c9f8 100644 --- a/install.sh +++ b/install.sh @@ -34,7 +34,8 @@ loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status chromium-monitor, /usr/b loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* loginuser ALL=(ALL) NOPASSWD: /usr/bin/cp /etc/watchdog.conf /etc/watchdog.conf.bak loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee /etc/watchdog.conf, /usr/bin/tee -a /etc/watchdog.conf -loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed -i * /etc/hosts, /usr/bin/sed -r +loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed -i +loginuser ALL=(ALL) NOPASSWD: /usr/bin/sed -r 's/[x]+/,/g' loginuser ALL=(ALL) NOPASSWD: /usr/bin/fbset -s loginuser ALL=(ALL) NOPASSWD: /usr/bin/hostnamectl set-hostname loginuser ALL=(ALL) NOPASSWD: /usr/sbin/dhclient eth0 From ce9bafa0694f598cf2cdc38ce4329ea2a643c7ec Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 14:32:20 +0100 Subject: [PATCH 63/89] install.sh aktualisiert --- install.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index a89c9f8..7e17b3f 100644 --- a/install.sh +++ b/install.sh @@ -28,9 +28,8 @@ sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' -loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status watchdog, /usr/bin/systemctl start watchdog, /usr/bin/systemctl stop watchdog, /usr/bin/systemctl restart watchdog -loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status watchdog-monitor, /usr/bin/systemctl start watchdog-monitor, /usr/bin/systemctl stop watchdog-monitor, /usr/bin/systemctl restart watchdog-monitor -loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl status chromium-monitor, /usr/bin/systemctl start chromium-monitor, /usr/bin/systemctl stop chromium-monitor, /usr/bin/systemctl restart chromium-monitor +loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl start watchdog, /usr/bin/systemctl stop watchdog, /usr/bin/systemctl restart watchdog +loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop watchdog-monitor loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* loginuser ALL=(ALL) NOPASSWD: /usr/bin/cp /etc/watchdog.conf /etc/watchdog.conf.bak loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee /etc/watchdog.conf, /usr/bin/tee -a /etc/watchdog.conf @@ -86,9 +85,9 @@ echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" echo -e "${RED}→${NC} Creating log files..." -sudo touch /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Log files created" -sudo chown loginuser:loginuser /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Ownership set for log files" -sudo chmod 777 /var/log/watchdog.log /var/log/chromium-monitor.log >>/var/log/install 2>&1 && print_status "Permissions set for log files" +sudo touch /var/log/watchdog.log /var/log/chromium-monitor.log /var/log/hostname.log >>/var/log/install 2>&1 && print_status "Log files created" +sudo chown loginuser:loginuser /var/log/watchdog.log /var/log/chromium-monitor.log /var/log/hostname.log >>/var/log/install 2>&1 && print_status "Ownership set for log files" +sudo chmod 777 /var/log/watchdog.log /var/log/chromium-monitor.log /var/log/hostname.log >>/var/log/install 2>&1 && print_status "Permissions set for log files" sudo chmod +x /usr/bin/custom/* >>/var/log/install 2>&1 && print_status "Permissions set for script files" echo -e "${RED}→${NC} Enabling services..." From dcde376e95310d6c41391ffc9dc25b852970bc5d Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 14:51:46 +0100 Subject: [PATCH 64/89] usr/bin/custom/chromium-monitor aktualisiert --- usr/bin/custom/chromium-monitor | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/usr/bin/custom/chromium-monitor b/usr/bin/custom/chromium-monitor index 57ab03f..739caad 100644 --- a/usr/bin/custom/chromium-monitor +++ b/usr/bin/custom/chromium-monitor @@ -2,6 +2,11 @@ LOGFILE="/var/log/chromium-monitor.log" +# Function to log messages with timestamps +log() { + echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOGFILE" +} + # Function to get the monitor value from DHCP get_monitor() { sudo cat /var/lib/dhcp/* | grep -a "option monitor" | tail -1 | \ @@ -11,7 +16,7 @@ get_monitor() { # Function to get the current window name get_current_window() { - DISPLAY=:0 xdotool getwindowfocus getwindowname | awk -F '- Chromium' '{print $1}' + DISPLAY=:0 xdotool getwindowfocus getwindowname } # Initialize monitor variable @@ -19,20 +24,20 @@ monitor="" while [ -z "$monitor" ]; do monitor=$(get_monitor) if [ -n "$monitor" ]; then - echo "Initial monitor detected: $monitor" >> $LOGFILE # Log initial monitor + log "Initial monitor detected: $monitor" # Log initial monitor fi sleep 5 done # Main loop to continuously check the current window while true; do - new_current=$(get_current_window | awk '{print $1}') # Get the first word of the current window + current_window=$(get_current_window) # Get the current window name - if [ -n "$new_current" ]; then - # Check for mismatch - if [ "$new_current" != "$monitor" ]; then - echo "Mismatch detected! Monitor: $monitor, Current: $new_current" >> $LOGFILE - echo "Rebooting now." >> $LOGFILE + if [ -n "$current_window" ]; then + # Check for mismatch using case-insensitive comparison + if ! echo "$current_window" | grep -iq "$monitor"; then + log "Mismatch detected! Monitor: $monitor, Current: $current_window" + log "Rebooting now." sudo reboot exit 1 fi From 6341d49f76f044e432d5e66543ef81ac9d743409 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 14:52:32 +0100 Subject: [PATCH 65/89] usr/bin/custom/hostname aktualisiert --- usr/bin/custom/hostname | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/usr/bin/custom/hostname b/usr/bin/custom/hostname index fec09f9..85efd0c 100644 --- a/usr/bin/custom/hostname +++ b/usr/bin/custom/hostname @@ -2,6 +2,11 @@ LOGFILE="/var/log/hostname.log" +# Function to log messages with timestamps +log() { + echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOGFILE" +} + # Function to read the hostname from the DHCP lease file get_hostname() { sudo cat /var/lib/dhcp/* | grep -a "option host-name" | tail -1 | \ @@ -13,7 +18,7 @@ update_hosts() { local hostname="$1" # Replace the second line with the new hostname sudo sed -i "2s/.*/127.0.1.1 ${hostname}/" /etc/hosts - echo "Updated /etc/hosts with hostname: $hostname" >> $LOGFILE + log "Updated /etc/hosts with hostname: $hostname" } # Read the hostname from DHCP @@ -22,14 +27,14 @@ hostname=$(get_hostname) if [ -n "$hostname" ]; then # Set the hostname using hostnamectl sudo hostnamectl set-hostname "$hostname" - echo "Set hostname to: $hostname" >> $LOGFILE + log "Set hostname to: $hostname" update_hosts "$hostname" else - echo "No hostname found." >> $LOGFILE + log "No hostname found." fi # Log completion -echo "Hostname update script completed." >> $LOGFILE +log "Hostname update script completed." -# Version 1.0: -# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. +# Version 1.0: +# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspbian as custom PXE init script. From 16cfbefd83074da608913c17aa041732396d78ed Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 14:54:19 +0100 Subject: [PATCH 66/89] install.sh aktualisiert --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 7e17b3f..395a191 100644 --- a/install.sh +++ b/install.sh @@ -21,7 +21,7 @@ sudo apt clean >>/var/log/install 2>&1 && print_status "Clean" echo -e "${RED}→${NC} Installing required packages..." sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit chromium-browser fonts-noto-color-emoji nfs-common watchdog xdotool rsync -y >>/var/log/install 2>&1 && print_status "Required packages installed" -sudo apt install realvnc-vnc-server -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" +#sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" echo -e "${RED}→${NC} Creating user 'loginuser'..." sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" From 620fe0c83118f4ae790bf52e6206554e75797690 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 15:07:22 +0100 Subject: [PATCH 67/89] =?UTF-8?q?root/.vnc/config.d/vncserver-x11=20gel?= =?UTF-8?q?=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- root/.vnc/config.d/vncserver-x11 | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 root/.vnc/config.d/vncserver-x11 diff --git a/root/.vnc/config.d/vncserver-x11 b/root/.vnc/config.d/vncserver-x11 deleted file mode 100644 index ce1b4a3..0000000 --- a/root/.vnc/config.d/vncserver-x11 +++ /dev/null @@ -1,4 +0,0 @@ -Authentication=None - -# Version 1.0: -# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. \ No newline at end of file From e35bbc7d779cec5c46b6f1a65879d85f28da5eb5 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 15:21:54 +0100 Subject: [PATCH 68/89] install.sh aktualisiert --- install.sh | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 395a191..2b60829 100644 --- a/install.sh +++ b/install.sh @@ -17,11 +17,44 @@ sudo apt upgrade -y >>/var/log/install 2>&1 && print_status "System Upgrade" sudo apt dist-upgrade -y >>/var/log/install 2>&1 && print_status "System Dist-Upgrade" sudo apt autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove" sudo apt clean >>/var/log/install 2>&1 && print_status "Clean" - rm -rf /var/lib/apt/lists/* "Clear cache" +rm -rf /var/lib/apt/lists/* "Clear cache" echo -e "${RED}→${NC} Installing required packages..." sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit chromium-browser fonts-noto-color-emoji nfs-common watchdog xdotool rsync -y >>/var/log/install 2>&1 && print_status "Required packages installed" -#sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" +sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" + +echo -e "${RED}→${NC} Configuring VNC..." +sudo systemctl enable vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service enabled" +sudo systemctl start vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service started" +CONFIG_FILE="/root/.vnc/config.d/vncserver-x11" +if [ ! -d "$(dirname "$CONFIG_FILE")" ]; then + mkdir -p "$(dirname "$CONFIG_FILE")" + echo -e "${RED}→${NC} Created directory for VNC config." +fi +read -p "Do you want to set a VNC password? (y/n): " -r +if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then + vncpasswd + echo -e "${GREEN}✔${NC} VNC password has been set." +else + echo -e "${RED}✖${NC} No VNC password will be set." +fi +if [ "$(vncpasswd -o)" = 'none' ]; then + echo "Authentication=None" >> "$CONFIG_FILE" + echo "Geometry=1920x1080" >> "$CONFIG_FILE" + echo "# Version 1.0:" >> "$CONFIG_FILE" + echo "# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspbian as custom PXE init script." >> "$CONFIG_FILE" + echo -e "${RED}→${NC} VNC config set to no authentication with geometry 1920x1080." +else + echo "Authentication=VNC" >> "$CONFIG_FILE" + echo "Geometry=1920x1080" >> "$CONFIG_FILE" + echo "# Version 1.0:" >> "$CONFIG_FILE" + echo "# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspbian as custom PXE init script." >> "$CONFIG_FILE" + echo -e "${RED}→${NC} VNC password is set. Authentication will be required." +fi + +echo -e "${GREEN}✔${NC} VNC configuration updated with geometry 1920x1080." +sudo raspi-config nonint do_vnc 0 >>/var/log/install 2>&1 && print_status "VNC enabled in raspi-config" +echo -e "${GREEN}✔${NC} VNC configuration completed. You can connect using a VNC viewer." echo -e "${RED}→${NC} Creating user 'loginuser'..." sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" @@ -48,7 +81,7 @@ PermitRootLogin no EOF sudo passwd -l root >>/var/log/install 2>&1 && print_status "Root login disabled" -# Array of source and destination pairs +echo -e "${RED}→${NC} Copy requiered files..." declare -A files=( ["./rps-client/boot/ro-root.sh"]="/boot/ro-root.sh" ["./rps-client/boot/firmware/ro-root.sh"]="/boot/firmware/ro-root.sh" @@ -67,19 +100,13 @@ declare -A files=( ["./rps-client/usr/bin/custom/chromium-monitor"]="/usr/bin/custom/chromium-monitor" ["./rps-client/usr/bin/custom/watchdog-monitor"]="/usr/bin/custom/watchdog-monitor" ) - -# Rsync options RSYNC_OPTS="-a --numeric-ids --info=progress2 --no-owner --no-group" - -# Loop through and sync each file for src in "${!files[@]}"; do dst="${files[$src]}" echo "Copying $src to $dst..." sudo rsync $RSYNC_OPTS "$src" "$dst" >>/var/log/install 2>&1 && print_status "$src copied to $dst" done - -# Final status message -print_status "All required files copied" +echo -e "${GREEN}✔${NC} All required files copied" echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" From 04e0b1a3b631546e72012f408a278b0090138340 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 15:32:37 +0100 Subject: [PATCH 69/89] install.sh aktualisiert --- install.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/install.sh b/install.sh index 2b60829..9b27ebf 100644 --- a/install.sh +++ b/install.sh @@ -131,6 +131,20 @@ else echo -e "${RED}→${NC} Skipping unused kernel cleanup." fi +echo -e "${RED}→${NC} Configuring Overlayroot..." +CONFIG_FILE="/etc/overlayroot.conf" +echo 'overlayroot_cfgdisk="disabled"' | sudo tee "$CONFIG_FILE" +echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" +read -p "Do you want to activate overlayfs? (y/n): " -r +if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then + echo 'overlayroot="tmpfs:overlayfs"' | sudo tee -a "$CONFIG_FILE" + sudo raspi-config nonint do_overlayroot 0 >>/var/log/install 2>&1 && print_status "Overlayroot enabled in raspi-config" + echo -e "${GREEN}✔${NC} Overlayroot has been activated." +else + echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" + echo -e "${RED}✖${NC} Overlayroot has not been activated." +fi + echo -e "${RED}→${NC} Cleaning up installer..." sudo rm -rf ./rps-client >>/var/log/install 2>&1 && print_status "Installer cleaned up" From 689824ac04fa3b3632e29b09b24fbd58e9916de0 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 15:41:39 +0100 Subject: [PATCH 70/89] install.sh aktualisiert --- install.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/install.sh b/install.sh index 9b27ebf..cc9f84f 100644 --- a/install.sh +++ b/install.sh @@ -23,6 +23,20 @@ echo -e "${RED}→${NC} Installing required packages..." sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit chromium-browser fonts-noto-color-emoji nfs-common watchdog xdotool rsync -y >>/var/log/install 2>&1 && print_status "Required packages installed" sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" +echo -e "${GREEN}→${NC} Configuring Raspberry Pi settings..." +sudo raspi-config nonint do_camera 0 >> /var/log/install 2>&1 && print_status "Camera disabled" +sudo raspi-config nonint do_vnc 0 >> /var/log/install 2>&1 && print_status "VNC enabled" +sudo raspi-config nonint do_spi 0 >> /var/log/install 2>&1 && print_status "SPI disabled" +sudo raspi-config nonint do_i2c 0 >> /var/log/install 2>&1 && print_status "I2C disabled" +sudo raspi-config nonint do_serial 0 0 >> /var/log/install 2>&1 && print_status "Serial port disabled" +sudo raspi-config nonint do_onewire 0 >> /var/log/install 2>&1 && print_status "1-Wire disabled" +sudo raspi-config nonint do_remote_gpio 0 >> /var/log/install 2>&1 && print_status "Remote GPIO disabled" +sudo raspi-config nonint do_gpu_memory 256 >> /var/log/install 2>&1 && print_status "GPU memory set to 256MB" +sudo raspi-config nonint do_locale "de_DE.UTF-8" "de_DE.UTF-8" >> /var/log/install 2>&1 && print_status "Locale set to de_DE.UTF-8" +sudo raspi-config nonint do_timezone "Europe/Berlin" >> /var/log/install 2>&1 && print_status "Timezone set to Europe/Berlin" +sudo raspi-config nonint do_boot_order 3 >> /var/log/install 2>&1 && print_status "Boot order set to network boot" +echo -e "${GREEN}✔${NC} All raspi-config settings applied successfully." + echo -e "${RED}→${NC} Configuring VNC..." sudo systemctl enable vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service enabled" sudo systemctl start vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service started" From 1720679c1b2c704abcbeec699b650f9e0aef6ea2 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 16:02:39 +0100 Subject: [PATCH 71/89] install.sh aktualisiert --- install.sh | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index cc9f84f..16156df 100644 --- a/install.sh +++ b/install.sh @@ -15,13 +15,13 @@ echo -e "${RED}→${NC} Starting System Update..." sudo apt update >>/var/log/install 2>&1 && print_status "System Update" sudo apt upgrade -y >>/var/log/install 2>&1 && print_status "System Upgrade" sudo apt dist-upgrade -y >>/var/log/install 2>&1 && print_status "System Dist-Upgrade" -sudo apt autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove" -sudo apt clean >>/var/log/install 2>&1 && print_status "Clean" -rm -rf /var/lib/apt/lists/* "Clear cache" echo -e "${RED}→${NC} Installing required packages..." sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit chromium-browser fonts-noto-color-emoji nfs-common watchdog xdotool rsync -y >>/var/log/install 2>&1 && print_status "Required packages installed" sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" +sudo apt autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove" +sudo apt clean >>/var/log/install 2>&1 && print_status "Clean" +rm -rf /var/lib/apt/lists/* >>/var/log/install 2>&1 && print_status "Clear cache" echo -e "${GREEN}→${NC} Configuring Raspberry Pi settings..." sudo raspi-config nonint do_camera 0 >> /var/log/install 2>&1 && print_status "Camera disabled" @@ -35,7 +35,6 @@ sudo raspi-config nonint do_gpu_memory 256 >> /var/log/install 2>&1 && print_sta sudo raspi-config nonint do_locale "de_DE.UTF-8" "de_DE.UTF-8" >> /var/log/install 2>&1 && print_status "Locale set to de_DE.UTF-8" sudo raspi-config nonint do_timezone "Europe/Berlin" >> /var/log/install 2>&1 && print_status "Timezone set to Europe/Berlin" sudo raspi-config nonint do_boot_order 3 >> /var/log/install 2>&1 && print_status "Boot order set to network boot" -echo -e "${GREEN}✔${NC} All raspi-config settings applied successfully." echo -e "${RED}→${NC} Configuring VNC..." sudo systemctl enable vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service enabled" @@ -43,32 +42,29 @@ sudo systemctl start vncserver-x11-serviced.service >>/var/log/install 2>&1 && p CONFIG_FILE="/root/.vnc/config.d/vncserver-x11" if [ ! -d "$(dirname "$CONFIG_FILE")" ]; then mkdir -p "$(dirname "$CONFIG_FILE")" - echo -e "${RED}→${NC} Created directory for VNC config." + print_status "Created directory for VNC config." >> /var/log/install 2>&1 fi read -p "Do you want to set a VNC password? (y/n): " -r if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then vncpasswd - echo -e "${GREEN}✔${NC} VNC password has been set." + print_status "VNC password has been set." >> /var/log/install 2>&1 else - echo -e "${RED}✖${NC} No VNC password will be set." + echo -e "${RED}✖${NC} No VNC password will be set." >> /var/log/install 2>&1 fi if [ "$(vncpasswd -o)" = 'none' ]; then echo "Authentication=None" >> "$CONFIG_FILE" echo "Geometry=1920x1080" >> "$CONFIG_FILE" echo "# Version 1.0:" >> "$CONFIG_FILE" echo "# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspbian as custom PXE init script." >> "$CONFIG_FILE" - echo -e "${RED}→${NC} VNC config set to no authentication with geometry 1920x1080." + print_status "VNC config set to no authentication with geometry 1920x1080." >> /var/log/install 2>&1 else echo "Authentication=VNC" >> "$CONFIG_FILE" echo "Geometry=1920x1080" >> "$CONFIG_FILE" echo "# Version 1.0:" >> "$CONFIG_FILE" echo "# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspbian as custom PXE init script." >> "$CONFIG_FILE" - echo -e "${RED}→${NC} VNC password is set. Authentication will be required." + print_status "VNC password is set. Authentication will be required." >> /var/log/install 2>&1 fi - -echo -e "${GREEN}✔${NC} VNC configuration updated with geometry 1920x1080." sudo raspi-config nonint do_vnc 0 >>/var/log/install 2>&1 && print_status "VNC enabled in raspi-config" -echo -e "${GREEN}✔${NC} VNC configuration completed. You can connect using a VNC viewer." echo -e "${RED}→${NC} Creating user 'loginuser'..." sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" @@ -120,7 +116,7 @@ for src in "${!files[@]}"; do echo "Copying $src to $dst..." sudo rsync $RSYNC_OPTS "$src" "$dst" >>/var/log/install 2>&1 && print_status "$src copied to $dst" done -echo -e "${GREEN}✔${NC} All required files copied" +print_status "All files have been successfully copied" echo -e "${RED}→${NC} Setting file permissions..." sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" @@ -142,7 +138,8 @@ if [[ "$clean_kernels" =~ ^[Yy](e[Ss]?)?$ ]]; then echo -e "${RED}→${NC} Cleaning up unused kernels..." sudo bash /root/remove_unused_kernel.sh -u -e >>/var/log/install 2>&1 && print_status "Unused kernels cleaned up" else - echo -e "${RED}→${NC} Skipping unused kernel cleanup." + echo -e "${RED}→${NC} Skipping unused kernel cleanup..." + print_status "Cleanup has been skipped" >> /var/log/install 2>&1 fi echo -e "${RED}→${NC} Configuring Overlayroot..." @@ -153,16 +150,16 @@ read -p "Do you want to activate overlayfs? (y/n): " -r if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then echo 'overlayroot="tmpfs:overlayfs"' | sudo tee -a "$CONFIG_FILE" sudo raspi-config nonint do_overlayroot 0 >>/var/log/install 2>&1 && print_status "Overlayroot enabled in raspi-config" - echo -e "${GREEN}✔${NC} Overlayroot has been activated." + print_status "Overlayroot has been activated." >> /var/log/install 2>&1 else echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" - echo -e "${RED}✖${NC} Overlayroot has not been activated." + echo -e "${RED}✖${NC} Overlayroot has not been activated." >> /var/log/install 2>&1 fi echo -e "${RED}→${NC} Cleaning up installer..." sudo rm -rf ./rps-client >>/var/log/install 2>&1 && print_status "Installer cleaned up" -echo -e "${GREEN}✔${NC} Installation complete. Press any key to reboot..." +echo -e "${GREEN}✔${NC} Installation complete. Press any key to reboot..." >> /var/log/install 2>&1 read -n 1 -s sudo reboot From 488b0a6406e391edf542db681e780b7d73a0776a Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 20:37:08 +0100 Subject: [PATCH 72/89] home/loginuser/.xinitrc aktualisiert --- home/loginuser/.xinitrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home/loginuser/.xinitrc b/home/loginuser/.xinitrc index 19206a5..5b15742 100644 --- a/home/loginuser/.xinitrc +++ b/home/loginuser/.xinitrc @@ -14,7 +14,8 @@ then xset s noblank xset s off else - xset s $SCREEN + xset +dpms + xset dmps $SCREEN 0 0 fi #NO-Var fallback site From a5cd4e6f2ca13a63febd4c333eb19f1caea99da3 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 20:49:14 +0100 Subject: [PATCH 73/89] home/loginuser/.xinitrc aktualisiert --- home/loginuser/.xinitrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/home/loginuser/.xinitrc b/home/loginuser/.xinitrc index 5b15742..e2f8198 100644 --- a/home/loginuser/.xinitrc +++ b/home/loginuser/.xinitrc @@ -15,7 +15,9 @@ then xset s off else xset +dpms - xset dmps $SCREEN 0 0 + xset dmps $SCREEN $SCREEN $SCREEN + xset s blank + xset s $SCREEN fi #NO-Var fallback site From 1510ce0758b1139833b995700000aab81d677166 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 20:55:43 +0100 Subject: [PATCH 74/89] home/loginuser/.xinitrc aktualisiert --- home/loginuser/.xinitrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/loginuser/.xinitrc b/home/loginuser/.xinitrc index e2f8198..4205bd6 100644 --- a/home/loginuser/.xinitrc +++ b/home/loginuser/.xinitrc @@ -15,7 +15,7 @@ then xset s off else xset +dpms - xset dmps $SCREEN $SCREEN $SCREEN + xset dmps 0 0 $SCREEN xset s blank xset s $SCREEN fi From 43b9640eb0579a7926c85a81604b9cc4ba9cbf37 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 20:57:22 +0100 Subject: [PATCH 75/89] home/loginuser/.xinitrc aktualisiert --- home/loginuser/.xinitrc | 1 - 1 file changed, 1 deletion(-) diff --git a/home/loginuser/.xinitrc b/home/loginuser/.xinitrc index 4205bd6..8ba29a8 100644 --- a/home/loginuser/.xinitrc +++ b/home/loginuser/.xinitrc @@ -17,7 +17,6 @@ else xset +dpms xset dmps 0 0 $SCREEN xset s blank - xset s $SCREEN fi #NO-Var fallback site From c7a77796a1b156ac4a5b3bd49c8b233415c35612 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 20:59:57 +0100 Subject: [PATCH 76/89] install.sh aktualisiert --- install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install.sh b/install.sh index 16156df..1ba83cf 100644 --- a/install.sh +++ b/install.sh @@ -163,5 +163,9 @@ echo -e "${GREEN}✔${NC} Installation complete. Press any key to reboot..." >> read -n 1 -s sudo reboot + +echo "performance" | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor +sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target + # Version 1.2: # Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. From 5dc8681dfd5fcefa57ccd80cfd5deea86e8480b2 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Tue, 29 Oct 2024 21:02:35 +0100 Subject: [PATCH 77/89] home/loginuser/.xinitrc aktualisiert --- home/loginuser/.xinitrc | 1 - 1 file changed, 1 deletion(-) diff --git a/home/loginuser/.xinitrc b/home/loginuser/.xinitrc index 8ba29a8..98c3785 100644 --- a/home/loginuser/.xinitrc +++ b/home/loginuser/.xinitrc @@ -16,7 +16,6 @@ then else xset +dpms xset dmps 0 0 $SCREEN - xset s blank fi #NO-Var fallback site From a70a362ce45845e3eb342fc58032a513d978c0ab Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Wed, 30 Oct 2024 09:33:36 +0100 Subject: [PATCH 78/89] install.sh aktualisiert --- install.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index 1ba83cf..a0b2755 100644 --- a/install.sh +++ b/install.sh @@ -93,22 +93,22 @@ sudo passwd -l root >>/var/log/install 2>&1 && print_status "Root login disabled echo -e "${RED}→${NC} Copy requiered files..." declare -A files=( - ["./rps-client/boot/ro-root.sh"]="/boot/ro-root.sh" - ["./rps-client/boot/firmware/ro-root.sh"]="/boot/firmware/ro-root.sh" - ["./rps-client/etc/dhcp/dhclient.conf"]="/etc/dhcp/dhclient.conf" - ["./rps-client/etc/systemd/system/hostname.service"]="/etc/systemd/system/hostname.service" - ["./rps-client/etc/systemd/system/watchdog-monitor.service"]="/etc/systemd/system/watchdog-monitor.service" - ["./rps-client/etc/systemd/system/chromium-monitor.service"]="/etc/systemd/system/chromium-monitor.service" - ["./rps-client/etc/systemd/system/getty@tty1.service.d/override.conf"]="/etc/systemd/system/getty@tty1.service.d/override.conf" - ["./rps-client/etc/chromium/policies/managed/disable_password_saving.json"]="/etc/chromium/policies/managed/disable_password_saving.json" - ["./rps-client/home/loginuser/.bash_profile"]="/home/loginuser/.bash_profile" - ["./rps-client/home/loginuser/.xinitrc"]="/home/loginuser/.xinitrc" - ["./rps-client/home/wis/.ssh/id_rsa.pub"]="/home/wis/.ssh/id_rsa.pub" - ["./rps-client/root/remove_unused_kernel.sh"]="/root/remove_unused_kernel.sh" - ["./rps-client/root/.vnc/config.d/vncserver-x11"]="/root/.vnc/config.d/vncserver-x11" - ["./rps-client/usr/bin/custom/hostname"]="/usr/bin/custom/hostname" - ["./rps-client/usr/bin/custom/chromium-monitor"]="/usr/bin/custom/chromium-monitor" - ["./rps-client/usr/bin/custom/watchdog-monitor"]="/usr/bin/custom/watchdog-monitor" + ["/root/rps-client/boot/ro-root.sh"]="/boot/ro-root.sh" + ["/root/rps-client/boot/firmware/ro-root.sh"]="/boot/firmware/ro-root.sh" + ["/root/rps-client/etc/dhcp/dhclient.conf"]="/etc/dhcp/dhclient.conf" + ["/root/rps-client/etc/systemd/system/hostname.service"]="/etc/systemd/system/hostname.service" + ["/root/rps-client/etc/systemd/system/watchdog-monitor.service"]="/etc/systemd/system/watchdog-monitor.service" + ["/root/rps-client/etc/systemd/system/chromium-monitor.service"]="/etc/systemd/system/chromium-monitor.service" + ["/root/rps-client/etc/systemd/system/getty@tty1.service.d/override.conf"]="/etc/systemd/system/getty@tty1.service.d/override.conf" + ["/root/rps-client/etc/chromium/policies/managed/disable_password_saving.json"]="/etc/chromium/policies/managed/disable_password_saving.json" + ["/root/rps-client/home/loginuser/.bash_profile"]="/home/loginuser/.bash_profile" + ["/root/rps-client/home/loginuser/.xinitrc"]="/home/loginuser/.xinitrc" + ["/root/rps-client/home/wis/.ssh/id_rsa.pub"]="/home/wis/.ssh/id_rsa.pub" + ["/root/rps-client/root/remove_unused_kernel.sh"]="/root/remove_unused_kernel.sh" + ["/root/rps-client/root/.vnc/config.d/vncserver-x11"]="/root/.vnc/config.d/vncserver-x11" + ["/root/rps-client/usr/bin/custom/hostname"]="/usr/bin/custom/hostname" + ["/root/rps-client/usr/bin/custom/chromium-monitor"]="/usr/bin/custom/chromium-monitor" + ["/root/rps-client/usr/bin/custom/watchdog-monitor"]="/usr/bin/custom/watchdog-monitor" ) RSYNC_OPTS="-a --numeric-ids --info=progress2 --no-owner --no-group" for src in "${!files[@]}"; do From 9e7f59606cd6eb2443859f398519b49bf70df6a8 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Wed, 30 Oct 2024 09:35:00 +0100 Subject: [PATCH 79/89] README.md aktualisiert --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f319ab9..ba075a7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # RPS-Client ```bash -wget -qO- --header 'Authorization:token 9031f8d227dd83ba601680bf3a9f6c2d26c1a970' https://gitea.int.eertmoed.net/WiS/RPS-Client/archive/latest.tar.gz | tar xvz ; bash ./rps-client/install.sh ; +wget -qO- --header 'Authorization:token 9031f8d227dd83ba601680bf3a9f6c2d26c1a970' https://gitea.int.eertmoed.net/WiS/RPS-Client/archive/latest.tar.gz | tar xvz ; bash /root/rps-client/install.sh ; ``` ```ruby From 5ff6d190c3f0c78e85d0db59aa9edfc11d1b941f Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Wed, 30 Oct 2024 09:58:01 +0100 Subject: [PATCH 80/89] install.sh aktualisiert --- install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index a0b2755..9d2dbb4 100644 --- a/install.sh +++ b/install.sh @@ -65,6 +65,8 @@ else print_status "VNC password is set. Authentication will be required." >> /var/log/install 2>&1 fi sudo raspi-config nonint do_vnc 0 >>/var/log/install 2>&1 && print_status "VNC enabled in raspi-config" +sudo systemctl unmask vncserver-x11-serviced.service +sudo systemctl enable vncserver-x11-serviced.service echo -e "${RED}→${NC} Creating user 'loginuser'..." sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" @@ -92,6 +94,7 @@ EOF sudo passwd -l root >>/var/log/install 2>&1 && print_status "Root login disabled" echo -e "${RED}→${NC} Copy requiered files..." +mkdir -p /etc/chromium/policies/managed /home/wis/.ssh /usr/bin/custom declare -A files=( ["/root/rps-client/boot/ro-root.sh"]="/boot/ro-root.sh" ["/root/rps-client/boot/firmware/ro-root.sh"]="/boot/firmware/ro-root.sh" @@ -105,7 +108,6 @@ declare -A files=( ["/root/rps-client/home/loginuser/.xinitrc"]="/home/loginuser/.xinitrc" ["/root/rps-client/home/wis/.ssh/id_rsa.pub"]="/home/wis/.ssh/id_rsa.pub" ["/root/rps-client/root/remove_unused_kernel.sh"]="/root/remove_unused_kernel.sh" - ["/root/rps-client/root/.vnc/config.d/vncserver-x11"]="/root/.vnc/config.d/vncserver-x11" ["/root/rps-client/usr/bin/custom/hostname"]="/usr/bin/custom/hostname" ["/root/rps-client/usr/bin/custom/chromium-monitor"]="/usr/bin/custom/chromium-monitor" ["/root/rps-client/usr/bin/custom/watchdog-monitor"]="/usr/bin/custom/watchdog-monitor" @@ -119,7 +121,8 @@ done print_status "All files have been successfully copied" echo -e "${RED}→${NC} Setting file permissions..." -sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set" +sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions for 'loginuser' set" +sudo chown wis:wis -R /home/wis >>/var/log/install 2>&1 && print_status "File permissions for 'wis' set" echo -e "${RED}→${NC} Creating log files..." sudo touch /var/log/watchdog.log /var/log/chromium-monitor.log /var/log/hostname.log >>/var/log/install 2>&1 && print_status "Log files created" From 1853f2ff2896517a986e40693762041576c41d7a Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Wed, 30 Oct 2024 10:01:30 +0100 Subject: [PATCH 81/89] install.sh aktualisiert --- install.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 9d2dbb4..230bd04 100644 --- a/install.sh +++ b/install.sh @@ -65,8 +65,8 @@ else print_status "VNC password is set. Authentication will be required." >> /var/log/install 2>&1 fi sudo raspi-config nonint do_vnc 0 >>/var/log/install 2>&1 && print_status "VNC enabled in raspi-config" -sudo systemctl unmask vncserver-x11-serviced.service -sudo systemctl enable vncserver-x11-serviced.service +sudo systemctl unmask vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC unmask" +sudo systemctl enable vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC enabled systemctl" echo -e "${RED}→${NC} Creating user 'loginuser'..." sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" @@ -135,7 +135,7 @@ sudo systemctl daemon-reload >>/var/log/install 2>&1 && print_status "Daemon rel sudo systemctl enable hostname watchdog chromium-monitor vncserver-x11-serviced.service getty@tty1 >>/var/log/install 2>&1 && print_status "Services enabled" sudo systemctl restart getty@tty1 >>/var/log/install 2>&1 && print_status "getty service restarted" -echo -e "${RED}→${NC} Do you want to clean up unused kernels? (yes/y/ye to proceed):" +echo -e "${RED}→${NC} Do you want to clean up unused kernels? (y/n):" read -r clean_kernels if [[ "$clean_kernels" =~ ^[Yy](e[Ss]?)?$ ]]; then echo -e "${RED}→${NC} Cleaning up unused kernels..." @@ -145,6 +145,12 @@ else print_status "Cleanup has been skipped" >> /var/log/install 2>&1 fi +echo "performance" | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor +sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target + +echo -e "${RED}→${NC} Cleaning up installer..." +sudo rm -rf ./rps-client >>/var/log/install 2>&1 && print_status "Installer cleaned up" + echo -e "${RED}→${NC} Configuring Overlayroot..." CONFIG_FILE="/etc/overlayroot.conf" echo 'overlayroot_cfgdisk="disabled"' | sudo tee "$CONFIG_FILE" @@ -159,16 +165,13 @@ else echo -e "${RED}✖${NC} Overlayroot has not been activated." >> /var/log/install 2>&1 fi -echo -e "${RED}→${NC} Cleaning up installer..." -sudo rm -rf ./rps-client >>/var/log/install 2>&1 && print_status "Installer cleaned up" - echo -e "${GREEN}✔${NC} Installation complete. Press any key to reboot..." >> /var/log/install 2>&1 read -n 1 -s + sudo reboot -echo "performance" | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor -sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target + # Version 1.2: # Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. From 16be62b87878fce69d0f9d34de30d2277b9ca1d4 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Wed, 30 Oct 2024 10:10:25 +0100 Subject: [PATCH 82/89] install.sh aktualisiert --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 230bd04..68813b6 100644 --- a/install.sh +++ b/install.sh @@ -23,7 +23,7 @@ sudo apt autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove" sudo apt clean >>/var/log/install 2>&1 && print_status "Clean" rm -rf /var/lib/apt/lists/* >>/var/log/install 2>&1 && print_status "Clear cache" -echo -e "${GREEN}→${NC} Configuring Raspberry Pi settings..." +echo -e "${RED}→${NC} Configuring Raspberry Pi settings..." sudo raspi-config nonint do_camera 0 >> /var/log/install 2>&1 && print_status "Camera disabled" sudo raspi-config nonint do_vnc 0 >> /var/log/install 2>&1 && print_status "VNC enabled" sudo raspi-config nonint do_spi 0 >> /var/log/install 2>&1 && print_status "SPI disabled" From 4d072450c0dc6ee870c0b2555c3869f8d592e075 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Wed, 30 Oct 2024 17:34:55 +0100 Subject: [PATCH 83/89] install.sh aktualisiert --- install.sh | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/install.sh b/install.sh index 68813b6..9344671 100644 --- a/install.sh +++ b/install.sh @@ -11,19 +11,19 @@ print_status() { echo -e "${GREEN}✔${NC} ${1} completed." } -echo -e "${RED}→${NC} Starting System Update..." +echo -e "${RED}→${NC} Starting System Update..." | tee -a /var/log/install sudo apt update >>/var/log/install 2>&1 && print_status "System Update" sudo apt upgrade -y >>/var/log/install 2>&1 && print_status "System Upgrade" sudo apt dist-upgrade -y >>/var/log/install 2>&1 && print_status "System Dist-Upgrade" -echo -e "${RED}→${NC} Installing required packages..." +echo -e "${RED}→${NC} Installing required packages..." | tee -a /var/log/install sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit chromium-browser fonts-noto-color-emoji nfs-common watchdog xdotool rsync -y >>/var/log/install 2>&1 && print_status "Required packages installed" sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" sudo apt autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove" sudo apt clean >>/var/log/install 2>&1 && print_status "Clean" rm -rf /var/lib/apt/lists/* >>/var/log/install 2>&1 && print_status "Clear cache" -echo -e "${RED}→${NC} Configuring Raspberry Pi settings..." +echo -e "${RED}→${NC} Configuring Raspberry Pi settings..." | tee -a /var/log/install sudo raspi-config nonint do_camera 0 >> /var/log/install 2>&1 && print_status "Camera disabled" sudo raspi-config nonint do_vnc 0 >> /var/log/install 2>&1 && print_status "VNC enabled" sudo raspi-config nonint do_spi 0 >> /var/log/install 2>&1 && print_status "SPI disabled" @@ -36,20 +36,20 @@ sudo raspi-config nonint do_locale "de_DE.UTF-8" "de_DE.UTF-8" >> /var/log/insta sudo raspi-config nonint do_timezone "Europe/Berlin" >> /var/log/install 2>&1 && print_status "Timezone set to Europe/Berlin" sudo raspi-config nonint do_boot_order 3 >> /var/log/install 2>&1 && print_status "Boot order set to network boot" -echo -e "${RED}→${NC} Configuring VNC..." +echo -e "${RED}→${NC} Configuring VNC..." | tee -a /var/log/install sudo systemctl enable vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service enabled" sudo systemctl start vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service started" CONFIG_FILE="/root/.vnc/config.d/vncserver-x11" if [ ! -d "$(dirname "$CONFIG_FILE")" ]; then mkdir -p "$(dirname "$CONFIG_FILE")" - print_status "Created directory for VNC config." >> /var/log/install 2>&1 + echo -e "${GREEN}✔${NC} Created directory for VNC config." | tee -a /var/log/install fi read -p "Do you want to set a VNC password? (y/n): " -r if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then vncpasswd - print_status "VNC password has been set." >> /var/log/install 2>&1 + echo -e "${GREEN}✔${NC} VNC password has been set." | tee -a /var/log/install else - echo -e "${RED}✖${NC} No VNC password will be set." >> /var/log/install 2>&1 + echo -e "${GREEN}✔${NC} No VNC password will be set." | tee -a /var/log/install fi if [ "$(vncpasswd -o)" = 'none' ]; then echo "Authentication=None" >> "$CONFIG_FILE" @@ -68,10 +68,10 @@ sudo raspi-config nonint do_vnc 0 >>/var/log/install 2>&1 && print_status "VNC e sudo systemctl unmask vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC unmask" sudo systemctl enable vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC enabled systemctl" -echo -e "${RED}→${NC} Creating user 'loginuser'..." +echo -e "${RED}→${NC} Creating user 'loginuser'..." | tee -a /var/log/install sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" -echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." +echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." | tee -a /var/log/install sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl start watchdog, /usr/bin/systemctl stop watchdog, /usr/bin/systemctl restart watchdog loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop watchdog-monitor @@ -87,13 +87,13 @@ loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot EOF sudo usermod -aG video loginuser >>/var/log/install 2>&1 && print_status "Permissions for 'loginuser' set" -echo -e "${RED}→${NC} Disabling root login..." +echo -e "${RED}→${NC} Disabling root login..." | tee -a /var/log/install sudo tee /etc/ssh/sshd_config >/dev/null << 'EOF' PermitRootLogin no EOF sudo passwd -l root >>/var/log/install 2>&1 && print_status "Root login disabled" -echo -e "${RED}→${NC} Copy requiered files..." +echo -e "${RED}→${NC} Copy requiered files..." | tee -a /var/log/install mkdir -p /etc/chromium/policies/managed /home/wis/.ssh /usr/bin/custom declare -A files=( ["/root/rps-client/boot/ro-root.sh"]="/boot/ro-root.sh" @@ -120,49 +120,49 @@ for src in "${!files[@]}"; do done print_status "All files have been successfully copied" -echo -e "${RED}→${NC} Setting file permissions..." +echo -e "${RED}→${NC} Setting file permissions..." | tee -a /var/log/install sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions for 'loginuser' set" sudo chown wis:wis -R /home/wis >>/var/log/install 2>&1 && print_status "File permissions for 'wis' set" -echo -e "${RED}→${NC} Creating log files..." +echo -e "${RED}→${NC} Creating log files..." | tee -a /var/log/install sudo touch /var/log/watchdog.log /var/log/chromium-monitor.log /var/log/hostname.log >>/var/log/install 2>&1 && print_status "Log files created" sudo chown loginuser:loginuser /var/log/watchdog.log /var/log/chromium-monitor.log /var/log/hostname.log >>/var/log/install 2>&1 && print_status "Ownership set for log files" sudo chmod 777 /var/log/watchdog.log /var/log/chromium-monitor.log /var/log/hostname.log >>/var/log/install 2>&1 && print_status "Permissions set for log files" sudo chmod +x /usr/bin/custom/* >>/var/log/install 2>&1 && print_status "Permissions set for script files" -echo -e "${RED}→${NC} Enabling services..." +echo -e "${RED}→${NC} Enabling services..." | tee -a /var/log/install sudo systemctl daemon-reload >>/var/log/install 2>&1 && print_status "Daemon reloaded" sudo systemctl enable hostname watchdog chromium-monitor vncserver-x11-serviced.service getty@tty1 >>/var/log/install 2>&1 && print_status "Services enabled" sudo systemctl restart getty@tty1 >>/var/log/install 2>&1 && print_status "getty service restarted" -echo -e "${RED}→${NC} Do you want to clean up unused kernels? (y/n):" +echo -e "${RED}→${NC} Do you want to clean up unused kernels? (y/n):" | tee -a /var/log/install read -r clean_kernels if [[ "$clean_kernels" =~ ^[Yy](e[Ss]?)?$ ]]; then - echo -e "${RED}→${NC} Cleaning up unused kernels..." + echo -e "${RED}→${NC} Cleaning up unused kernels..." | tee -a /var/log/install sudo bash /root/remove_unused_kernel.sh -u -e >>/var/log/install 2>&1 && print_status "Unused kernels cleaned up" else - echo -e "${RED}→${NC} Skipping unused kernel cleanup..." - print_status "Cleanup has been skipped" >> /var/log/install 2>&1 + echo -e "${RED}→${NC} Skipping unused kernel cleanup..." | tee -a /var/log/install + echo -e "${GREEN}✔${NC} Cleanup has been skipped" | tee -a /var/log/install fi echo "performance" | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target -echo -e "${RED}→${NC} Cleaning up installer..." +echo -e "${RED}→${NC} Cleaning up installer..." | tee -a /var/log/install sudo rm -rf ./rps-client >>/var/log/install 2>&1 && print_status "Installer cleaned up" -echo -e "${RED}→${NC} Configuring Overlayroot..." +echo -e "${RED}→${NC} Configuring Overlayroot..." | tee -a /var/log/install CONFIG_FILE="/etc/overlayroot.conf" -echo 'overlayroot_cfgdisk="disabled"' | sudo tee "$CONFIG_FILE" -echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" +echo 'overlayroot_cfgdisk="disabled"' | sudo tee "$CONFIG_FILE" >/dev/null +echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" >/dev/null read -p "Do you want to activate overlayfs? (y/n): " -r if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then - echo 'overlayroot="tmpfs:overlayfs"' | sudo tee -a "$CONFIG_FILE" + echo 'overlayroot="tmpfs:overlayfs"' | sudo tee -a "$CONFIG_FILE" sudo raspi-config nonint do_overlayroot 0 >>/var/log/install 2>&1 && print_status "Overlayroot enabled in raspi-config" - print_status "Overlayroot has been activated." >> /var/log/install 2>&1 + echo -e "${GREEN}✔${NC} Overlayroot has been activated." | tee -a /var/log/install else echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" - echo -e "${RED}✖${NC} Overlayroot has not been activated." >> /var/log/install 2>&1 + echo -e "${GREEN}✔${NC} Overlayroot has not been activated." | tee -a /var/log/install fi echo -e "${GREEN}✔${NC} Installation complete. Press any key to reboot..." >> /var/log/install 2>&1 From 8d57596072be1cdd346cfd04a01d3792bd6eb50d Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Wed, 30 Oct 2024 17:36:28 +0100 Subject: [PATCH 84/89] home/loginuser/.xinitrc aktualisiert --- home/loginuser/.xinitrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/home/loginuser/.xinitrc b/home/loginuser/.xinitrc index 98c3785..56f7edd 100644 --- a/home/loginuser/.xinitrc +++ b/home/loginuser/.xinitrc @@ -24,7 +24,11 @@ then WBS=https://www.wis.gmbh/ fi -#Start Chromium +sudo systemctl stop watchdog-monitor +sudo systemctl stop chromium-monitor +sudo systemctl start watchdog-monitor +sudo systemctl start chromium-monitor + chromium-browser $WBS \ --window-size=$RES \ --window-position=0,0 \ From 61a4fabac9f0ef1a0263574f31dfba6d576169b6 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Fri, 8 Nov 2024 12:40:54 +0100 Subject: [PATCH 85/89] install.sh aktualisiert --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 9344671..fb88980 100644 --- a/install.sh +++ b/install.sh @@ -73,8 +73,8 @@ sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." | tee -a /var/log/install sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' -loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl start watchdog, /usr/bin/systemctl stop watchdog, /usr/bin/systemctl restart watchdog -loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop watchdog-monitor +loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop chromium-monitor, /usr/bin/systemctl start chromium-monitor +loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop watchdog-monitor, /usr/bin/systemctl start watchdog-monitor loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/* loginuser ALL=(ALL) NOPASSWD: /usr/bin/cp /etc/watchdog.conf /etc/watchdog.conf.bak loginuser ALL=(ALL) NOPASSWD: /usr/bin/tee /etc/watchdog.conf, /usr/bin/tee -a /etc/watchdog.conf From 4547c21cba39b79fef3777a730ef79c869acee82 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Fri, 8 Nov 2024 12:46:38 +0100 Subject: [PATCH 86/89] install.sh aktualisiert --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index fb88980..458b94c 100644 --- a/install.sh +++ b/install.sh @@ -52,13 +52,13 @@ else echo -e "${GREEN}✔${NC} No VNC password will be set." | tee -a /var/log/install fi if [ "$(vncpasswd -o)" = 'none' ]; then - echo "Authentication=None" >> "$CONFIG_FILE" + echo "Authentication=none" >> "$CONFIG_FILE" echo "Geometry=1920x1080" >> "$CONFIG_FILE" echo "# Version 1.0:" >> "$CONFIG_FILE" echo "# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspbian as custom PXE init script." >> "$CONFIG_FILE" print_status "VNC config set to no authentication with geometry 1920x1080." >> /var/log/install 2>&1 else - echo "Authentication=VNC" >> "$CONFIG_FILE" + echo "Authentication=none" >> "$CONFIG_FILE" echo "Geometry=1920x1080" >> "$CONFIG_FILE" echo "# Version 1.0:" >> "$CONFIG_FILE" echo "# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspbian as custom PXE init script." >> "$CONFIG_FILE" From 18cd5a388d42c62d246a570bfcea9d0bb2a2e5b3 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Sat, 9 Nov 2024 22:13:38 +0100 Subject: [PATCH 87/89] install.sh aktualisiert --- install.sh | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/install.sh b/install.sh index 458b94c..9ad5da3 100644 --- a/install.sh +++ b/install.sh @@ -36,6 +36,33 @@ sudo raspi-config nonint do_locale "de_DE.UTF-8" "de_DE.UTF-8" >> /var/log/insta sudo raspi-config nonint do_timezone "Europe/Berlin" >> /var/log/install 2>&1 && print_status "Timezone set to Europe/Berlin" sudo raspi-config nonint do_boot_order 3 >> /var/log/install 2>&1 && print_status "Boot order set to network boot" +echo -e "${RED}→${NC} Copy requiered files..." | tee -a /var/log/install +mkdir -p /etc/chromium/policies/managed /home/wis/.ssh /usr/bin/custom +declare -A files=( + ["/root/rps-client/boot/ro-root.sh"]="/boot/ro-root.sh" + ["/root/rps-client/boot/firmware/ro-root.sh"]="/boot/firmware/ro-root.sh" + ["/root/rps-client/etc/dhcp/dhclient.conf"]="/etc/dhcp/dhclient.conf" + ["/root/rps-client/etc/systemd/system/hostname.service"]="/etc/systemd/system/hostname.service" + ["/root/rps-client/etc/systemd/system/watchdog-monitor.service"]="/etc/systemd/system/watchdog-monitor.service" + ["/root/rps-client/etc/systemd/system/chromium-monitor.service"]="/etc/systemd/system/chromium-monitor.service" + ["/root/rps-client/etc/systemd/system/getty@tty1.service.d/override.conf"]="/etc/systemd/system/getty@tty1.service.d/override.conf" + ["/root/rps-client/etc/chromium/policies/managed/disable_password_saving.json"]="/etc/chromium/policies/managed/disable_password_saving.json" + ["/root/rps-client/home/loginuser/.bash_profile"]="/home/loginuser/.bash_profile" + ["/root/rps-client/home/loginuser/.xinitrc"]="/home/loginuser/.xinitrc" + ["/root/rps-client/home/wis/.ssh/id_rsa.pub"]="/home/wis/.ssh/id_rsa.pub" + ["/root/rps-client/root/remove_unused_kernel.sh"]="/root/remove_unused_kernel.sh" + ["/root/rps-client/usr/bin/custom/hostname"]="/usr/bin/custom/hostname" + ["/root/rps-client/usr/bin/custom/chromium-monitor"]="/usr/bin/custom/chromium-monitor" + ["/root/rps-client/usr/bin/custom/watchdog-monitor"]="/usr/bin/custom/watchdog-monitor" +) +RSYNC_OPTS="-a --numeric-ids --info=progress2 --no-owner --no-group" +for src in "${!files[@]}"; do + dst="${files[$src]}" + echo "Copying $src to $dst..." + sudo rsync $RSYNC_OPTS "$src" "$dst" >>/var/log/install 2>&1 && print_status "$src copied to $dst" +done +print_status "All files have been successfully copied" + echo -e "${RED}→${NC} Configuring VNC..." | tee -a /var/log/install sudo systemctl enable vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service enabled" sudo systemctl start vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC service started" @@ -93,33 +120,6 @@ PermitRootLogin no EOF sudo passwd -l root >>/var/log/install 2>&1 && print_status "Root login disabled" -echo -e "${RED}→${NC} Copy requiered files..." | tee -a /var/log/install -mkdir -p /etc/chromium/policies/managed /home/wis/.ssh /usr/bin/custom -declare -A files=( - ["/root/rps-client/boot/ro-root.sh"]="/boot/ro-root.sh" - ["/root/rps-client/boot/firmware/ro-root.sh"]="/boot/firmware/ro-root.sh" - ["/root/rps-client/etc/dhcp/dhclient.conf"]="/etc/dhcp/dhclient.conf" - ["/root/rps-client/etc/systemd/system/hostname.service"]="/etc/systemd/system/hostname.service" - ["/root/rps-client/etc/systemd/system/watchdog-monitor.service"]="/etc/systemd/system/watchdog-monitor.service" - ["/root/rps-client/etc/systemd/system/chromium-monitor.service"]="/etc/systemd/system/chromium-monitor.service" - ["/root/rps-client/etc/systemd/system/getty@tty1.service.d/override.conf"]="/etc/systemd/system/getty@tty1.service.d/override.conf" - ["/root/rps-client/etc/chromium/policies/managed/disable_password_saving.json"]="/etc/chromium/policies/managed/disable_password_saving.json" - ["/root/rps-client/home/loginuser/.bash_profile"]="/home/loginuser/.bash_profile" - ["/root/rps-client/home/loginuser/.xinitrc"]="/home/loginuser/.xinitrc" - ["/root/rps-client/home/wis/.ssh/id_rsa.pub"]="/home/wis/.ssh/id_rsa.pub" - ["/root/rps-client/root/remove_unused_kernel.sh"]="/root/remove_unused_kernel.sh" - ["/root/rps-client/usr/bin/custom/hostname"]="/usr/bin/custom/hostname" - ["/root/rps-client/usr/bin/custom/chromium-monitor"]="/usr/bin/custom/chromium-monitor" - ["/root/rps-client/usr/bin/custom/watchdog-monitor"]="/usr/bin/custom/watchdog-monitor" -) -RSYNC_OPTS="-a --numeric-ids --info=progress2 --no-owner --no-group" -for src in "${!files[@]}"; do - dst="${files[$src]}" - echo "Copying $src to $dst..." - sudo rsync $RSYNC_OPTS "$src" "$dst" >>/var/log/install 2>&1 && print_status "$src copied to $dst" -done -print_status "All files have been successfully copied" - echo -e "${RED}→${NC} Setting file permissions..." | tee -a /var/log/install sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions for 'loginuser' set" sudo chown wis:wis -R /home/wis >>/var/log/install 2>&1 && print_status "File permissions for 'wis' set" From c8f88bb40ae90961287167490c9fb09260d69445 Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Mon, 11 Nov 2024 17:37:44 +0100 Subject: [PATCH 88/89] install.sh aktualisiert --- install.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 9ad5da3..43b2bb4 100644 --- a/install.sh +++ b/install.sh @@ -36,6 +36,9 @@ sudo raspi-config nonint do_locale "de_DE.UTF-8" "de_DE.UTF-8" >> /var/log/insta sudo raspi-config nonint do_timezone "Europe/Berlin" >> /var/log/install 2>&1 && print_status "Timezone set to Europe/Berlin" sudo raspi-config nonint do_boot_order 3 >> /var/log/install 2>&1 && print_status "Boot order set to network boot" +echo -e "${RED}→${NC} Creating user 'loginuser'..." | tee -a /var/log/install +sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" + echo -e "${RED}→${NC} Copy requiered files..." | tee -a /var/log/install mkdir -p /etc/chromium/policies/managed /home/wis/.ssh /usr/bin/custom declare -A files=( @@ -95,9 +98,6 @@ sudo raspi-config nonint do_vnc 0 >>/var/log/install 2>&1 && print_status "VNC e sudo systemctl unmask vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC unmask" sudo systemctl enable vncserver-x11-serviced.service >>/var/log/install 2>&1 && print_status "VNC enabled systemctl" -echo -e "${RED}→${NC} Creating user 'loginuser'..." | tee -a /var/log/install -sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created" - echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." | tee -a /var/log/install sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF' loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl stop chromium-monitor, /usr/bin/systemctl start chromium-monitor @@ -139,7 +139,7 @@ echo -e "${RED}→${NC} Do you want to clean up unused kernels? (y/n):" | tee -a read -r clean_kernels if [[ "$clean_kernels" =~ ^[Yy](e[Ss]?)?$ ]]; then echo -e "${RED}→${NC} Cleaning up unused kernels..." | tee -a /var/log/install - sudo bash /root/remove_unused_kernel.sh -u -e >>/var/log/install 2>&1 && print_status "Unused kernels cleaned up" + yes yes | head -n 2 | sudo bash /root/remove_unused_kernel.sh -u -e >>/var/log/install 2>&1 && print_status "Unused kernels cleaned up" else echo -e "${RED}→${NC} Skipping unused kernel cleanup..." | tee -a /var/log/install echo -e "${GREEN}✔${NC} Cleanup has been skipped" | tee -a /var/log/install @@ -157,7 +157,7 @@ echo 'overlayroot_cfgdisk="disabled"' | sudo tee "$CONFIG_FILE" >/dev/null echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" >/dev/null read -p "Do you want to activate overlayfs? (y/n): " -r if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then - echo 'overlayroot="tmpfs:overlayfs"' | sudo tee -a "$CONFIG_FILE" + echo 'overlayroot="tmpfs:overlayfs"' | sudo tee -a "$CONFIG_FILE" sudo raspi-config nonint do_overlayroot 0 >>/var/log/install 2>&1 && print_status "Overlayroot enabled in raspi-config" echo -e "${GREEN}✔${NC} Overlayroot has been activated." | tee -a /var/log/install else @@ -170,8 +170,5 @@ read -n 1 -s sudo reboot - - - # Version 1.2: -# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. +# Created 2024 by Tim Eertmoed, Christian Hampp @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script. \ No newline at end of file From 422790edcd83bc1ad8424d842311ffc7503e55fb Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Thu, 14 Nov 2024 15:06:14 +0100 Subject: [PATCH 89/89] install.sh aktualisiert --- install.sh | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/install.sh b/install.sh index 43b2bb4..12aebbe 100644 --- a/install.sh +++ b/install.sh @@ -12,28 +12,28 @@ print_status() { } echo -e "${RED}→${NC} Starting System Update..." | tee -a /var/log/install -sudo apt update >>/var/log/install 2>&1 && print_status "System Update" -sudo apt upgrade -y >>/var/log/install 2>&1 && print_status "System Upgrade" -sudo apt dist-upgrade -y >>/var/log/install 2>&1 && print_status "System Dist-Upgrade" +sudo apt-get update >>/var/log/install 2>&1 && print_status "System Update" +sudo apt-get upgrade -y >>/var/log/install 2>&1 && print_status "System Upgrade" +#sudo apt-get dist-upgrade -y >>/var/log/install 2>&1 && print_status "System Dist-Upgrade" echo -e "${RED}→${NC} Installing required packages..." | tee -a /var/log/install sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit chromium-browser fonts-noto-color-emoji nfs-common watchdog xdotool rsync -y >>/var/log/install 2>&1 && print_status "Required packages installed" -sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" +#sudo apt install realvnc-vnc-server overlayroot -y >>/var/log/install 2>&1 && print_status "VNC and Overlayroot installed" sudo apt autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove" sudo apt clean >>/var/log/install 2>&1 && print_status "Clean" rm -rf /var/lib/apt/lists/* >>/var/log/install 2>&1 && print_status "Clear cache" echo -e "${RED}→${NC} Configuring Raspberry Pi settings..." | tee -a /var/log/install -sudo raspi-config nonint do_camera 0 >> /var/log/install 2>&1 && print_status "Camera disabled" -sudo raspi-config nonint do_vnc 0 >> /var/log/install 2>&1 && print_status "VNC enabled" -sudo raspi-config nonint do_spi 0 >> /var/log/install 2>&1 && print_status "SPI disabled" -sudo raspi-config nonint do_i2c 0 >> /var/log/install 2>&1 && print_status "I2C disabled" -sudo raspi-config nonint do_serial 0 0 >> /var/log/install 2>&1 && print_status "Serial port disabled" -sudo raspi-config nonint do_onewire 0 >> /var/log/install 2>&1 && print_status "1-Wire disabled" -sudo raspi-config nonint do_remote_gpio 0 >> /var/log/install 2>&1 && print_status "Remote GPIO disabled" -sudo raspi-config nonint do_gpu_memory 256 >> /var/log/install 2>&1 && print_status "GPU memory set to 256MB" -sudo raspi-config nonint do_locale "de_DE.UTF-8" "de_DE.UTF-8" >> /var/log/install 2>&1 && print_status "Locale set to de_DE.UTF-8" -sudo raspi-config nonint do_timezone "Europe/Berlin" >> /var/log/install 2>&1 && print_status "Timezone set to Europe/Berlin" +#sudo raspi-config nonint do_camera 0 >> /var/log/install 2>&1 && print_status "Camera disabled" +#sudo raspi-config nonint do_vnc 0 >> /var/log/install 2>&1 && print_status "VNC enabled" +#sudo raspi-config nonint do_spi 0 >> /var/log/install 2>&1 && print_status "SPI disabled" +#sudo raspi-config nonint do_i2c 0 >> /var/log/install 2>&1 && print_status "I2C disabled" +#sudo raspi-config nonint do_serial 0 0 >> /var/log/install 2>&1 && print_status "Serial port disabled" +#sudo raspi-config nonint do_onewire 0 >> /var/log/install 2>&1 && print_status "1-Wire disabled" +#sudo raspi-config nonint do_remote_gpio 0 >> /var/log/install 2>&1 && print_status "Remote GPIO disabled" +#sudo raspi-config nonint do_gpu_memory 256 >> /var/log/install 2>&1 && print_status "GPU memory set to 256MB" +#sudo raspi-config nonint do_locale "de_DE.UTF-8" "de_DE.UTF-8" >> /var/log/install 2>&1 && print_status "Locale set to de_DE.UTF-8" +#sudo raspi-config nonint do_timezone "Europe/Berlin" >> /var/log/install 2>&1 && print_status "Timezone set to Europe/Berlin" sudo raspi-config nonint do_boot_order 3 >> /var/log/install 2>&1 && print_status "Boot order set to network boot" echo -e "${RED}→${NC} Creating user 'loginuser'..." | tee -a /var/log/install @@ -151,21 +151,21 @@ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.ta echo -e "${RED}→${NC} Cleaning up installer..." | tee -a /var/log/install sudo rm -rf ./rps-client >>/var/log/install 2>&1 && print_status "Installer cleaned up" -echo -e "${RED}→${NC} Configuring Overlayroot..." | tee -a /var/log/install -CONFIG_FILE="/etc/overlayroot.conf" -echo 'overlayroot_cfgdisk="disabled"' | sudo tee "$CONFIG_FILE" >/dev/null -echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" >/dev/null -read -p "Do you want to activate overlayfs? (y/n): " -r -if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then - echo 'overlayroot="tmpfs:overlayfs"' | sudo tee -a "$CONFIG_FILE" - sudo raspi-config nonint do_overlayroot 0 >>/var/log/install 2>&1 && print_status "Overlayroot enabled in raspi-config" - echo -e "${GREEN}✔${NC} Overlayroot has been activated." | tee -a /var/log/install -else - echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" - echo -e "${GREEN}✔${NC} Overlayroot has not been activated." | tee -a /var/log/install -fi +#echo -e "${RED}→${NC} Configuring Overlayroot..." | tee -a /var/log/install +#CONFIG_FILE="/etc/overlayroot.conf" +#echo 'overlayroot_cfgdisk="disabled"' | sudo tee "$CONFIG_FILE" >/dev/null +#echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" >/dev/null +#read -p "Do you want to activate overlayfs? (y/n): " -r +#if [[ $REPLY =~ ^[Yy](e[Ss]?)?$ ]]; then +# echo 'overlayroot="tmpfs:overlayfs"' | sudo tee -a "$CONFIG_FILE" +# sudo raspi-config nonint do_overlayroot 0 >>/var/log/install 2>&1 && print_status "Overlayroot enabled in raspi-config" +# echo -e "${GREEN}✔${NC} Overlayroot has been activated." | tee -a /var/log/install +#else +# echo 'overlayroot=""' | sudo tee -a "$CONFIG_FILE" +# echo -e "${GREEN}✔${NC} Overlayroot has not been activated." | tee -a /var/log/install +#fi -echo -e "${GREEN}✔${NC} Installation complete. Press any key to reboot..." >> /var/log/install 2>&1 +echo -e "${GREEN}✔${NC} Installation complete. Press any key to reboot..." | tee -a /var/log/install 2>&1 read -n 1 -s sudo reboot