summaryrefslogtreecommitdiff
path: root/docker/assets/initctl
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-07-21 16:44:38 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-07-23 14:27:25 +0200
commit47e81e75d7545a5d8601210055a7a6349aaaa528 (patch)
treee5ff0e4f46d10a729c516b8ddb2d83c024fa67fc /docker/assets/initctl
parent8ba1a7a03f849cd83a83476c920c2c0572e675d7 (diff)
downloadgitlab-ce-docker-pin.tar.gz
PIN users to UIDs and monkey patch initctldocker-pin
Diffstat (limited to 'docker/assets/initctl')
-rwxr-xr-xdocker/assets/initctl67
1 files changed, 67 insertions, 0 deletions
diff --git a/docker/assets/initctl b/docker/assets/initctl
new file mode 100755
index 00000000000..944741ee66c
--- /dev/null
+++ b/docker/assets/initctl
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+# Monkey patch missing initctl in docker environment
+
+fail() {
+ echo "$@" 1>&2
+ exit 1
+}
+
+verify_args() {
+ if [[ "$2" != "gitlab-runsvdir" ]]; then
+ fail "initctl: Unknown job: $2"
+ fi
+ if [[ $# -ne 2 ]]; then
+ fail "usage: $0 command gitlab-runsvdir"
+ fi
+}
+
+proxy_gitlab_ctl() {
+ gitlab-ctl "$COMMAND"
+}
+
+COMMAND="$1"
+shift
+SERVICE="$1"
+
+case "$COMMAND" in
+ start)
+ verify_args "$COMMAND" "$@"
+ RUNSVDIR=$(pidof runsvdir)
+ if [[ -z "$RUNSVDIR" ]]; then
+ /opt/gitlab/embedded/bin/runsvdir-start &
+ fi
+ ;;
+
+ stop|restart)
+ verify_args "$COMMAND" "$@"
+ proxy_gitlab_ctl "$COMMAND" "$@"
+ ;;
+
+ status)
+ verify_args "$COMMAND" "$@"
+ if [[ ! -f /etc/init/$SERVICE.conf ]]; then
+ fail "initctl: Unknown job: $SERVICE"
+ fi
+
+ RUNSVDIR=$(pidof runsvdir)
+ if [[ -n "$RUNSVDIR" ]]; then
+ echo "$SERVICE start/running, process $RUNSVDIR"
+ else
+ echo "$SERVICE stop/waiting"
+ fi
+ ;;
+
+ reload)
+ verify_args "$COMMAND" "$@"
+ proxy_gitlab_ctl "hup" "$@"
+ ;;
+
+ list)
+ echo "gitlab-runsvdir"
+ ;;
+
+ *)
+ exit 0
+ ;;
+esac