forked from lucamaro/opendcim-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
60 lines (49 loc) · 1.57 KB
/
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
#! /bin/sh
if [ ! -f /.configured ] ; then
# configure port with environment var DBHOST
sed -i "s/[$]dbhost = [']localhost[']/\$dbhost = '$DBHOST'/" /var/www/dcim/db.inc.php
sed -i "s/[$]dbname = [']dcim[']/\$dbname = '$DCIM_DB_SCHEMA'/" /var/www/dcim/db.inc.php
sed -i "s/[$]dbuser = [']dcim[']/\$dbuser = '$DCIM_DB_USER'/" /var/www/dcim/db.inc.php
sed -i "s/[$]dbpass = [']dcim[']/\$dbpass = '$DCIM_DB_PASSWD'/" /var/www/dcim/db.inc.php
if [ -f "$SSL_CERT_FILE" ] && [ -f "$SSL_KEY_FILE" ] ; then
a2enmod ssl
a2ensite default-ssl
cd /etc/ssl/certs/
cp $SSL_CERT_FILE ssl-cert.pem
cp $SSL_KEY_FILE ssl-cert.key
fi
# for swarm secret
if [ -f "$DCIM_PASSWD_FILE" ] ; then
PASSWORD=$(cat $DCIM_PASSWD_FILE)
elif [ ! -z "$DCIM_PASSWD" ] ; then
PASSWORD=$DCIM_PASSWD
else
PASSWORD=dcim
fi
htpasswd -cb /data/opendcim.password dcim $PASSWORD
cd /var/www/dcim
for D in images pictures drawings ; do
if [ ! -d /data/$D ] ; then
mkdir /data/$D
fi
if [ -d /var/www/dcim/$D ] ; then
mv /var/www/dcim/$D/* /data/$D
rm -rf /var/www/dcim/$D
ln -s /data/$D .
fi
chown www-data:www-data /data/$D
done
# fix permissions on images directory
chmod 555 /data/images
chown www-data:www-data /var/www/dcim/vendor/mpdf/mpdf/ttfontdata
touch /.configured
fi
for param in "$@" ; do
if [ "$param" = "--remove-install" ] ; then
rm -f /var/www/dcim/install.php
elif [ "$param" = "--enable-ldap" ] ; then
mv /var/www/dcim/.htaccess /var/www/dcim/.htaccess.no
sed -i "s/Apache/LDAP/" /var/www/dcim/db.inc.php
fi
done
exec docker-php-entrypoint -DFOREGROUND