Files
raspscreen/install.sh
DaanSelen 66cc9dae97
All checks were successful
Cross-Compile Binaries / compile-linux (push) Successful in 3m50s
Cross-Compile Binaries / compile-windows (push) Successful in 9m42s
feat: account for post-reboot
2026-02-05 16:22:18 +01:00

71 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
program_name="raspscreen"
runtime_id=$(id -u)
userland_name="${1-systemec}"
# Check if the user is right (root) for the program
if [[ "$runtime_id" -ne 0 ]]; then
echo "Not running as root, please run as root."
exit 1
fi
apt-get -y install \
default-jre libreoffice-impress libreoffice-java-common psmisc ssh vlc
systemctl enable --now ssh
# Create the systemd userland folder
if [[ ! -d /home/${userland_name}/.config/systemd/user ]]; then
mkdir -p /home/${userland_name}/.config/systemd/user -m 755
fi
# Create the program place onto /opt
if [[ ! -d /opt/${program_name} ]]; then
mkdir -p /opt/${program_name}/media -m 755
fi
# THIS MUST BE THE SAME AR $REPO/service-files/presentation.service
cat > /home/${userland_name}/.config/systemd/user/presentation.service << EOF
[Unit]
Description="Systemec RaspScreen Presentation"
Conflicts=video.service
After=graphical-session.target
[Service]
Type=simple
Environment=DISPLAY=:0
WorkingDirectory=/opt/raspscreen
ExecStart=/opt/raspscreen/bin/manage.sh start presentation --foreground
KillSignal=SIGKILL
Restart=on-failure
RestartSec=2
[Install]
WantedBy=default.target
EOF
# THIS MUST BE THE SAME AR $REPO/service-files/video.service
cat > /home/${userland_name}/.config/systemd/user/video.service << EOF
[Unit]
Description="Systemec RaspScreen Video"
Conflicts=presentation.service
After=graphical-session.target
[Service]
Type=simple
Environment=DISPLAY=:0
WorkingDirectory=/opt/raspscreen
ExecStart=/opt/raspscreen/bin/manage.sh start video --foreground
KillSignal=SIGKILL
Restart=on-failure
RestartSec=2
[Install]
WantedBy=default.target
EOF
chown -Rv ${userland_name}:${userland_name} /home/${userland_name}/.config/systemd
chown -Rv ${userland_name}:${userland_name} /opt/${program_name}
echo "Self-destruction NOW!"
rm $(pwd)/$0