Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1ae34a336 |
@@ -79,7 +79,7 @@ jobs:
|
|||||||
export GOARM=${{ matrix.arm_version }}
|
export GOARM=${{ matrix.arm_version }}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OUTPUT="${OUTPUT}"
|
OUTPUT="${OUTPUT}${{ matrix.ext }}"
|
||||||
echo "Building $OUTPUT"
|
echo "Building $OUTPUT"
|
||||||
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT"
|
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT"
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -105,7 +105,31 @@ jobs:
|
|||||||
cp -r ./web $BUILD_DIR/usr/share/$PKG_NAME/
|
cp -r ./web $BUILD_DIR/usr/share/$PKG_NAME/
|
||||||
chmod +x $BUILD_DIR/usr/bin/$PKG_NAME
|
chmod +x $BUILD_DIR/usr/bin/$PKG_NAME
|
||||||
|
|
||||||
# 4. Create Control File
|
# 4. Handle .env (Copy as a .template so it doesn't overwrite existing ones)
|
||||||
|
if [ -f ".env" ]; then
|
||||||
|
cp .env $BUILD_DIR/usr/share/$PKG_NAME/.env.template
|
||||||
|
else
|
||||||
|
echo "PORT=8080" > $BUILD_DIR/usr/share/$PKG_NAME/.env.template
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 5. Create the systemd Service File
|
||||||
|
cat <<EOF > $BUILD_DIR/etc/systemd/system/$PKG_NAME.service
|
||||||
|
[Unit]
|
||||||
|
Description=Slideshow Application Service
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/$PKG_NAME
|
||||||
|
WorkingDirectory=/usr/share/$PKG_NAME
|
||||||
|
Restart=always
|
||||||
|
User=root
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 6. Create Control File
|
||||||
cat <<EOF > $BUILD_DIR/DEBIAN/control
|
cat <<EOF > $BUILD_DIR/DEBIAN/control
|
||||||
Package: $PKG_NAME
|
Package: $PKG_NAME
|
||||||
Version: $VERSION
|
Version: $VERSION
|
||||||
@@ -116,7 +140,28 @@ jobs:
|
|||||||
Description: Slideshow Application
|
Description: Slideshow Application
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 5. Build .deb
|
# 7. Optional: Add post-install script to enable service automatically
|
||||||
|
echo "create service"
|
||||||
|
cat <<EOF > $BUILD_DIR/DEBIAN/postinst
|
||||||
|
#!/bin/sh
|
||||||
|
# Check if .env exists in the target share folder
|
||||||
|
if [ ! -f "/usr/share/$PKG_NAME/.env" ]; then
|
||||||
|
echo "Creating new .env from template..."
|
||||||
|
cp /usr/share/$PKG_NAME/.env.template /usr/share/$PKG_NAME/.env
|
||||||
|
else
|
||||||
|
echo ".env already exists, skipping template copy to preserve settings."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "reload"
|
||||||
|
systemctl daemon-reload
|
||||||
|
echo "enable service"
|
||||||
|
systemctl enable $PKG_NAME.service
|
||||||
|
echo "start service"
|
||||||
|
systemctl start $PKG_NAME.service
|
||||||
|
EOF
|
||||||
|
chmod 555 $BUILD_DIR/DEBIAN/postinst
|
||||||
|
|
||||||
|
# 8. Build .deb
|
||||||
dpkg-deb --build $BUILD_DIR
|
dpkg-deb --build $BUILD_DIR
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user