forked from joschi127/docker-lamp-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
51 lines (45 loc) · 1.16 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
#!/bin/bash
#
# This script will be used as init script within the docker container when the container is started. (the container
# will be started with '/bin/bash /path/to/init.sh' as command)
#
# exit on error
set -e
# set variables
D_PROVISION=0
if [ "$1" == "--provision" ]; then
D_PROVISION=1
fi
D_DIR="$(dirname "$0")"
D_IP_ADDRESS="$(hostname --ip-address)"
# run chef-solo / berkshelf provisioning
if [ "$D_PROVISION" = "1" ]; then
echo
echo "Running chef-solo / berkshelf provisioning ..."
echo
rm -rf /chef
cp -r -Pav "$D_DIR" /chef
cd /chef
rm -f Berksfile.lock
/opt/chef/embedded/bin/berks vendor /chef/cookbooks
chef-solo -c "/chef/chef.rb" -j "/chef/chef.json"
echo
echo "Provisioning completed."
echo
fi
# start services
echo
echo "Starting services ..."
echo
/etc/init.d/ssh restart
/etc/init.d/mysql restart
/etc/init.d/apache2 restart
echo
echo "Services started. Server IP is: $D_IP_ADDRESS"
echo
echo "To ssh into the container use: ssh webserver@$D_IP_ADDRESS"
echo
echo "You can press Ctrl+C now to get back to your console."
echo
# keep container running forever (or until it is being stopped)
sleep infinity