-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint
executable file
·91 lines (73 loc) · 2.34 KB
/
entrypoint
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
#!/bin/bash
comba_owns=(
'/var/audio'
'/opt/comba/combac.py'
'/opt/comba/combas.py'
'/opt/comba/combaa.py'
'/opt/comba/combaevents.py'
'/etc/comba/scheduler.xml'
'/opt/comba/soundengine/helpers'
'/var/log/comba'
'/var/run/comba'
'/opt/comba/var/sqlite'
)
if [ -n "$USERID" ] && [ "${USERID//[0-9]}" = "" ];then
echo "Changing combas uid to $USERID"
usermod -u $USERID comba
for i in ${comba_owns[@]}; do
chown -R comba $i;
done;
fi
if [ -f /usr/share/zoneinfo/$COMBA_TIMEZONE ]; then
cp /usr/share/zoneinfo/$COMBA_TIMEZONE /etc/localtime && echo $COMBA_TIMEZONE > /etc/timezone
echo "Container timezone set to: $COMBA_TIMEZONE"
dpkg-reconfigure -f noninteractive tzdata
fi
echo $TZ
chown -R comba:liquidsoap /var/log/comba && chown -R comba /opt/comba/web
cd /opt/comba/web
/usr/bin/mongod --smallfiles &
COUNTER=0
while !(nc -z localhost 27017) && [[ $COUNTER -lt 60 ]] ; do
sleep 2
let COUNTER+=2
echo "Waiting for mongo to initialize... ($COUNTER seconds so far)"
done
/usr/bin/redis-server /etc/redis/redis.conf &
COUNTER=0
while !(nc -z localhost 6379) && [[ $COUNTER -lt 60 ]] ; do
sleep 2
let COUNTER+=2
echo "Waiting for redis to initialize... ($COUNTER seconds so far)"
done
echo "processing migrations"
python manage.py makemigrations --noinput
python manage.py migrate --noinput
echo "collecting statics"
python manage.py collectstatic --noinput
chown comba /var/log/comba/web.log && chown -R comba /opt/comba/web
chown -R comba:liquidsoap /opt/comba/var
if [ "$COMBA_WEB_ADMIN" != "" ] && [ "$COMBA_WEB_ADMIN_PASSWORD" != "" ] && [ ! -f /var/comba/adminset ]; then
echo "create django user object"
mkdir -p /var/comba/
touch /var/comba/adminset
fi
echo "create audio folders"
audio_folders=(
'fallback'
'archive'
'jingles'
'preprod'
'rec'
)
for folder in ${audio_folders[@]}; do
mkdir -p "/var/audio/$folder"
chown -R comba:liquidsoap "/var/audio/$folder"
done;
python /opt/comba/tools/initdb.py
kill -9 $(ps -ax | grep /usr/bin/mongod | grep -v grep | awk '{ print $1 }');
kill -9 $(ps -ax | grep /usr/bin/redis-server | grep -v grep | awk '{ print $1 }');
envsubst < /etc/ssmtp/ssmtp.template > /etc/ssmtp/ssmtp.conf
envsubst < /etc/comba/comba.template > /etc/comba/comba.ini
/usr/bin/supervisord -n
exit 0