aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2023-08-24 22:54:41 +0200
committerWojtek Kosior <koszko@koszko.org>2023-08-25 12:27:38 +0200
commit66d57678ba0276832449418b6d8f654169563ba9 (patch)
treec62b1248aa2340d68509fa7947f2fafa6c295fc8
parent7a05a24d414a5a95ee2bf377c87464d57bf5e035 (diff)
downloadkoszko-org-server-66d57678ba0276832449418b6d8f654169563ba9.tar.gz
koszko-org-server-66d57678ba0276832449418b6d8f654169563ba9.zip
make it possible to test the container without SysV init helper tools
-rwxr-xr-xguix-container.sh61
1 files changed, 57 insertions, 4 deletions
diff --git a/guix-container.sh b/guix-container.sh
index 902ee94..da8b765 100755
--- a/guix-container.sh
+++ b/guix-container.sh
@@ -17,7 +17,43 @@
set -e
-. /lib/lsb/init-functions
+if [ -r /lib/lsb/init-functions ]; then
+ . /lib/lsb/init-functions
+else
+ log_anything() {
+ while [ 0 -lt $# ]; do
+ printf "%s" "$1"
+ shift
+ if [ 0 -lt $# ]; then
+ printf " "
+ else
+ printf "\n"
+ fi
+ done
+ }
+ log_action_msg() {
+ log_anything "$@"
+ }
+ log_failure_msg() {
+ printf "Failure\n"
+ }
+ log_success_msg() {
+ printf "Success\n"
+ }
+ log_daemon_msg() {
+ log_anything "$@"
+ }
+ log_warning_msg() {
+ log_anything "$@"
+ }
+ status_of_proc() {
+ if is_running; then
+ printf "Guix container running\n"
+ else
+ printf "Guix container not running\n"
+ fi
+ }
+fi
if [ 0 != $(id -u) ]; then
log_action_msg "Script '$0' must be run as root"
@@ -71,9 +107,26 @@ network_rip() {
stop() {
network_rip
- /sbin/start-stop-daemon \
- --stop --signal TERM --pidfile "$PIDFILE" --remove-pidfile --quiet \
- --retry 60 2>/dev/null || true
+
+ if [ -x /sbin/start-stop-daemon ]; then
+ /sbin/start-stop-daemon \
+ --stop --signal TERM --pidfile "$PIDFILE" --remove-pidfile --quiet \
+ --retry 60 2>/dev/null || true
+ else
+ DAEMON_PID="$(cat "$PIDFILE")"
+
+ while is_running; do
+ kill -TERM "$DAEMON_PID" || true
+ printf "Sent TERM, waiting for process to finish\n"
+ for I in $(seq 30); do
+ if is_running; then
+ sleep 2
+ fi
+ done
+ done
+
+ rm -rf "$PIDFILE"
+ fi
}
onexit() {