summaryrefslogtreecommitdiffhomepage
path: root/pkg/docker/docker-entrypoint.sh
diff options
context:
space:
mode:
authorKonstantin Pavlov <thresh@nginx.com>2023-05-10 10:29:16 -0700
committerKonstantin Pavlov <thresh@nginx.com>2023-05-10 10:29:16 -0700
commit69235c513277c64b513447d9b92c3c03d616f577 (patch)
tree0780c92ba28d92b547c85ea0bee5e3040e14dee2 /pkg/docker/docker-entrypoint.sh
parentb9bc222021e77bbdfb12576b3e315b962cf6b399 (diff)
parentfaf97dc06058de1c929af33a68adb34d3932b374 (diff)
downloadunit-1.30.0-1.tar.gz
unit-1.30.0-1.tar.bz2
Merged with the default branch.1.30.0-1
Diffstat (limited to '')
-rwxr-xr-xpkg/docker/docker-entrypoint.sh75
1 files changed, 42 insertions, 33 deletions
diff --git a/pkg/docker/docker-entrypoint.sh b/pkg/docker/docker-entrypoint.sh
index e0afd7ea..4646409f 100755
--- a/pkg/docker/docker-entrypoint.sh
+++ b/pkg/docker/docker-entrypoint.sh
@@ -25,21 +25,23 @@ 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
- if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
- echo "$0: /docker-entrypoint.d/ is not empty, launching Unit daemon to perform initial configuration..."
- /usr/sbin/$1 --control unix:/var/run/control.unit.sock
+ echo "$0: Launching Unit daemon to perform initial configuration..."
+ /usr/sbin/$1 --control unix:/var/run/control.unit.sock
- for i in $(/usr/bin/seq $WAITLOOPS); do
- if [ ! -S /var/run/control.unit.sock ]; then
- echo "$0: Waiting for control socket to be created..."
- /bin/sleep $SLEEPSEC
- else
- break
- fi
- done
- # even when the control socket exists, it does not mean unit has finished initialisation
- # this curl call will get a reply once unit is fully launched
- /usr/bin/curl -s -X GET --unix-socket /var/run/control.unit.sock http://localhost/
+ for i in $(/usr/bin/seq $WAITLOOPS); do
+ if [ ! -S /var/run/control.unit.sock ]; then
+ echo "$0: Waiting for control socket to be created..."
+ /bin/sleep $SLEEPSEC
+ else
+ break
+ fi
+ done
+ # even when the control socket exists, it does not mean unit has finished initialisation
+ # this curl call will get a reply once unit is fully launched
+ /usr/bin/curl -s -X GET --unix-socket /var/run/control.unit.sock http://localhost/
+
+ if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
+ echo "$0: /docker-entrypoint.d/ is not empty, applying initial configuration..."
echo "$0: Looking for certificate bundles in /docker-entrypoint.d/..."
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.pem"); do
@@ -47,6 +49,12 @@ if [ "$1" = "unitd" ] || [ "$1" = "unitd-debug" ]; then
curl_put $f "certificates/$(basename $f .pem)"
done
+ echo "$0: Looking for JavaScript modules in /docker-entrypoint.d/..."
+ for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.js"); do
+ echo "$0: Uploading JavaScript module: $f"
+ curl_put $f "js_modules/$(basename $f .js)"
+ done
+
echo "$0: Looking for configuration snippets in /docker-entrypoint.d/..."
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.json"); do
echo "$0: Applying configuration $f";
@@ -60,32 +68,33 @@ if [ "$1" = "unitd" ] || [ "$1" = "unitd-debug" ]; then
done
# warn on filetypes we don't know what to do with
- for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -not -name "*.sh" -not -name "*.json" -not -name "*.pem"); do
+ for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -not -name "*.sh" -not -name "*.json" -not -name "*.pem" -not -name "*.js"); do
echo "$0: Ignoring $f";
done
+ else
+ echo "$0: /docker-entrypoint.d/ is empty, creating 'welcome' configuration..."
+ curl_put /usr/share/unit/welcome/welcome.json "config"
+ fi
- echo "$0: Stopping Unit daemon after initial configuration..."
- kill -TERM $(/bin/cat /var/run/unit.pid)
+ echo "$0: Stopping Unit daemon after initial configuration..."
+ kill -TERM $(/bin/cat /var/run/unit.pid)
- 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
+ for i in $(/usr/bin/seq $WAITLOOPS); do
if [ -S /var/run/control.unit.sock ]; then
- kill -KILL $(/bin/cat /var/run/unit.pid)
- rm -f /var/run/control.unit.sock
+ echo "$0: Waiting for control socket to be removed..."
+ /bin/sleep $SLEEPSEC
+ else
+ break
fi
-
- echo
- echo "$0: Unit initial configuration complete; ready for start up..."
- echo
- else
- echo "$0: /docker-entrypoint.d/ is empty, skipping initial configuration..."
+ 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..."
+ echo
fi
fi