summaryrefslogtreecommitdiff
path: root/linux/deb/02-fs-spring-boot-kamal/package/DEBIAN/postinst
diff options
context:
space:
mode:
Diffstat (limited to 'linux/deb/02-fs-spring-boot-kamal/package/DEBIAN/postinst')
-rwxr-xr-xlinux/deb/02-fs-spring-boot-kamal/package/DEBIAN/postinst47
1 files changed, 29 insertions, 18 deletions
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