aboutsummaryrefslogtreecommitdiff
path: root/guix-container.sh
diff options
context:
space:
mode:
Diffstat (limited to 'guix-container.sh')
-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() {