From 942f1205174b784e8dee1d80b99fdd951c6b833e Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Tue, 9 Jun 2026 01:20:47 +0530 Subject: Deb package - Made service to automatically start during install --- .../package/DEBIAN/postinst | 47 +++++++++++++--------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'linux/deb/02-fs-spring-boot-kamal/package/DEBIAN/postinst') diff --git a/linux/deb/02-fs-spring-boot-kamal/package/DEBIAN/postinst b/linux/deb/02-fs-spring-boot-kamal/package/DEBIAN/postinst index 430ba0a..67fffe0 100755 --- a/linux/deb/02-fs-spring-boot-kamal/package/DEBIAN/postinst +++ b/linux/deb/02-fs-spring-boot-kamal/package/DEBIAN/postinst @@ -28,21 +28,32 @@ chmod 750 /etc/fs-spring-boot-kamal chmod 640 /etc/fs-spring-boot-kamal/application.yaml chmod 640 /etc/fs-spring-boot-kamal/environment.env -# Reload systemd service configurations -systemctl daemon-reload - -# Enable service as boot time -#systemctl enable fs-spring-boot-kamal - -# Restart service -#systemctl restart fs-spring-boot-kamal - -echo "[INFO] fs-spring-boot-kamal service installed." -echo "[INFO] Update /etc/fs-spring-boot-kamal/application.yaml to update the configuration." -echo "[INFO] By default, TCP port 8085 is used by the installed server." -echo "[INFO] To enable service start at boot time:" -echo "[INFO] systemctl enable fs-spring-boot-kamal" -echo "[INFO] To start the service if not running:" -echo "[INFO] systemctl start fs-spring-boot-kamal" -echo "[INFO] To allow access from remote systems, you may have to enable firewall for example by running:" -echo "[INFO] ufw allow 8085/tcp" +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + if [ -d /run/systemd/system ]; then + # Reload systemd service configurations + systemctl daemon-reload > /dev/null || true + + if [ -n "$2" ]; then + # Upgrade + # Restart service + if systemctl is-enabled fs-spring-boot-kamal > /dev/null; then + systemctl start fs-spring-boot-kamal + fi + else + # First install (not upgrade) + # Enable service to start at boot time + systemctl enable fs-spring-boot-kamal + # Start service + systemctl start fs-spring-boot-kamal + fi + fi +fi + +if [ "$1" == "configure" ] && [ -z "$2" ]; then + # Code here executes only during package install (but not during upgrade) + echo "[INFO] fs-spring-boot-kamal service installed." + echo "[INFO] Update /etc/fs-spring-boot-kamal/application.yaml to update the configuration." + echo "[INFO] By default, TCP port 8085 is used by the installed server." + echo "[INFO] To allow access from remote systems, you may have to enable firewall for example by running:" + echo "[INFO] ufw allow 8085/tcp" +fi -- cgit v1.2.3