Compare commits
129 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c892f4cac9 | |||
| d2dd04ad05 | |||
| 71d9899cb0 | |||
| 6a0890fb07 | |||
| 7d2e5c106a | |||
| 4a4ea1f048 | |||
| d77a81b38c | |||
| 78bb57f2ae | |||
| 5156f07940 | |||
| b509d70d06 | |||
| 85d2a079a6 | |||
| 0eccb69777 | |||
| 4827f1f708 | |||
| a73808fc1e | |||
| e225fda908 | |||
| f99e5f1fd2 | |||
| 4a300e9448 | |||
| 9f8c063290 | |||
| 94d5562993 | |||
| 4c9e91bf85 | |||
| 3b988b007b | |||
| 2029e34f7b | |||
| 19ec00985f | |||
| 95af8b30c8 | |||
| 3cd029e81b | |||
| 957da88592 | |||
| 05a4f7a4d9 | |||
| 1a6e6ec818 | |||
| a342512f47 | |||
| 7043e38faa | |||
| 29a91daec3 | |||
| 0821fe16e2 | |||
| 4e4c4a7a07 | |||
| 0b81870af8 | |||
| 8db117a15d | |||
| 3643bd727a | |||
| 7412fc76de | |||
| e099b97bb1 | |||
| 307d20f651 | |||
| e7c2d849e8 | |||
| cb3c1c4649 | |||
| e1d817f09a | |||
| 42420cdc5a | |||
| 1947f634a6 | |||
| 94609cb6c9 | |||
| 541c54d1aa | |||
| b71a4fcf9a | |||
| 4889ac79f0 | |||
| a5f48bdfe9 | |||
| ba4a2286f7 | |||
| 41f23212cf | |||
| 735f5be839 | |||
| 56f754c0ee | |||
| ea5ff24038 | |||
| bc97e58e6b | |||
| a2c6e9a046 | |||
| 10fb89ad72 | |||
| a2cb44a790 | |||
| 7262ae5ec6 | |||
| eecb28096b | |||
| c54692ed15 | |||
| cf8a661173 | |||
| ec8c36a73e | |||
| b77291fa8e | |||
| 03220f4332 | |||
| 422790edcd | |||
| c8f88bb40a | |||
| 18cd5a388d | |||
| 4547c21cba | |||
| 61a4fabac9 | |||
| 8d57596072 | |||
| 4d072450c0 | |||
| 16be62b878 | |||
| 1853f2ff28 | |||
| 5ff6d190c3 | |||
| 9e7f59606c | |||
| a70a362ce4 | |||
| 5dc8681dfd | |||
| c7a77796a1 | |||
| 43b9640eb0 | |||
| 1510ce0758 | |||
| a5cd4e6f2c | |||
| 488b0a6406 | |||
| 1720679c1b | |||
| 689824ac04 | |||
| 04e0b1a3b6 | |||
| e35bbc7d77 | |||
| 620fe0c831 | |||
| 16cfbefd83 | |||
| 6341d49f76 | |||
| dcde376e95 | |||
| ce9bafa069 | |||
| 3e711f04fe | |||
| b239b564f1 | |||
| 777d3981f0 | |||
| 6f1498f422 | |||
| 514cc91ed5 | |||
| 0378024409 | |||
| 5f2cd53026 | |||
| b2d2a89ca3 | |||
| 859759a253 | |||
| a20d85f543 | |||
| 7b46dc4e73 | |||
| 63a40835b6 | |||
| 39ee07fe14 | |||
| 2a1dac448a | |||
| c5ed7dde10 | |||
| af0b0c7bb1 | |||
| 259e0d7f3a | |||
| fc1f25477d | |||
| d754b93250 | |||
| 11451b03be | |||
| 068d6ac9a5 | |||
| b58147b391 | |||
| 86b3bdae71 | |||
| cdfd6359da | |||
| bf0b5e857f | |||
| 9b85eddf09 | |||
| 0d5e790cd2 | |||
| 7d05ae6fa4 | |||
| 0dc0236f40 | |||
| f65185644d | |||
| 73ea27ac67 | |||
| d012e5193d | |||
| 6a631c3aee | |||
| 7276958e0b | |||
| 5f9f63d026 | |||
| b6d889a348 | |||
| e511fcb885 |
@@ -1,7 +1,7 @@
|
|||||||
# RPS-Client
|
# RPS-Client
|
||||||
|
|
||||||
```bash
|
```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
|
```ruby
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Read-only Root-FS for Raspian using overlayfs
|
|
||||||
# Version 1.1:
|
|
||||||
# Changed to use /proc/mounts rathern than /etc/fstab for deriving the root filesystem.
|
|
||||||
#
|
|
||||||
# Version 1:
|
|
||||||
# Created 2017 by Pascal Suter @ DALCO AG, Switzerland to work on Raspian as custom init script
|
|
||||||
# (raspbian does not use an initramfs on boot)
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see
|
|
||||||
# <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Tested with Raspbian mini, 2017-01-11
|
|
||||||
#
|
|
||||||
# This script will mount the root filesystem read-only and overlay it with a temporary tempfs
|
|
||||||
# which is read-write mounted. This is done using the overlayFS which is part of the linux kernel
|
|
||||||
# since version 3.18.
|
|
||||||
# when this script is in use, all changes made to anywhere in the root filesystem mount will be lost
|
|
||||||
# upon reboot of the system. The SD card will only be accessed as read-only drive, which significantly
|
|
||||||
# helps to prolong its life and prevent filesystem coruption in environments where the system is usually
|
|
||||||
# not shut down properly
|
|
||||||
#
|
|
||||||
# Install:
|
|
||||||
# copy this script to /sbin/overlayRoot.sh and add "init=/sbin/overlayRoot.sh" to the cmdline.txt
|
|
||||||
# file in the raspbian image's boot partition.
|
|
||||||
# I strongly recommend to disable swapping before using this. it will work with swap but that just does
|
|
||||||
# not make sens as the swap file will be stored in the tempfs which again resides in the ram.
|
|
||||||
# run these commands on the booted raspberry pi BEFORE you set the init=/sbin/overlayRoot.sh boot option:
|
|
||||||
# sudo dphys-swapfile swapoff
|
|
||||||
# sudo dphys-swapfile uninstall
|
|
||||||
# sudo update-rc.d dphys-swapfile remove
|
|
||||||
#
|
|
||||||
# To install software, run upgrades and do other changes to the raspberry setup, simply remove the init=
|
|
||||||
# entry from the cmdline.txt file and reboot, make the changes, add the init= entry and reboot once more.
|
|
||||||
|
|
||||||
fail(){
|
|
||||||
echo -e "$1"
|
|
||||||
/bin/bash
|
|
||||||
}
|
|
||||||
|
|
||||||
# load module
|
|
||||||
modprobe overlay
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: missing overlay kernel module"
|
|
||||||
fi
|
|
||||||
# mount /proc
|
|
||||||
mount -t proc proc /proc
|
|
||||||
|
|
||||||
# create a writable fs to then create our mountpoints
|
|
||||||
mount -t tmpfs inittemp /mnt
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: could not create a temporary filesystem to mount the base filesystems for overlayfs"
|
|
||||||
fi
|
|
||||||
mkdir /mnt/lower
|
|
||||||
mkdir /mnt/rw
|
|
||||||
mount -t tmpfs root-rw /mnt/rw
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: could not create tempfs for upper filesystem"
|
|
||||||
fi
|
|
||||||
mkdir /mnt/rw/upper
|
|
||||||
mkdir /mnt/rw/work
|
|
||||||
mkdir /mnt/newroot
|
|
||||||
|
|
||||||
# mount root filesystem readonly
|
|
||||||
rootDev=`awk '$2 == "/" {print $1}' /proc/mounts`
|
|
||||||
rootMountOpt=`awk '$2 == "/" {print $4}' /proc/mounts`
|
|
||||||
rootFsType=`awk '$2 == "/" {print $3}' /proc/mounts`
|
|
||||||
mount -t ${rootFsType} -o ${rootMountOpt},ro ${rootDev} /mnt/lower
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: could not ro-mount original root partition"
|
|
||||||
fi
|
|
||||||
mount -t overlay -o lowerdir=/mnt/lower,upperdir=/mnt/rw/upper,workdir=/mnt/rw/work overlayfs-root /mnt/newroot
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: could not mount overlayFS"
|
|
||||||
fi
|
|
||||||
# create mountpoints inside the new root filesystem-overlay
|
|
||||||
mkdir /mnt/newroot/ro
|
|
||||||
mkdir /mnt/newroot/rw
|
|
||||||
# remove root mount from fstab (this is already a non-permanent modification)
|
|
||||||
grep -v "$rootDev" /mnt/lower/etc/fstab > /mnt/newroot/etc/fstab
|
|
||||||
echo "#the original root mount has been removed by overlayRoot.sh" >> /mnt/newroot/etc/fstab
|
|
||||||
echo "#this is only a temporary modification, the original fstab" >> /mnt/newroot/etc/fstab
|
|
||||||
echo "#stored on the disk can be found in /ro/etc/fstab" >> /mnt/newroot/etc/fstab
|
|
||||||
# change to the new overlay root
|
|
||||||
cd /mnt/newroot
|
|
||||||
pivot_root . mnt
|
|
||||||
exec chroot . sh -c "$(cat <<END
|
|
||||||
# move ro and rw mounts to the new root
|
|
||||||
mount --move /mnt/mnt/lower/ /ro
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: could not move ro-root into newroot"
|
|
||||||
/bin/bash
|
|
||||||
fi
|
|
||||||
mount --move /mnt/mnt/rw /rw
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: could not move tempfs rw mount into newroot"
|
|
||||||
/bin/bash
|
|
||||||
fi
|
|
||||||
# unmount unneeded mounts so we can unmout the old readonly root
|
|
||||||
umount /mnt/mnt
|
|
||||||
umount /mnt/proc
|
|
||||||
umount -l -f /mnt/dev
|
|
||||||
umount -l -f /mnt
|
|
||||||
# continue with regular init
|
|
||||||
exec /sbin/init
|
|
||||||
END
|
|
||||||
)"
|
|
||||||
120
boot/ro-root.sh
120
boot/ro-root.sh
@@ -1,120 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Read-only Root-FS for Raspian using overlayfs
|
|
||||||
# Version 1.1:
|
|
||||||
# Changed to use /proc/mounts rathern than /etc/fstab for deriving the root filesystem.
|
|
||||||
#
|
|
||||||
# Version 1:
|
|
||||||
# Created 2017 by Pascal Suter @ DALCO AG, Switzerland to work on Raspian as custom init script
|
|
||||||
# (raspbian does not use an initramfs on boot)
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see
|
|
||||||
# <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Tested with Raspbian mini, 2017-01-11
|
|
||||||
#
|
|
||||||
# This script will mount the root filesystem read-only and overlay it with a temporary tempfs
|
|
||||||
# which is read-write mounted. This is done using the overlayFS which is part of the linux kernel
|
|
||||||
# since version 3.18.
|
|
||||||
# when this script is in use, all changes made to anywhere in the root filesystem mount will be lost
|
|
||||||
# upon reboot of the system. The SD card will only be accessed as read-only drive, which significantly
|
|
||||||
# helps to prolong its life and prevent filesystem coruption in environments where the system is usually
|
|
||||||
# not shut down properly
|
|
||||||
#
|
|
||||||
# Install:
|
|
||||||
# copy this script to /sbin/overlayRoot.sh and add "init=/sbin/overlayRoot.sh" to the cmdline.txt
|
|
||||||
# file in the raspbian image's boot partition.
|
|
||||||
# I strongly recommend to disable swapping before using this. it will work with swap but that just does
|
|
||||||
# not make sens as the swap file will be stored in the tempfs which again resides in the ram.
|
|
||||||
# run these commands on the booted raspberry pi BEFORE you set the init=/sbin/overlayRoot.sh boot option:
|
|
||||||
# sudo dphys-swapfile swapoff
|
|
||||||
# sudo dphys-swapfile uninstall
|
|
||||||
# sudo update-rc.d dphys-swapfile remove
|
|
||||||
#
|
|
||||||
# To install software, run upgrades and do other changes to the raspberry setup, simply remove the init=
|
|
||||||
# entry from the cmdline.txt file and reboot, make the changes, add the init= entry and reboot once more.
|
|
||||||
|
|
||||||
fail(){
|
|
||||||
echo -e "$1"
|
|
||||||
/bin/bash
|
|
||||||
}
|
|
||||||
|
|
||||||
# load module
|
|
||||||
modprobe overlay
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: missing overlay kernel module"
|
|
||||||
fi
|
|
||||||
# mount /proc
|
|
||||||
mount -t proc proc /proc
|
|
||||||
|
|
||||||
# create a writable fs to then create our mountpoints
|
|
||||||
mount -t tmpfs inittemp /mnt
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: could not create a temporary filesystem to mount the base filesystems for overlayfs"
|
|
||||||
fi
|
|
||||||
mkdir /mnt/lower
|
|
||||||
mkdir /mnt/rw
|
|
||||||
mount -t tmpfs root-rw /mnt/rw
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: could not create tempfs for upper filesystem"
|
|
||||||
fi
|
|
||||||
mkdir /mnt/rw/upper
|
|
||||||
mkdir /mnt/rw/work
|
|
||||||
mkdir /mnt/newroot
|
|
||||||
|
|
||||||
# mount root filesystem readonly
|
|
||||||
rootDev=`awk '$2 == "/" {print $1}' /proc/mounts`
|
|
||||||
rootMountOpt=`awk '$2 == "/" {print $4}' /proc/mounts`
|
|
||||||
rootFsType=`awk '$2 == "/" {print $3}' /proc/mounts`
|
|
||||||
mount -t ${rootFsType} -o ${rootMountOpt},ro ${rootDev} /mnt/lower
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: could not ro-mount original root partition"
|
|
||||||
fi
|
|
||||||
mount -t overlay -o lowerdir=/mnt/lower,upperdir=/mnt/rw/upper,workdir=/mnt/rw/work overlayfs-root /mnt/newroot
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
fail "ERROR: could not mount overlayFS"
|
|
||||||
fi
|
|
||||||
# create mountpoints inside the new root filesystem-overlay
|
|
||||||
mkdir /mnt/newroot/ro
|
|
||||||
mkdir /mnt/newroot/rw
|
|
||||||
# remove root mount from fstab (this is already a non-permanent modification)
|
|
||||||
grep -v "$rootDev" /mnt/lower/etc/fstab > /mnt/newroot/etc/fstab
|
|
||||||
echo "#the original root mount has been removed by overlayRoot.sh" >> /mnt/newroot/etc/fstab
|
|
||||||
echo "#this is only a temporary modification, the original fstab" >> /mnt/newroot/etc/fstab
|
|
||||||
echo "#stored on the disk can be found in /ro/etc/fstab" >> /mnt/newroot/etc/fstab
|
|
||||||
# change to the new overlay root
|
|
||||||
cd /mnt/newroot
|
|
||||||
pivot_root . mnt
|
|
||||||
exec chroot . sh -c "$(cat <<END
|
|
||||||
# move ro and rw mounts to the new root
|
|
||||||
mount --move /mnt/mnt/lower/ /ro
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: could not move ro-root into newroot"
|
|
||||||
/bin/bash
|
|
||||||
fi
|
|
||||||
mount --move /mnt/mnt/rw /rw
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: could not move tempfs rw mount into newroot"
|
|
||||||
/bin/bash
|
|
||||||
fi
|
|
||||||
# unmount unneeded mounts so we can unmout the old readonly root
|
|
||||||
umount /mnt/mnt
|
|
||||||
umount /mnt/proc
|
|
||||||
umount -l -f /mnt/dev
|
|
||||||
umount -l -f /mnt
|
|
||||||
# continue with regular init
|
|
||||||
exec /sbin/init
|
|
||||||
END
|
|
||||||
)"
|
|
||||||
@@ -14,7 +14,8 @@ then
|
|||||||
xset s noblank
|
xset s noblank
|
||||||
xset s off
|
xset s off
|
||||||
else
|
else
|
||||||
xset s $SCREEN
|
xset +dpms
|
||||||
|
xset dmps 0 0 $SCREEN
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#NO-Var fallback site
|
#NO-Var fallback site
|
||||||
@@ -23,7 +24,8 @@ then
|
|||||||
WBS=https://www.wis.gmbh/
|
WBS=https://www.wis.gmbh/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Start Chromium
|
sudo systemctl start chromium-monitor
|
||||||
|
|
||||||
chromium-browser $WBS \
|
chromium-browser $WBS \
|
||||||
--window-size=$RES \
|
--window-size=$RES \
|
||||||
--window-position=0,0 \
|
--window-position=0,0 \
|
||||||
38
data/config/config.txt
Normal file
38
data/config/config.txt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# --- Basis Boot Einstellungen ---
|
||||||
|
disable_splash=1 # Kein Raspberry-Pi-Bootlogo
|
||||||
|
boot_delay=0 # Kein Boot-Delay (schnellerer Start)
|
||||||
|
initial_turbo=30 # CPU für 30 Sek. auf maximale Leistung setzen (schnelleres PXE-Boot)
|
||||||
|
|
||||||
|
# --- Netzwerk PXE Boot ---
|
||||||
|
program_usb_boot_mode=1 # Aktiviert USB/Netzwerk-Boot (nur einmalig nötig)
|
||||||
|
bootcode_delay=1 # Reduziert Wartezeit beim Netzwerkboot
|
||||||
|
|
||||||
|
# --- GPU & Video Settings (für 2 Monitore) ---
|
||||||
|
gpu_mem=192 # 192 MB Grafikspeicher für stabilen Dual-Monitor-Betrieb
|
||||||
|
max_framebuffers=2 # Unterstützt 2 Bildschirme
|
||||||
|
hdmi_force_hotplug=1 # Erzwungene HDMI-Erkennung (wichtig bei Boot ohne angeschlossenen Monitor)
|
||||||
|
hdmi_drive=1 # DVI-Modus (kein Audio über HDMI)
|
||||||
|
hdmi_ignore_edid_audio=1 # HDMI-Audio komplett deaktivieren
|
||||||
|
dtoverlay=vc4-kms-v3d # KMS-Grafiktreiber für beste Kompatibilität
|
||||||
|
|
||||||
|
# --- Display Konfiguration ---
|
||||||
|
disable_overscan=1 # Deaktiviert Overscan für eine saubere Anzeige
|
||||||
|
hdmi_group=2 # Modus für explizite Auflösungswahl
|
||||||
|
hdmi_mode=82 # 1080p @ 60 Hz
|
||||||
|
hdmi_blanking=1 # Reduziert Stromverbrauch bei ausgeschaltetem Bildschirm
|
||||||
|
|
||||||
|
# --- Touchscreen Einstellungen (falls benötigt) ---
|
||||||
|
dtoverlay=usbtouchscreen # Aktiviert Unterstützung für HID-kompatible USB-Touchscreens
|
||||||
|
dtoverlay=goodix # Aktiviert Unterstützung für I2C-basierte Goodix-Touchscreens
|
||||||
|
dtparam=i2c_arm=on # Falls Touchscreen über I2C läuft
|
||||||
|
|
||||||
|
# --- Deaktivierung von nicht benötigten Funktionen ---
|
||||||
|
dtoverlay=disable-wifi # WLAN abschalten
|
||||||
|
dtoverlay=disable-bt # Bluetooth abschalten
|
||||||
|
dtparam=audio=off # Onboard-Sound deaktivieren (spart Ressourcen)
|
||||||
|
|
||||||
|
# --- Optimierung für Embedded-Betrieb (stabiler und stromsparender) ---
|
||||||
|
force_turbo=0 # Kein permanentes Overclocking (längere Lebensdauer)
|
||||||
|
arm_boost=1 # Automatische Taktoptimierung (nur auf RPi 4/400)
|
||||||
|
temp_limit=75 # Max. Temperaturbegrenzung (75°C)
|
||||||
|
over_voltage=0 # Keine Spannungsanpassung (stabil)
|
||||||
51
data/scripts/chromium-monitor
Normal file
51
data/scripts/chromium-monitor
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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 | \
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Initialize monitor variable
|
||||||
|
monitor=""
|
||||||
|
while [ -z "$monitor" ]; do
|
||||||
|
monitor=$(get_monitor)
|
||||||
|
if [ -n "$monitor" ]; then
|
||||||
|
log "Initial monitor detected: $monitor" # Log initial monitor
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
# Main loop to continuously check the current window
|
||||||
|
while true; do
|
||||||
|
current_window=$(get_current_window) # Get the current window name
|
||||||
|
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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 Raspbian as custom PXE init script.
|
||||||
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
LOGFILE="/var/log/hostname.log"
|
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
|
# Function to read the hostname from the DHCP lease file
|
||||||
get_hostname() {
|
get_hostname() {
|
||||||
sudo cat /var/lib/dhcp/* | grep -a "option host-name" | tail -1 | \
|
sudo cat /var/lib/dhcp/* | grep -a "option host-name" | tail -1 | \
|
||||||
@@ -13,7 +18,7 @@ update_hosts() {
|
|||||||
local hostname="$1"
|
local hostname="$1"
|
||||||
# Replace the second line with the new hostname
|
# Replace the second line with the new hostname
|
||||||
sudo sed -i "2s/.*/127.0.1.1 ${hostname}/" /etc/hosts
|
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
|
# Read the hostname from DHCP
|
||||||
@@ -22,14 +27,14 @@ hostname=$(get_hostname)
|
|||||||
if [ -n "$hostname" ]; then
|
if [ -n "$hostname" ]; then
|
||||||
# Set the hostname using hostnamectl
|
# Set the hostname using hostnamectl
|
||||||
sudo hostnamectl set-hostname "$hostname"
|
sudo hostnamectl set-hostname "$hostname"
|
||||||
echo "Set hostname to: $hostname" >> $LOGFILE
|
log "Set hostname to: $hostname"
|
||||||
update_hosts "$hostname"
|
update_hosts "$hostname"
|
||||||
else
|
else
|
||||||
echo "No hostname found." >> $LOGFILE
|
log "No hostname found."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Log completion
|
# Log completion
|
||||||
echo "Hostname update script completed." >> $LOGFILE
|
log "Hostname update script completed."
|
||||||
|
|
||||||
# Version 1.0:
|
# 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.
|
||||||
70
data/scripts/overlayRoot.sh
Normal file
70
data/scripts/overlayRoot.sh
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Dieses Skript wird das Root-Dateisystem schreibgeschützt einbinden und es mit einem temporären tmpfs-Overlay versehen.
|
||||||
|
#
|
||||||
|
# Installation:
|
||||||
|
# Kopiere dieses Skript nach /sbin/overlayRoot.sh und füge "init=/sbin/overlayRoot.sh" zur cmdline.txt-Datei
|
||||||
|
# in der Boot-Partition des Raspbian-Images hinzu.
|
||||||
|
#
|
||||||
|
# Führe die folgenden Befehle als root aus:
|
||||||
|
# sudo dphys-swapfile swapoff
|
||||||
|
# sudo dphys-swapfile uninstall
|
||||||
|
# sudo update-rc.d dphys-swapfile remove
|
||||||
|
#
|
||||||
|
# Um Software zu installieren, Upgrades durchzuführen und andere Änderungen an der Raspberry-Konfiguration vorzunehmen,
|
||||||
|
# entferne einfach den Eintrag "init=/sbin/overlayRoot.sh" aus der cmdline.txt-Datei und starte das System neu.
|
||||||
|
# Nimm die gewünschten Änderungen vor, füge den init= Eintrag wieder hinzu und starte erneut neu.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
fail() {
|
||||||
|
echo -e "$1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prüfen und Modul laden
|
||||||
|
modprobe overlay || fail "ERROR: OverlayFS-Modul nicht geladen."
|
||||||
|
|
||||||
|
# /proc einbinden
|
||||||
|
mountpoint -q /proc || mount -t proc proc /proc
|
||||||
|
|
||||||
|
# Temporäres Dateisystem für Overlay erstellen
|
||||||
|
mount -t tmpfs tmpfs /overlay || fail "ERROR: tmpfs konnte nicht gemountet werden."
|
||||||
|
mkdir -p /overlay/lower /overlay/rw/upper /overlay/rw/work /overlay/newroot
|
||||||
|
|
||||||
|
# Root-Dateisystem schreibgeschützt einbinden
|
||||||
|
rootDev=$(awk '$2 == "/" {print $1}' /proc/mounts)
|
||||||
|
rootMountOpt=$(awk '$2 == "/" {print $4}' /proc/mounts)
|
||||||
|
rootFsType=$(awk '$2 == "/" {print $3}' /proc/mounts)
|
||||||
|
|
||||||
|
mount -t "${rootFsType}" -o "${rootMountOpt},ro" "${rootDev}" /overlay/lower || \
|
||||||
|
fail "ERROR: Ursprüngliches Root-Dateisystem konnte nicht schreibgeschützt eingebunden werden."
|
||||||
|
|
||||||
|
# OverlayFS einbinden
|
||||||
|
mount -t overlay \
|
||||||
|
-o lowerdir=/overlay/lower,upperdir=/overlay/rw/upper,workdir=/overlay/rw/work \
|
||||||
|
overlay /overlay/newroot || fail "ERROR: OverlayFS konnte nicht gemountet werden."
|
||||||
|
|
||||||
|
# Neue Root-Overlay-Verzeichnisse erstellen
|
||||||
|
mkdir -p /overlay/newroot/overlay/ro /overlay/newroot/overlay/rw
|
||||||
|
|
||||||
|
# Originale fstab modifizieren
|
||||||
|
grep -v "$rootDev" /overlay/lower/etc/fstab > /overlay/newroot/etc/fstab
|
||||||
|
cat <<EOF >> /overlay/newroot/etc/fstab
|
||||||
|
# Das originale Root-Dateisystem wurde durch overlayRoot.sh entfernt.
|
||||||
|
# Diese änderung ist temporär. Die originale fstab ist in /overlay/ro/etc/fstab verfügbar.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Root wechseln und alte Root aufräumen
|
||||||
|
cd /overlay/newroot
|
||||||
|
pivot_root . overlay || fail "ERROR: pivot_root fehlgeschlagen."
|
||||||
|
|
||||||
|
exec chroot . /bin/bash -c "
|
||||||
|
mount --move /overlay/overlay/lower /overlay/ro || fail 'ERROR: /ro konnte nicht verschoben werden.'
|
||||||
|
mount --move /overlay/overlay/rw /overlay/rw || fail 'ERROR: /rw konnte nicht verschoben werden.'
|
||||||
|
umount /overlay/overlay || true
|
||||||
|
umount /overlay/proc || true
|
||||||
|
umount -l -f /overlay/dev || true
|
||||||
|
umount -l -f /overlay || true
|
||||||
|
|
||||||
|
exec /sbin/init
|
||||||
|
"
|
||||||
44
data/scripts/ramfsRoot.sh
Normal file
44
data/scripts/ramfsRoot.sh
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
echo -e "$1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prüfen, ob genügend RAM frei ist (in KB)
|
||||||
|
RAM_FREE=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
|
||||||
|
if [ "$RAM_FREE" -lt 3000000 ]; then # 3GB als Mindestgrenze
|
||||||
|
fail "Nicht genügend freier RAM!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# RAMFS als neues Root mounten
|
||||||
|
echo "Erstelle RAM-basiertes Root-Dateisystem..."
|
||||||
|
mount -t ramfs -o mode=0755 ramfs /mnt || fail "Fehler beim Mounten von ramfs"
|
||||||
|
|
||||||
|
# Sicherstellen, dass notwendige Verzeichnisse existieren
|
||||||
|
mkdir -p /mnt/{proc,sys,dev,run,tmp}
|
||||||
|
|
||||||
|
# Komplettes Root-Dateisystem nach RAMFS kopieren
|
||||||
|
echo "Kopiere System nach RAM..."
|
||||||
|
cp -ax / /mnt || fail "Fehler beim Kopieren nach RAMFS"
|
||||||
|
|
||||||
|
# Mountpunkte ins neue Root verschieben
|
||||||
|
mount --move /proc /mnt/proc
|
||||||
|
mount --move /sys /mnt/sys
|
||||||
|
mount --move /dev /mnt/dev
|
||||||
|
mount --move /run /mnt/run
|
||||||
|
|
||||||
|
# Wechsle zum neuen Root-FS
|
||||||
|
cd /mnt
|
||||||
|
pivot_root . oldroot || fail "pivot_root fehlgeschlagen"
|
||||||
|
|
||||||
|
# Altes Root unmounten
|
||||||
|
umount -l /oldroot/proc || true
|
||||||
|
umount -l /oldroot/sys || true
|
||||||
|
umount -l /oldroot/dev || true
|
||||||
|
umount -l /oldroot/run || true
|
||||||
|
umount -l /oldroot || true
|
||||||
|
|
||||||
|
# Startet das System normal weiter
|
||||||
|
exec /sbin/init
|
||||||
50
data/scripts/squashfsRoot.sh
Normal file
50
data/scripts/squashfsRoot.sh
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
fail() {
|
||||||
|
echo -e "$1" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Lade SquashFS-Root in den RAM..."
|
||||||
|
|
||||||
|
# Prüfen, ob genügend RAM verfügbar ist
|
||||||
|
RAM_FREE=$(grep MemAvailable /proc/meminfo | awk '{print $2}')
|
||||||
|
if [ "$RAM_FREE" -lt 1000000 ]; then # Mindestens 1GB RAM nötig
|
||||||
|
fail "Nicht genügend freier RAM!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# RAMFS für SquashFS-Image erstellen
|
||||||
|
mount -t ramfs -o mode=0755 ramfs /mnt || fail "Fehler beim Mounten von ramfs"
|
||||||
|
|
||||||
|
# SquashFS-Image nach RAM laden (600-900 MB)
|
||||||
|
cp /root.sqsh /mnt/root.sqsh || fail "Fehler beim Kopieren von SquashFS-Image"
|
||||||
|
|
||||||
|
# SquashFS-Image mounten (Read-Only)
|
||||||
|
mkdir -p /mnt/squashfs
|
||||||
|
mount -t squashfs /mnt/root.sqsh /mnt/squashfs -o loop || fail "Fehler beim Mounten von SquashFS"
|
||||||
|
|
||||||
|
# OverlayFS für Schreibzugriff einrichten
|
||||||
|
mkdir -p /mnt/overlay/{upper,work,newroot}
|
||||||
|
mount -t overlay overlay -o lowerdir=/mnt/squashfs,upperdir=/mnt/overlay/upper,workdir=/mnt/overlay/work /mnt/overlay/newroot || fail "Fehler beim Mounten von OverlayFS"
|
||||||
|
|
||||||
|
# Mountpunkte ins neue Root verschieben
|
||||||
|
mkdir -p /mnt/overlay/newroot/{proc,sys,dev,run,tmp}
|
||||||
|
mount --move /proc /mnt/overlay/newroot/proc
|
||||||
|
mount --move /sys /mnt/overlay/newroot/sys
|
||||||
|
mount --move /dev /mnt/overlay/newroot/dev
|
||||||
|
mount --move /run /mnt/overlay/newroot/run
|
||||||
|
|
||||||
|
# Root wechseln
|
||||||
|
cd /mnt/overlay/newroot
|
||||||
|
pivot_root . oldroot || fail "pivot_root fehlgeschlagen"
|
||||||
|
|
||||||
|
# Altes Root unmounten
|
||||||
|
umount -l /oldroot/proc || true
|
||||||
|
umount -l /oldroot/sys || true
|
||||||
|
umount -l /oldroot/dev || true
|
||||||
|
umount -l /oldroot/run || true
|
||||||
|
umount -l /oldroot || true
|
||||||
|
|
||||||
|
echo "SquashFS Root erfolgreich geladen. Starte init..."
|
||||||
|
exec /sbin/init
|
||||||
99
data/scripts/watchdog-monitor
Normal file
99
data/scripts/watchdog-monitor
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
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
|
||||||
|
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 IPs by comma or space
|
||||||
|
|
||||||
|
# Backup current configuration
|
||||||
|
sudo cp "$config_file" "$config_file.bak"
|
||||||
|
log "Backup of $config_file created successfully."
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# Append IPs to config
|
||||||
|
for ip in "${ip_array[@]}"; do
|
||||||
|
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
|
||||||
|
done
|
||||||
|
log "Configured watchdog to ping: ${ip_array[*]}"
|
||||||
|
|
||||||
|
# Attempt to restart watchdog service
|
||||||
|
if ! sudo systemctl restart watchdog; then
|
||||||
|
log "Failed to restart watchdog service. Attempting to stop and start."
|
||||||
|
|
||||||
|
# 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 start watchdog service after stop."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
log "IP addresses found and watchdog restarted. Exiting loop."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
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
|
||||||
|
log "5 minutes have passed. Stopping the watchdog service."
|
||||||
|
sudo systemctl stop watchdog
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Waiting for $interval seconds before checking for IP addresses again..."
|
||||||
|
sleep $interval
|
||||||
|
done
|
||||||
|
|
||||||
|
# Version 1.5:
|
||||||
|
# Created 2024 by Tim Eertmoed @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom PXE init script.
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=A Service to monitor the Kiosk's current site
|
Description=A Service to monitor the Kiosk's current site
|
||||||
After=network.target getty@tty1.service
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStartPre=-/bin/sleep 10
|
|
||||||
Type=simple
|
Type=simple
|
||||||
User=loginuser
|
User=loginuser
|
||||||
|
ExecStartPre=/bin/bash -c 'pgrep -f chromium-browser > /dev/null || exit 1'
|
||||||
ExecStart=/usr/bin/custom/chromium-monitor
|
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
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
@@ -1,16 +1,10 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Watchdog Monitor Service
|
Description=Watchdog Monitor Service
|
||||||
After=network.target getty@tty1.service
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStartPre=-/bin/sleep 10
|
|
||||||
Type=simple
|
Type=simple
|
||||||
User=loginuser
|
ExecStart=/usr/bin/custom/watchdog-monitor
|
||||||
ExecStart=/usr/bin/watchdog/watchdog
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=5s
|
|
||||||
StandardOutput=append:/var/log/watchdog
|
|
||||||
StandardError=append:/var/log/watchdog
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
@@ -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==
|
|
||||||
208
install.sh
208
install.sh
@@ -11,86 +11,176 @@ print_status() {
|
|||||||
echo -e "${GREEN}✔${NC} ${1} completed."
|
echo -e "${GREEN}✔${NC} ${1} completed."
|
||||||
}
|
}
|
||||||
|
|
||||||
echo -e "${RED}→${NC} Starting System Update..."
|
# Update and setup system and packages
|
||||||
|
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 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 full-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..." | tee -a /var/log/install
|
||||||
|
sudo apt install --no-install-recommends realvnc-vnc-server 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 autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove"
|
sudo apt autoremove -y >>/var/log/install 2>&1 && print_status "Autoremove"
|
||||||
sudo apt clean >>/var/log/install 2>&1 && print_status "Clean"
|
sudo apt clean >>/var/log/install 2>&1 && print_status "Clean"
|
||||||
|
sudo rm -rf /var/lib/apt/lists/* >>/var/log/install 2>&1 && print_status "Clear cache"
|
||||||
|
|
||||||
echo -e "${RED}→${NC} Installing required packages..."
|
echo -e "${RED}→${NC} Configuring Raspberry Pi settings..." | 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"
|
print_status ""
|
||||||
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'..."
|
# Set needed users
|
||||||
|
echo -e "${RED}→${NC} Creating nescessary directorys..." | tee -a /var/log/install
|
||||||
|
sudo mkdir -p /overlay >>/var/log/install 2>&1 && print_status "/overlay created"
|
||||||
|
|
||||||
|
# Set needed users
|
||||||
|
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"
|
sudo adduser --disabled-password --gecos "" loginuser >>/var/log/install 2>&1 && print_status "User 'loginuser' created"
|
||||||
|
|
||||||
echo -e "${RED}→${NC} Setting permissions for 'loginuser'..."
|
# Copy required files
|
||||||
sudo tee /etc/sudoers.d/loginuser >/dev/null << 'EOF'
|
echo -e "${RED}→${NC} Copy requiered files..." | tee -a /var/log/install
|
||||||
loginuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart watchdog, /usr/bin/systemctl restart chromium-monitor
|
sudo mkdir -p /etc/chromium/policies/managed /etc/systemd/system/getty@tty1.service.d /usr/bin/custom
|
||||||
loginuser ALL=(ALL) NOPASSWD: /usr/bin/echo, /usr/bin/cp, /usr/bin/sed
|
declare -A files=(
|
||||||
loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot, /usr/sbin/dhclient eth0, /usr/bin/fbset
|
["/root/rps-client/data/config/config.txt"]="/boot/firmware/config.txt"
|
||||||
loginuser ALL=(ALL) NOPASSWD: /usr/bin/cat /var/lib/dhcp/*
|
["/root/rps-client/data/config/dhclient.conf"]="/etc/dhcp/dhclient.conf"
|
||||||
EOF
|
["/root/rps-client/data/config/override.conf"]="/etc/systemd/system/getty@tty1.service.d/override.conf"
|
||||||
sudo usermod -aG video loginuser >>/var/log/install 2>&1 && print_status "Permissions for 'loginuser' set"
|
["/root/rps-client/data/config/disable_password_saving.json"]="/etc/chromium/policies/managed/disable_password_saving.json"
|
||||||
|
["/root/rps-client/data/config/.bash_profile"]="/home/loginuser/.bash_profile"
|
||||||
|
["/root/rps-client/data/config/.xinitrc"]="/home/loginuser/.xinitrc"
|
||||||
|
["/root/rps-client/data/scripts/overlayRoot.sh"]="/sbin/overlayRoot.sh"
|
||||||
|
["/root/rps-client/data/scripts/ramfsRoot.sh"]="/sbin/ramfsRoot.sh"
|
||||||
|
["/root/rps-client/data/scripts/squashfsRoot.sh"]="/sbin/squashfsRoot.sh"
|
||||||
|
["/root/rps-client/data/scripts/remove_unused_kernel.sh"]="/root/remove_unused_kernel.sh"
|
||||||
|
["/root/rps-client/data/scripts/hostname"]="/usr/bin/custom/hostname"
|
||||||
|
["/root/rps-client/data/scripts/chromium-monitor"]="/usr/bin/custom/chromium-monitor"
|
||||||
|
["/root/rps-client/data/scripts/watchdog-monitor"]="/usr/bin/custom/watchdog-monitor"
|
||||||
|
["/root/rps-client/data/service/hostname.service"]="/etc/systemd/system/hostname.service"
|
||||||
|
["/root/rps-client/data/service/watchdog-monitor.service"]="/etc/systemd/system/watchdog-monitor.service"
|
||||||
|
["/root/rps-client/data/service/chromium-monitor.service"]="/etc/systemd/system/chromium-monitor.service"
|
||||||
|
)
|
||||||
|
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} Disabling root login..."
|
# Set 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"
|
||||||
|
sudo chmod +x /usr/bin/custom/hostname /usr/bin/custom/chromium-monitor /usr/bin/custom/watchdog-monitor /sbin/overlayRoot.sh /sbin/ramfsRoot.sh >>/var/log/install 2>&1 && print_status "Permissions for script files set"
|
||||||
|
sudo usermod -aG video loginuser >>/var/log/install 2>&1 && print_status "Permissions for 'loginuser' set"
|
||||||
|
echo -e "${RED}→${NC} Setting permissions for 'loginuser'..." | tee -a /var/log/install
|
||||||
|
sudo tee /etc/sudoers.d/loginuser >>/var/log/install 2>&1 <<'EOF' \
|
||||||
|
&& print_status "Sudo rights for 'loginuser' set"
|
||||||
|
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
|
||||||
|
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
|
||||||
|
loginuser ALL=(ALL) NOPASSWD: /usr/sbin/reboot
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Setze TCP-Keepalive
|
||||||
|
echo "net.ipv4.tcp_keepalive_time = 60" >> /etc/sysctl.conf
|
||||||
|
echo "net.ipv4.tcp_keepalive_intvl = 10" >> /etc/sysctl.conf
|
||||||
|
echo "net.ipv4.tcp_keepalive_probes = 6" >> /etc/sysctl.conf
|
||||||
|
|
||||||
|
# Disable root
|
||||||
|
echo -e "${RED}→${NC} Disabling root login..." | tee -a /var/log/install
|
||||||
sudo tee /etc/ssh/sshd_config >/dev/null << 'EOF'
|
sudo tee /etc/ssh/sshd_config >/dev/null << 'EOF'
|
||||||
PermitRootLogin no
|
PermitRootLogin no
|
||||||
EOF
|
EOF
|
||||||
sudo passwd -l root >>/var/log/install 2>&1 && print_status "Root login disabled"
|
sudo passwd -l root >>/var/log/install 2>&1 && print_status "Root login disabled"
|
||||||
|
|
||||||
echo -e "${RED}→${NC} Copying required files..."
|
# Setup logs
|
||||||
sudo rsync -a --numeric-ids --info=progress2 --no-owner --no-group \
|
echo -e "${RED}→${NC} Creating log files..." | tee -a /var/log/install
|
||||||
./rps-client/boot/ro-root.sh /boot/ro-root.sh \
|
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"
|
||||||
./rps-client/boot/firmware/ro-root.sh /boot/firmware/ro-root.sh \
|
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"
|
||||||
./rps-client/etc/dhcp/dhclient.conf /etc/dhcp/dhclient.conf \
|
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"
|
||||||
./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/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..."
|
# Configure services
|
||||||
sudo chown loginuser:loginuser -R /home/loginuser >>/var/log/install 2>&1 && print_status "File permissions set"
|
echo -e "${RED}→${NC} Configure services..." | tee -a /var/log/install
|
||||||
|
|
||||||
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 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 chromium-monitor getty@tty1 >>/var/log/install 2>&1 && print_status "Services enabled"
|
||||||
|
sudo systemctl disable watchdog >>/var/log/install 2>&1 && print_status "Watchdog disabled"
|
||||||
sudo systemctl restart getty@tty1 >>/var/log/install 2>&1 && print_status "getty service restarted"
|
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):"
|
# Set performance
|
||||||
read -r clean_kernels
|
echo -e "${RED}→${NC} Configure performance teaks..." | tee -a /var/log/install
|
||||||
if [[ "$clean_kernels" =~ ^[Yy](e[Ss]?)?$ ]]; then
|
echo "performance" | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor >>/var/log/install 2>&1 && print_status "CPU set to high"
|
||||||
echo -e "${RED}→${NC} Cleaning up unused kernels..."
|
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target >>/var/log/install 2>&1 && print_status "Powercfg off"
|
||||||
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..."
|
# Clean
|
||||||
|
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"
|
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..."
|
# Configure VNC-Client
|
||||||
|
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
|
||||||
|
sudo mkdir -p "$(dirname "$CONFIG_FILE")"
|
||||||
|
echo -e "${GREEN}✔${NC} Created directory for VNC config." | tee -a /var/log/install
|
||||||
|
fi
|
||||||
|
echo -e "${RED}→${NC} Do you want to set a VNC password? (y/n):" | tee -a /var/log/install
|
||||||
|
read -r config_vnc
|
||||||
|
if [[ "$config_vnc" =~ ^[Yy](e[Ss]?)?$ ]]; then
|
||||||
|
sudo vncpasswd
|
||||||
|
echo -e "${GREEN}✔${NC} VNC password has been set." | tee -a /var/log/install
|
||||||
|
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 "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=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 password is set. Authentication will be required." >> /var/log/install 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove old kernels
|
||||||
|
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..." | tee -a /var/log/install
|
||||||
|
echo -e "y\ny" | 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
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Create squashfs
|
||||||
|
#echo -e "${RED}→${NC} Do you want to create a squashfs image of the system and copy it to the server? (y/n):" | tee -a /var/log/install
|
||||||
|
#read -r create_squash
|
||||||
|
#if [[ "$create_squash" =~ ^[Yy](e[Ss]?)?$ ]]; then
|
||||||
|
# echo -e "${RED}→${NC} Creating squashfs image..." | tee -a /var/log/install
|
||||||
|
# SQUASH_IMAGE="/tmp/rootfs.squashfs"
|
||||||
|
# SERVER_IP="192.168.120.239"
|
||||||
|
# SERVER_DIR="/nfs/live/rootfs"
|
||||||
|
# sudo mksquashfs / "$SQUASH_IMAGE" -e boot dev proc sys tmp run media mnt lost+found var/log >>/var/log/install 2>&1 && print_status "SquashFS created"
|
||||||
|
# echo -e "${RED}→${NC} Copying squashfs image to NFS server..." | tee -a /var/log/install
|
||||||
|
# sudo rsync -avh "$SQUASH_IMAGE" "$SERVER_IP:$SERVER_DIR" >>/var/log/install 2>&1 && print_status "SquashFS copied to server"
|
||||||
|
# sudo rm "$SQUASH_IMAGE" >>/var/log/install 2>&1 && print_status "Temporary squashfs file removed"
|
||||||
|
#else
|
||||||
|
# echo -e "${GREEN}✔${NC} SquashFS creation skipped." | tee -a /var/log/install
|
||||||
|
#fi
|
||||||
|
|
||||||
|
|
||||||
|
# Finish
|
||||||
|
echo -e "${GREEN}✔${NC} Installation complete. Press any key to exit..." | tee -a /var/log/install 2>&1
|
||||||
read -n 1 -s
|
read -n 1 -s
|
||||||
sudo reboot
|
|
||||||
|
|
||||||
# Version 1.2:
|
# 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.
|
||||||
@@ -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==
|
|
||||||
@@ -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.
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#!/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." >> $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
|
|
||||||
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.
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
|
|
||||||
# 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
|
|
||||||
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
|
|
||||||
|
|
||||||
# Version 1.1:
|
|
||||||
# Created 2024 by Tim Eertmoed @ WiS IT-Solutions GmbH, Germany to work on Raspian as custom pxe init script.
|
|
||||||
Reference in New Issue
Block a user