-
Notifications
You must be signed in to change notification settings - Fork 3
/
init
54 lines (50 loc) · 1.58 KB
/
init
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
#!/bin/bash
# exit on error
set -e
# set variables
container_ip_address="$(hostname --ip-address)"
# update user id of webserver user to the owner of this init script
webserver_uid="$(stat -c "%u" "$0")"
webserver_orig_uid="$(id -u webserver)"
if [ "$webserver_uid" -lt "500" ] || [ "$webserver_uid" -gt "1999" ]
then
echo "The tugger-stack 'init' script's owner user id will be used as user id for the webserver user in your"
echo "container. Please use the user id of your own local user to avoid permission issues. The user id has to be"
echo "between 500 and 1999."
exit 1
fi
if [ "$webserver_uid" != "$webserver_orig_uid" ]
then
usermod -u $webserver_uid webserver
if test -e /var/lock/apache2; then
chown -R $webserver_uid /var/lock/apache2
fi
if test -e /var/cache/apache2; then
chown -R $webserver_uid /var/cache/apache2
fi
if test -e /var/lib/php5/session5; then
chown -R $webserver_uid /var/lib/php5/session5/*
fi
fi
# start services
echo "Starting services..."
service ssh restart
service mysql-default restart
if test -e /var/run/apache2.pid
then
# remove apache2 pid file after unclean shut down if no process running
if [ "$(pgrep apache2 | wc -l)" == "0" ]
then
rm /var/run/apache2.pid
fi
fi
service apache2 restart
service elasticsearch stop
service elasticsearch start
if test -e /var/run/redis/6379/redis_6379.pid
then
rm /var/run/redis/6379/redis_6379.pid
fi
service redis6379 start
echo "Services started."
echo "The default password of the webserver user and the database root user is: qweqwe"