-
Notifications
You must be signed in to change notification settings - Fork 2
/
dockerctl
executable file
·96 lines (85 loc) · 2.31 KB
/
dockerctl
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
#!/bin/bash
#confdir=/etc/dockerctl
confdir="/root/fuel-dockerctl/"
. "$confdir/config"
. "$confdir/functions.sh"
DEBUG=true
if [ -z "$1" ] || [ "$1" = "help" ]; then
echo "Please specify a command."
show_usage
exit 1
fi
if [ -z "$2" ] || [ "$2" = "all" ]; then
container="all"
else
container=$2
fi
if [ "$1" == "build" ]; then
if [ "$container" = "storage" ]; then
build_storage_containers
run_storage_containers
elif [ "$container" = "all" ];then
#Step 1: prepare storage containers
build_storage_containers
run_storage_containers
#Step 2: import app images
import_images ${SOURCE_IMAGES[@]}
#Step 3: Prepare supervisord
cp $SUPERVISOR_CONF_DIR/* /etc/supervisord.d/
#Prepare iptables just in case ICC is broken
allow_all_docker_traffic
#Step 3: Launch all in order
apps="postgres rabbitmq rsync astute rsyslog nailgun mcollective ostf nginx cobbler"
for service in $apps; do
start_container $service
sleep 4
done
#Deploy supervisord scripts
#TODO(mattymo): puppetize this in host-only role
yum install -y supervisor
mkdir -p /etc/supervisord.d
cp -R $confdir/supervisor/* /etc/supervisord.d/
cp /etc/puppet/modules/nailgun/templates/supervisord.conf.base.erb /etc/supervisord.conf
service supervisord start
#Step 4: Test deployment TODO(mattymo)
#run_tests $apps
else
import_images ${SOURCE_IMAGES[$container]}
start_container $container
fi
elif [ "$1" == "start" ]; then
if [ "$container" = "all" ];then
apps="postgres rabbitmq rsync astute rsyslog nailgun mcollective ostf nginx cobbler"
for service in $apps; do
start_container $service
#supervisorctl start $service
sleep 4
done
else
shift 2
start_container $container $@
fi
elif [ "$1" == "restart" ]; then
shift 2
restart_container $container $@
elif [ "$1" == "stop" ]; then
shift 2
stop_container $container $@
elif [ "$1" == "shell" ]; then
shift 2
shell_container $container $@
elif [ "$1" == "upgrade" ]; then
shift 2
upgrade_container $container $@
elif [ "$1" == "backup" ]; then
shift 2
backup_container $container $@
elif [ "$1" == "destroy" ]; then
shift 2
destroy_container $container $@
elif [ "$1" == "logs" ]; then
logs $container
else
echo "Invalid selection."
show_usage
fi