summaryrefslogtreecommitdiffhomepage
path: root/pkg/docker/docker-entrypoint.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/docker/docker-entrypoint.sh')
-rwxr-xr-xpkg/docker/docker-entrypoint.sh26
1 files changed, 20 insertions, 6 deletions
diff --git a/pkg/docker/docker-entrypoint.sh b/pkg/docker/docker-entrypoint.sh
index 59529925..3d134ea2 100755
--- a/pkg/docker/docker-entrypoint.sh
+++ b/pkg/docker/docker-entrypoint.sh
@@ -1,11 +1,14 @@
-#!/usr/bin/env bash
+#!/bin/sh
set -e
+WAITLOOPS=5
+SLEEPSEC=1
+
curl_put()
{
- RET=`/usr/bin/curl -s -w '%{http_code}' -X PUT --data-binary @$1 --unix-socket /var/run/control.unit.sock http://localhost/$2`
- RET_BODY=${RET::-3}
+ RET=$(/usr/bin/curl -s -w '%{http_code}' -X PUT --data-binary @$1 --unix-socket /var/run/control.unit.sock http://localhost/$2)
+ RET_BODY=$(echo $RET | /bin/sed '$ s/...$//')
RET_STATUS=$(echo $RET | /usr/bin/tail -c 4)
if [ "$RET_STATUS" -ne "200" ]; then
echo "$0: Error: HTTP response status code is '$RET_STATUS'"
@@ -18,7 +21,7 @@ curl_put()
return 0
}
-if [ "$1" = "unitd" -o "$1" = "unitd-debug" ]; then
+if [ "$1" = "unitd" ] || [ "$1" = "unitd-debug" ]; then
if /usr/bin/find "/var/lib/unit/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
echo "$0: /var/lib/unit/ is not empty, skipping initial configuration..."
else
@@ -55,9 +58,20 @@ if [ "$1" = "unitd" -o "$1" = "unitd-debug" ]; then
done
echo "$0: Stopping Unit daemon after initial configuration..."
- kill -TERM `/bin/cat /var/run/unit.pid`
+ kill -TERM $(/bin/cat /var/run/unit.pid)
- while [ -S /var/run/control.unit.sock ]; do echo "$0: Waiting for control socket to be removed..."; /bin/sleep 0.1; done
+ for i in $(/usr/bin/seq $WAITLOOPS); do
+ if [ -S /var/run/control.unit.sock ]; then
+ echo "$0 Waiting for control socket to be removed..."
+ /bin/sleep $SLEEPSEC
+ else
+ break
+ fi
+ done
+ if [ -S /var/run/control.unit.sock ]; then
+ kill -KILL $(/bin/cat /var/run/unit.pid)
+ rm -f /var/run/control.unit.sock
+ fi
echo
echo "$0: Unit initial configuration complete; ready for start up..."