Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df344b4c13 | ||
|
|
d82f213ca7 |
6
.env
6
.env
@@ -1,6 +1,8 @@
|
|||||||
ENV= #empty|development|debug
|
#empty|development|debug
|
||||||
|
ENV=
|
||||||
PHOTO_DIR=images
|
PHOTO_DIR=images
|
||||||
HOST=0.0.0.0
|
HOST=0.0.0.0
|
||||||
PORT=8080
|
PORT=8080
|
||||||
INTERVAL_DEFAULT=10
|
INTERVAL_DEFAULT=10
|
||||||
LOG_PATH= #path for logger files default .
|
#path for logger files default {executable name}.log
|
||||||
|
LOG_PATH=
|
||||||
@@ -113,23 +113,15 @@ 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=/usr/bin/$PKG_NAME
|
||||||
Type=simple
|
|
||||||
Environment=DISPLAY=:0
|
|
||||||
Environment=XAUTHORITY=/home/youruser/.Xauthority
|
|
||||||
ExecStart=/usr/bin/$PKG_NAME
|
|
||||||
WorkingDirectory=/usr/share/$PKG_NAME
|
WorkingDirectory=/usr/share/$PKG_NAME
|
||||||
Restart=always
|
Terminal=false
|
||||||
User=root
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 6. Create Control File
|
# 6. Create Control File
|
||||||
@@ -139,28 +131,44 @@ 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
|
# 1. Detect the real user (the one who ran sudo)
|
||||||
if [ ! -f "/usr/share/$PKG_NAME/.env" ]; then
|
REAL_USER=\$SUDO_USER
|
||||||
echo "Creating new .env from template..."
|
if [ -z "\$REAL_USER" ]; then
|
||||||
cp /usr/share/$PKG_NAME/.env.template /usr/share/$PKG_NAME/.env
|
REAL_USER=\$(logname 2>/dev/null || echo "pi")
|
||||||
else
|
|
||||||
echo ".env already exists, skipping template copy to preserve settings."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "reload"
|
USER_HOME=\$(getent passwd "\$REAL_USER" | cut -d: -f6)
|
||||||
systemctl daemon-reload
|
|
||||||
echo "enable service"
|
echo "Installing for user: \$REAL_USER in \$USER_HOME"
|
||||||
systemctl enable $PKG_NAME.service
|
|
||||||
echo "start service"
|
# 2. Setup .env from template
|
||||||
systemctl start $PKG_NAME.service
|
if [ ! -f "/usr/share/$PKG_NAME/.env" ]; then
|
||||||
|
cp /usr/share/$PKG_NAME/.env.template /usr/share/$PKG_NAME/.env
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Setup Autostart for the graphical desktop
|
||||||
|
AUTOSTART_DIR="\$USER_HOME/.config/autostart"
|
||||||
|
mkdir -p "\$AUTOSTART_DIR"
|
||||||
|
cp /usr/share/$PKG_NAME/setup/$PKG_NAME.desktop "\$AUTOSTART_DIR/"
|
||||||
|
|
||||||
|
# 4. Fix Chromium Profile Permissions (Resolves the 'Profile Error')
|
||||||
|
# This ensures the standard user can write to their own config
|
||||||
|
if [ -d "\$USER_HOME/.config/chromium" ]; then
|
||||||
|
chown -R \$REAL_USER:\$REAL_USER "\$USER_HOME/.config/chromium"
|
||||||
|
rm -f "\$USER_HOME/.config/chromium/SingletonLock"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 5. Set correct ownership for the autostart file
|
||||||
|
chown -R \$REAL_USER:\$REAL_USER "\$AUTOSTART_DIR/$PKG_NAME.desktop"
|
||||||
|
|
||||||
|
echo "Installation complete. The app will start on the next Desktop login."
|
||||||
EOF
|
EOF
|
||||||
chmod 555 $BUILD_DIR/DEBIAN/postinst
|
chmod 555 $BUILD_DIR/DEBIAN/postinst
|
||||||
|
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
images/
|
images/
|
||||||
slideshowApp
|
slideshowApp
|
||||||
schedule.json
|
schedule.json
|
||||||
|
*.log
|
||||||
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module slideshowApp
|
|||||||
go 1.25.4
|
go 1.25.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.tecamino.com/paadi/tecamino-logger v1.0.0
|
gitea.tecamino.com/paadi/tecamino-logger v1.0.1
|
||||||
github.com/gorilla/mux v1.8.1
|
github.com/gorilla/mux v1.8.1
|
||||||
github.com/gorilla/websocket v1.5.3
|
github.com/gorilla/websocket v1.5.3
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.5.1
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -1,5 +1,5 @@
|
|||||||
gitea.tecamino.com/paadi/tecamino-logger v1.0.0 h1:Quk0UJerOCy7xbHWYOuBXk0FQIgx4arjVDMt2ahvaO0=
|
gitea.tecamino.com/paadi/tecamino-logger v1.0.1 h1:NCF/foyuf0wVKLkyy2y1FYvHo9pVaUuHc1GSU5bNVbc=
|
||||||
gitea.tecamino.com/paadi/tecamino-logger v1.0.0/go.mod h1:FkzRTldUBBOd/iy2upycArDftSZ5trbsX5Ira5OzJgM=
|
gitea.tecamino.com/paadi/tecamino-logger v1.0.1/go.mod h1:FkzRTldUBBOd/iy2upycArDftSZ5trbsX5Ira5OzJgM=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||||
|
|||||||
5
main.go
5
main.go
@@ -18,6 +18,8 @@ var staticFolder = "./web/static/"
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
env.Load(".env")
|
||||||
|
|
||||||
logConfig := logging.DefaultConfig()
|
logConfig := logging.DefaultConfig()
|
||||||
logConfig.Debug = env.Env.GetValue() == "debug"
|
logConfig.Debug = env.Env.GetValue() == "debug"
|
||||||
|
|
||||||
@@ -26,9 +28,6 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("main", "load enviroment variable")
|
|
||||||
env.Load(".env")
|
|
||||||
|
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
|
|
||||||
uploadFolder := env.PhotoDir.GetValue()
|
uploadFolder := env.PhotoDir.GetValue()
|
||||||
|
|||||||
Reference in New Issue
Block a user