Update Deploy Script to create user, set user to auto-login and run kiosk mode on startup

This commit is contained in:
Chris 2025-05-23 20:37:09 +01:00
parent 72cf9a8146
commit 2adad16737

View File

@ -4,30 +4,79 @@ set -e
echo "🚀 Starting kiosk deployment..."
REPO_DIR="/home/chris/projects/ClubhouseDisplays"
SYSTEMD_DIR="/etc/systemd/system"
#REPO_DIR="/home/chris/projects/ClubhouseDisplays"
#SYSTEMD_DIR="/etc/systemd/system"
KIOSK_USER="kiosk-user"
KIOSK_USER_PASS="UckfieldRfc1954!"
KIOSK_URL="https://www.bbc.co.uk"
#!/bin/bash
# Create user if doesn't exist
if ! id -u "$KIOSK_USER" >/dev/null 2>&1; then
echo "Creating user: $KIOSK_USER"
sudo adduser --gecos "Kiosk User" --disabled-password "$KIOSK_USER"
echo "$KIOSK_USER:$KIOSK_USER_PASS" | sudo chpasswd
else
echo "User $KIOSK_USER already exists. Skipping creation."
fi
# Set up auto login
cat << EOF > /etc/gdm3/custom.conf
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=$KIOSK_USER
EOF
# Create the autostart directory if it doesn't exist
mkdir -p /home/$KIOSK_USER/.config/autostart
# Create a startup script for Firefox
cat << EOF > /home/$KIOSK_USER/.config/autostart/firefox.desktop
[Desktop Entry]
Type=Application
Exec=firefox -kiosk $KIOSK_URL
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=Firefox
Name=Firefox
Comment[en_US]=
Comment=
EOF
# Set the correct permissions for the startup script
sudo chmod 755 /home/$KIOSK_USER/.config/autostart/firefox.desktop
sudo chown -R $KIOSK_USER:$KIOSK_USER /home/$KIOSK_USER/.config
echo "🎉 Deployment complete! Rebooting..."
sleep 10
# Reboot the system
sudo reboot
# Make sure we are in the repo directory
cd "$REPO_DIR" || { echo "❌ Repo directory not found at $REPO_DIR"; exit 1; }
#cd "$REPO_DIR" || { echo "❌ Repo directory not found at $REPO_DIR"; exit 1; }
# Make scripts executable
chmod +x start-kiosk.sh
chmod +x update-kiosk.sh
#chmod +x start-kiosk.sh
#chmod +x update-kiosk.sh
# Copy and install kiosk service
sudo cp kiosk.service "$SYSTEMD_DIR/"
sudo systemctl enable --now kiosk.service
#sudo cp kiosk.service "$SYSTEMD_DIR/"
#sudo systemctl enable --now kiosk.service
# Copy and install update service and timer
sudo cp update-kiosk.service "$SYSTEMD_DIR/"
sudo cp update-kiosk.timer "$SYSTEMD_DIR/"
sudo systemctl daemon-reexec
sudo systemctl enable --now update-kiosk.timer
#sudo cp update-kiosk.service "$SYSTEMD_DIR/"
#sudo cp update-kiosk.timer "$SYSTEMD_DIR/"
#sudo systemctl daemon-reexec
#sudo systemctl enable --now update-kiosk.timer
echo "✅ Kiosk service and update timer are set up and running!"
#echo "✅ Kiosk service and update timer are set up and running!"
# Optional: show status
sudo systemctl status kiosk.service --no-pager
sudo systemctl status update-kiosk.timer --no-pager
#sudo systemctl status kiosk.service --no-pager -l
# sudo systemctl status update-kiosk.timer --no-pager -l
echo "🎉 Deployment complete!"