diff options
Diffstat (limited to 'microservices/01-oauth2-server/linux/deb/package/DEBIAN')
6 files changed, 101 insertions, 0 deletions
diff --git a/microservices/01-oauth2-server/linux/deb/package/DEBIAN/conffiles b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/conffiles new file mode 100644 index 0000000..a52c085 --- /dev/null +++ b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/conffiles @@ -0,0 +1,3 @@ +/etc/ceit-fs-auth-server/application.yaml +/etc/ceit-fs-auth-server/environment.env +/etc/nginx/sites-available/fs-auth-server.dev.ceit.pdn.ac.lk diff --git a/microservices/01-oauth2-server/linux/deb/package/DEBIAN/control b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/control new file mode 100644 index 0000000..9239fb0 --- /dev/null +++ b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/control @@ -0,0 +1,8 @@ +Package: ceit-fs-auth-server +Version: 1.0.0-1 +Section: httpd +Priority: optional +Architecture: all +Depends: openjdk-25-jre | temurin-25-jre | openjdk-25-jdk | temurin-25-jdk +Maintainer: Kamal Wickramanayake <info@software.lk> +Description: A demo Debian package that bundles a Spring Boot application. diff --git a/microservices/01-oauth2-server/linux/deb/package/DEBIAN/postinst b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/postinst new file mode 100755 index 0000000..74509f4 --- /dev/null +++ b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/postinst @@ -0,0 +1,59 @@ +#!/bin/bash + +# Stop on error +set -e + +if [ "$1" == "configure" ] && [ -z "$2" ]; then + # Code here executes only during package install (but not during upgrade) + + # Create a system user + # -r: System user + # -s /sbin/nologin: Prevent the user from logging into the system interactively + # -d /var/lib/ceit-fs-auth-server: Set home directory of user + # ceit-fs-auth-server: Username + useradd -r -s /sbin/nologin -d /var/lib/ceit-fs-auth-server ceit-fs-auth-server || true + +fi + +# Set directory ownership and permissions - Application jar file not to be read by other system users +chown -R root:ceit-fs-auth-server /opt/ceit/ceit-fs-auth-server +chmod 755 /opt/ceit +chmod 750 /opt/ceit/ceit-fs-auth-server +chmod 750 /opt/ceit/ceit-fs-auth-server/app +chmod 640 /opt/ceit/ceit-fs-auth-server/app/ceit-fs-auth-server.jar + +# Set directory ownership and permissions - Config files not to be read by other system users +chown -R root:ceit-fs-auth-server /etc/ceit-fs-auth-server +chmod 750 /etc/ceit-fs-auth-server +chmod 640 /etc/ceit-fs-auth-server/application.yaml +chmod 640 /etc/ceit-fs-auth-server/environment.env + +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 ceit-fs-auth-server > /dev/null; then + systemctl start ceit-fs-auth-server + fi + else + # First install (not upgrade) + # Enable service to start at boot time + systemctl enable ceit-fs-auth-server + # Start service + systemctl start ceit-fs-auth-server + fi + fi +fi + +if [ "$1" == "configure" ] && [ -z "$2" ]; then + # Code here executes only during package install (but not during upgrade) + echo "[INFO] ceit-fs-auth-server service installed." + echo "[INFO] Update /etc/ceit-fs-auth-server/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 diff --git a/microservices/01-oauth2-server/linux/deb/package/DEBIAN/postrm b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/postrm new file mode 100755 index 0000000..261f7af --- /dev/null +++ b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/postrm @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +# Check if the package is being purged (erased entirely including configs) +if [ -z "$DPKG_ROOT" ] && [ "$1" = "purge" ] ; then + update-rc.d ceit-fs-auth-server remove >/dev/null + deluser --quiet ceit-fs-auth-server || true +fi + +# Reload systemd service configuration files. +systemctl daemon-reload + +# postrm script must exit with 0 +exit 0 diff --git a/microservices/01-oauth2-server/linux/deb/package/DEBIAN/preinst b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/preinst new file mode 100755 index 0000000..61c2587 --- /dev/null +++ b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/preinst @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +# Put commands that should execute before the pckage is installed. + +# Example: Just print a message +echo "preinst script running..." diff --git a/microservices/01-oauth2-server/linux/deb/package/DEBIAN/prerm b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/prerm new file mode 100755 index 0000000..cd4bf94 --- /dev/null +++ b/microservices/01-oauth2-server/linux/deb/package/DEBIAN/prerm @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +# Stop service before files are removed +systemctl stop ceit-fs-auth-server || true + +# prerm script must exit with 0 +exit 0 + |
