Files
raspscreen/install.sh
DaanSelen a77e59929a
Some checks failed
Cross-Compile Binaries / compile-linux (push) Failing after 4m53s
Cross-Compile Binaries / compile-windows (push) Failing after 8m42s
chore: working
2026-02-04 16:31:47 +01:00

73 lines
1.9 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 libreoffice-impress 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.target
[Service]
Type=simple
Environment=DISPLAY=:0
WorkingDirectory=/opt/raspscreen
ExecStartPre=/usr/bin/sleep 5
ExecStart=/opt/raspscreen/bin/manage.sh start presentation --foreground
ExecStop=/opt/raspscreen/bin/manage kill video
Restart=always
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.target
[Service]
Type=simple
Environment=DISPLAY=:0
WorkingDirectory=/opt/raspscreen
ExecStartPre=/usr/bin/sleep 5
ExecStart=/opt/raspscreen/bin/manage.sh start video --foreground
ExecStop=/opt/raspscreen/bin/manage kill video
Restart=always
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