From 5771141861933d92c8cd001ce3bc7861bf66aa29 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 30 Apr 2024 14:35:50 +0200 Subject: [SS?S] Add dpkg hook to restart java services on update --- .../system-updates/etc/apt/apt.conf.d/80java-restart | 1 + .../system-updates/etc/cron.d/java-restart-init | 1 + .../system-updates/opt/openslx/dpkg-post.sh | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 satellit_installer/static_files/system-updates/etc/apt/apt.conf.d/80java-restart create mode 100644 satellit_installer/static_files/system-updates/etc/cron.d/java-restart-init create mode 100755 satellit_installer/static_files/system-updates/opt/openslx/dpkg-post.sh diff --git a/satellit_installer/static_files/system-updates/etc/apt/apt.conf.d/80java-restart b/satellit_installer/static_files/system-updates/etc/apt/apt.conf.d/80java-restart new file mode 100644 index 0000000..bf50988 --- /dev/null +++ b/satellit_installer/static_files/system-updates/etc/apt/apt.conf.d/80java-restart @@ -0,0 +1 @@ +DPkg::Post-Invoke { "/opt/openslx/dpkg-post.sh"; }; diff --git a/satellit_installer/static_files/system-updates/etc/cron.d/java-restart-init b/satellit_installer/static_files/system-updates/etc/cron.d/java-restart-init new file mode 100644 index 0000000..c563036 --- /dev/null +++ b/satellit_installer/static_files/system-updates/etc/cron.d/java-restart-init @@ -0,0 +1 @@ +@reboot root /opt/openslx/dpkg-post.sh --boot diff --git a/satellit_installer/static_files/system-updates/opt/openslx/dpkg-post.sh b/satellit_installer/static_files/system-updates/opt/openslx/dpkg-post.sh new file mode 100755 index 0000000..ab07bba --- /dev/null +++ b/satellit_installer/static_files/system-updates/opt/openslx/dpkg-post.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +laststamp=$( cat /run/openslx/java-ts 2> /dev/null ) + +s="$( stat -c %Y /usr/lib/jvm/*/bin/java /usr/lib/jvm/*/lib/jspawnhelper | sort -n | tail -n 1 )" + +# Nothing changed? +[ "$s" = "$laststamp" ] && exit 0 + +if [ -z "$laststamp" ] || [ "$1" = "--boot" ]; then + mkdir -p /run/openslx/ +else + systemctl --no-block try-restart dmsd.service taskmanager.service +fi + +echo "$s" > /run/openslx/java-ts +exit 0 -- cgit v1.2.3-55-g7522