Skip to content

Commit e236194

Browse files
authored
Executable bit
Signed-off-by: GitHub <noreply@github.com>
1 parent 791209c commit e236194

1 file changed

Lines changed: 51 additions & 11 deletions

File tree

  • root/etc/s6-overlay/s6-rc.d/init-kimai-config

root/etc/s6-overlay/s6-rc.d/init-kimai-config/run

100644100755
Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,60 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4+
DB_VALID=$(php -r 'echo filter_var(getenv("DATABASE_URL"), FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED);')
5+
6+
if [[ ${DATABASE_URL+x} == "" ]] || [[ ${DB_VALID+x} == "NULL" ]]; then
7+
cat <<-EOF
8+
********************************************************
9+
********************************************************
10+
* *
11+
* !!!! *
12+
* DATABASE_URL environment variable is not set *
13+
* OR *
14+
* DATABASE_URL environment variable is not valid *
15+
* *
16+
* Please refer to the README *
17+
* *
18+
* *
19+
********************************************************
20+
********************************************************
21+
EOF
22+
sleep infinity
23+
fi
24+
425
# make our folders
526
mkdir -p \
6-
/config/{cache,data,log,packages,plugins,sessions}
27+
/config/www/var/{cache,data,log,packages,plugins,sessions}
728

8-
symlink -l /app/www/var /config
29+
rm -rf /app/www/var
30+
symlink -l /app/www/var /config/www/var
931

10-
if [[ -n "${DATABASE_URL}" ]]; then
11-
cd /app/www || exit 1
12-
s6-setuidgid abc bin/console kimai:install -n
13-
s6-setuidgid abc bin/console kimai:update -n
14-
else
15-
echo "DATABASE_URL not set"
16-
sleep infinity
17-
fi
32+
DB_HOST=$(php -r 'echo parse_url(getenv("DATABASE_URL"), PHP_URL_HOST);')
33+
DB_PORT=$(php -r 'echo parse_url(getenv("DATABASE_URL"), PHP_URL_PORT) ?? 3306;')
34+
35+
# check for the mysql endpoint
36+
echo "Waiting for DB to be available"
37+
END=$((SECONDS + 30))
38+
while [[ ${SECONDS} -lt ${END} ]]; do
39+
if [[ $(/usr/bin/nc -w1 "${DB_HOST}" "${DB_PORT}" | tr -d '\0') ]]; then
40+
if [[ -n "${RUN}" ]]; then
41+
break
42+
fi
43+
RUN="RAN"
44+
# we sleep here again due to first run init on DB containers
45+
if [[ ! -f /dbwait.lock ]]; then
46+
sleep 5
47+
fi
48+
else
49+
sleep 1
50+
fi
51+
done
52+
# set lockfile to avoid DB waits for this specific container
53+
touch /dbwait.lock
54+
55+
cd /app/www || exit 1
56+
s6-setuidgid abc bin/console kimai:install -n
57+
s6-setuidgid abc bin/console kimai:update -n
1858

1959
lsiown -R abc:abc \
20-
/config
60+
/config/www

0 commit comments

Comments
 (0)