Compare commits
3 Commits
v0.0.15
...
4904589086
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4904589086 | ||
|
|
6f7e149c9a | ||
|
|
df344b4c13 |
@@ -113,23 +113,23 @@ jobs:
|
|||||||
echo "PORT=8080" > $BUILD_DIR/usr/share/$PKG_NAME/.env.template
|
echo "PORT=8080" > $BUILD_DIR/usr/share/$PKG_NAME/.env.template
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5. Create the systemd Service File
|
# 5. Create a Template Autostart File (Instead of Systemd)
|
||||||
cat <<EOF > $BUILD_DIR/etc/systemd/system/$PKG_NAME.service
|
mkdir -p $BUILD_DIR/usr/share/$PKG_NAME/setup
|
||||||
[Unit]
|
cat <<EOF > $BUILD_DIR/usr/share/$PKG_NAME/setup/$PKG_NAME.desktop
|
||||||
Description=Slideshow Application Service
|
[Desktop Entry]
|
||||||
After=graphical.target
|
Type=Application
|
||||||
|
Name=Slideshow App
|
||||||
[Service]
|
Exec=sh -c ' \
|
||||||
Type=simple
|
i=0; \
|
||||||
Environment=DISPLAY=:0
|
while [ $i -lt 30 ]; do \
|
||||||
Environment=XAUTHORITY=/home/youruser/.Xauthority
|
if [ "$(ls -A "/media/$REAL_USER" 2>/dev/null)" ] && ping -c 1 -W 1 8.8.8.8 >/dev/null 2>&1; then \
|
||||||
ExecStart=/usr/bin/$PKG_NAME
|
break; \
|
||||||
WorkingDirectory=/usr/share/$PKG_NAME
|
fi; \
|
||||||
Restart=always
|
i=$((i+1)); \
|
||||||
User=root
|
sleep 1; \
|
||||||
|
done; \
|
||||||
[Install]
|
cd /usr/share/slideshowapp && /usr/bin/slideshowapp'
|
||||||
WantedBy=multi-user.target
|
Terminal=false
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 6. Create Control File
|
# 6. Create Control File
|
||||||
@@ -139,28 +139,60 @@ jobs:
|
|||||||
Section: utils
|
Section: utils
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: $ARCH
|
Architecture: $ARCH
|
||||||
Maintainer: Your Name <you@example.com>
|
Maintainer: Adrian Zuercher <zuercher@tecamino.ch>
|
||||||
Description: Slideshow Application
|
Description: Slideshow Application
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 7. Optional: Add post-install script to enable service automatically
|
# 7. Add post-install script for Autostart and Permissions
|
||||||
echo "create service"
|
cat <<'EOF' > $BUILD_DIR/DEBIAN/postinst
|
||||||
cat <<EOF > $BUILD_DIR/DEBIAN/postinst
|
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Check if .env exists in the target share folder
|
set -e # Exit on error
|
||||||
if [ ! -f "/usr/share/$PKG_NAME/.env" ]; then
|
|
||||||
echo "Creating new .env from template..."
|
# 1. Detect the real user
|
||||||
cp /usr/share/$PKG_NAME/.env.template /usr/share/$PKG_NAME/.env
|
# We use 'who' and 'awk' as a fallback because $SUDO_USER is sometimes empty in Gitea/CI environments
|
||||||
else
|
REAL_USER=${SUDO_USER:-$(who | awk '{print $1}' | head -n1)}
|
||||||
echo ".env already exists, skipping template copy to preserve settings."
|
|
||||||
|
# If still empty, default to 'mst' or 'pi' (adjust to your primary user)
|
||||||
|
if [ -z "$REAL_USER" ] || [ "$REAL_USER" = "root" ]; then
|
||||||
|
REAL_USER="mst"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "reload"
|
USER_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6)
|
||||||
systemctl daemon-reload
|
|
||||||
echo "enable service"
|
echo "Post-install: Target user is $REAL_USER"
|
||||||
systemctl enable $PKG_NAME.service
|
echo "Post-install: Target home is $USER_HOME"
|
||||||
echo "start service"
|
|
||||||
systemctl start $PKG_NAME.service
|
# 2. Setup .env from template
|
||||||
|
if [ ! -f "/usr/share/slideshowapp/.env" ]; then
|
||||||
|
echo "Creating .env from template..."
|
||||||
|
cp /usr/share/slideshowapp/env.template /usr/share/slideshowapp/.env || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Setup Autostart (THE FIX)
|
||||||
|
# We use -p to ensure parent directories exist and set ownership immediately
|
||||||
|
AUTOSTART_DIR="$USER_HOME/.config/autostart"
|
||||||
|
|
||||||
|
if [ -d "$USER_HOME" ]; then
|
||||||
|
echo "Creating autostart directory at $AUTOSTART_DIR"
|
||||||
|
mkdir -p "$AUTOSTART_DIR"
|
||||||
|
cp /usr/share/slideshowapp/setup/slideshowapp.desktop "$AUTOSTART_DIR/"
|
||||||
|
|
||||||
|
# Critical: Change ownership of the folder and the file
|
||||||
|
chown -R "$REAL_USER:$REAL_USER" "$USER_HOME/.config"
|
||||||
|
chmod 644 "$AUTOSTART_DIR/slideshowapp.desktop"
|
||||||
|
else
|
||||||
|
echo "ERROR: Home directory $USER_HOME not found. Autostart not configured."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. Fix Chromium Profile Permissions
|
||||||
|
if [ -d "$USER_HOME/.config/chromium" ]; then
|
||||||
|
echo "Cleaning up Chromium locks for $REAL_USER..."
|
||||||
|
chown -R "$REAL_USER:$REAL_USER" "$USER_HOME/.config/chromium"
|
||||||
|
rm -f "$USER_HOME/.config/chromium/SingletonLock"
|
||||||
|
rm -f "$USER_HOME/.config/chromium/SingletonCookie"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installation complete."
|
||||||
EOF
|
EOF
|
||||||
chmod 555 $BUILD_DIR/DEBIAN/postinst
|
chmod 555 $BUILD_DIR/DEBIAN/postinst
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user