Files
raspscreen/install.sh

71 lines
2.0 KiB
Bash
Raw Normal View History

2026-01-09 17:01:49 +01:00
#!/bin/bash
2026-01-15 16:48:03 +01:00
program_name="raspscreen"
2026-01-09 17:01:49 +01:00
runtime_id=$(id -u)
userland_name="${1-systemec}"
# Check if the user is right (root) for the program
2026-01-09 17:01:49 +01:00
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
2026-01-12 16:28:52 +01:00
mkdir -p /home/${userland_name}/.config/systemd/user -m 755
fi
# Create the program place onto /opt
if [[ ! -d /opt/${program_name} ]]; then
2026-01-14 16:21:48 +01:00
mkdir -p /opt/${program_name}/media -m 755
2026-01-13 10:49:20 +01:00
fi
cat > /home/${userland_name}/.config/systemd/user/presentation.service << EOF
[Unit]
Description="Systemec RaspScreen"
Conflicts=video.service
2026-01-13 10:49:20 +01:00
After=graphical.target
[Service]
Type=simple
Environment=DISPLAY=:0
2026-01-15 16:48:03 +01:00
WorkingDirectory=/opt/raspscreen
2026-01-14 16:23:31 +01:00
ExecStartPre=/usr/bin/sleep 5
2026-01-15 16:48:03 +01:00
ExecStart=/bin/sh -c 'exec /usr/bin/libreoffice --impress --show --norestore \$(find /opt/raspscreen/media \( -name "*.pptx" -o -name "*.odp" \))'
2026-01-13 10:49:20 +01:00
ExecStop=/usr/bin/killall libreoffice
Restart=always
Restart=on-failure
RestartSec=2
[Install]
WantedBy=default.target
EOF
cat > /home/${userland_name}/.config/systemd/user/video.service << EOF
[Unit]
Description="Systemec RaspScreen"
Conflicts=presentation.service
2026-01-13 10:49:20 +01:00
After=graphical.target
[Service]
Type=simple
Environment=DISPLAY=:0
2026-01-15 16:48:03 +01:00
WorkingDirectory=/opt/raspscreen
2026-01-14 16:23:31 +01:00
ExecStartPre=/usr/bin/sleep 5
2026-01-15 16:48:03 +01:00
ExecStart=/bin/sh -c 'exec /usr/bin/vlc --fullscreen --loop --no-video-title --video-on-top --no-qt-privacy-ask --no-qt-fs-controller --qt-continue=0 \$(find /opt/raspscreen/media \( -name "*.mp4" -o -name "*.mkv" -o -name "*.mov" -o -name "*.webm" \))'
2026-01-13 10:49:20 +01:00
ExecStop=/usr/bin/killall vlc
Restart=always
Restart=on-failure
RestartSec=2
[Install]
WantedBy=default.target
EOF
chown -Rv ${userland_name}:${userland_name} /home/${userland_name}/.config/systemd
2026-02-03 14:12:47 +00:00
chown -Rv ${userland_name}:${userland_name} /opt/${program_name}
echo "Self-destruction NOW!"
rm $(pwd)/$0