-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathdocker-entrypoint.sh
88 lines (67 loc) · 2.09 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
pushd /var/www/html/fusio
# wait for external services
php bin/fusio system:wait_for
# install fusio
php bin/fusio migration:up-to-date
if [ $? -ne 0 ]; then
# migrate fusio
php bin/fusio migration:migrate --no-interaction
fi
# add initial backend user
php bin/fusio system:check user
if [ $? -ne 0 ]; then
php bin/fusio adduser --role=1 --username="$FUSIO_BACKEND_USER" --email="$FUSIO_BACKEND_EMAIL" --password="$FUSIO_BACKEND_PW"
fi
# replace env
php bin/fusio marketplace:env fusio
php bin/fusio marketplace:env developer
php bin/fusio marketplace:env account
php bin/fusio marketplace:env redoc
# login
php bin/fusio login --username="$FUSIO_BACKEND_USER" --password="$FUSIO_BACKEND_PW"
# configure worker
setup_worker() {
php bin/fusio connection:detail "$1"
if [ $? -ne 0 ]; then
php bin/fusio connection:create "{'name':'$1','class':'Fusio.Adapter.Worker.Connection.Worker','config':{'url':'http://$2'}}"
else
php bin/fusio connection:update "$1" "{'name':'$1','class':'Fusio.Adapter.Worker.Connection.Worker','config':{'url':'http://$2'}}"
fi
}
if [ ! -z "$FUSIO_WORKER_JAVA" ]; then
setup_worker "Java-Worker" $FUSIO_WORKER_JAVA
fi
if [ ! -z "$FUSIO_WORKER_JAVASCRIPT" ]; then
setup_worker "Javascript-Worker" $FUSIO_WORKER_JAVASCRIPT
fi
if [ ! -z "$FUSIO_WORKER_PHP" ]; then
setup_worker "PHP-Worker" $FUSIO_WORKER_PHP
fi
if [ ! -z "$FUSIO_WORKER_PYTHON" ]; then
setup_worker "Python-Worker" $FUSIO_WORKER_PYTHON
fi
# run deploy
php bin/fusio deploy
# logout
php bin/fusio logout
# create env script
echo '#!/bin/bash' > env.sh
declare -px | sed 's/^declare -x /export /g' | grep -E "^export FUSIO" >> env.sh
chown www-data: env.sh
chmod +x env.sh
popd
# chown
chown -R www-data: /var/www/html/fusio/cache
chown -R www-data: /var/www/html/fusio/log
# start cron
service cron start
# start supervisor
supervisord
# we start all worker and ignore any errors at startup
supervisorctl start all || true
# remove existing pid
rm -f /var/run/apache2/apache2.pid
# start apache
source /etc/apache2/envvars
exec /usr/sbin/apache2 -D FOREGROUND