-
Notifications
You must be signed in to change notification settings - Fork 7
/
init.sh
executable file
·117 lines (90 loc) · 2.92 KB
/
init.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# disable paritcular supervisor job by deleting jobs files
rm inited
if [ -n "$MULTI_DOMAINS" ]
then
./init_multidomains.sh
exit 0;
fi
if [ "$DISABLE_PHP_FPM" == 'true' ]
then
rm -f /etc/supervisor/conf.d/php-fpm.conf
echo php-fpm.conf disabled
else
echo php-fpm.conf enabled
fi
if [ "$DISABLE_HORIZON" == 'true' ]
then
rm -f /etc/supervisor/custom.d/horizon.conf
echo horizon.conf disabled
else
cp docker/conf/supervisor/services/horizon.conf /etc/supervisor/custom.d/horizon.conf
echo horizon.conf enabled
fi
if [ "$DISABLE_SCHEDULER" == 'true' ]
then
rm -f /etc/supervisor/custom.d/scheduler.conf
echo scheduler.conf disabled
else
cp docker/conf/supervisor/services/scheduler.conf /etc/supervisor/custom.d/scheduler.conf
echo scheduler.conf enabled
fi
# set env from `LARAVEL_` prefixed env vars
# this also setup MULTI_DOMAINS eg
# when MULTI_DOMAINS: "api-sprawnymarketing.escolalms.com,api-gest.escolalms.com"
# then API_SPRAWNYMARKETING_ESCOLALMS_COM_APP_NAME: '"Sprawny Marketing"'
php docker/envs/envs.php
# if binded by k8s or docker those folders might need to be recreated
mkdir storage
mkdir storage/framework
mkdir storage/framework/sessions
mkdir storage/framework/views
mkdir storage/framework/cache
mkdir storage/app
mkdir storage/logs
chmod -R 0766 storage
# run all laravel related tasks
# klucze mozna trzymac jako zmienne srodowiskowe wiec ....
# https://github.com/gecche/laravel-multidomain/issues/51
# create keys from env base64 variables
if [ -n "$JWT_PUBLIC_KEY_BASE64" ]; then
echo "Storing public RSA key for JWT generation - storage/oauth-public.key"
echo ${JWT_PUBLIC_KEY_BASE64} | base64 -d > storage/oauth-public.key
fi
if [ -n "$JWT_PRIVATE_KEY_BASE64" ]; then
echo "Storing private RSA key for JWT generation - storage/oauth-private.key"
echo ${JWT_PRIVATE_KEY_BASE64} | base64 -d > storage/oauth-private.key
fi
if [ "$DISABLE_DB_MIGRATE" == 'true' ]
then
echo "Disable db migrate"
else
php artisan migrate --force
fi
# generate passport keys only if storage/oauth-private.key is not set
FILE=storage/oauth-private.key
if [ -f "$FILE" ]; then
echo "$FILE exists."
else
echo "$FILE does not exist. Generating app keys, passport keys and passport client"
php artisan key:generate --force --no-interaction
php artisan passport:keys --force --no-interaction
php artisan passport:client --personal --no-interaction
fi
if [ "$DISABLE_DB_SEED" == 'true' ]
then
echo "Disable db:seed"
else
php artisan db:seed --class=PermissionsSeeder --force --no-interaction
fi
if [ "$DISABLE_H5P_STORAGE_LINK" == 'true' ]
then
echo "Disable h5p:storage-link"
else
php artisan h5p:storage-link --overwrite
fi
touch inited
# TODO: Fixme
# This is required so far as docker compose run this script as root
chown -R devilbox:devilbox /var/www/html/storage
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf