-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathS80dockercompose
executable file
·71 lines (56 loc) · 1.49 KB
/
S80dockercompose
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
#!/bin/bash
SYS_CONF=/etc/docker-compose.yml
BOOT_CONF=/boot/docker-compose.yml
USER_CONF=/data/etc/docker-compose.yml
PROG=/usr/bin/docker-compose
LOG=/var/log/docker-compose.log
PROJ=system
RUN_DIR=/var/run/docker-compose
test -x ${PROG} || exit 0
test -n "${OS_VERSION}" || source /etc/init.d/base
CONF=$(select_conf ${SYS_CONF} ${BOOT_CONF} ${USER_CONF})
test -s ${CONF} || exit 0
function start() {
msg_begin "Starting docker-compose"
# Wait for dockerd to start
running=false
for ((i=0; i < 30; i++)); do
if docker ps &>/dev/null; then
running=true
break
fi
sleep 1
done
if [[ ${running} != true ]]; then
msg_fail "dockerd not running"
return
fi
mkdir -p ${RUN_DIR}
export COMPOSE_HTTP_TIMEOUT=300
${PROG} -p ${PROJ} --project-directory ${RUN_DIR} -f ${CONF} pull &>${LOG}
${PROG} -p ${PROJ} --project-directory ${RUN_DIR} -f ${CONF} up --no-start &>>${LOG}
${PROG} -p ${PROJ} --project-directory ${RUN_DIR} -f ${CONF} up -d &>>${LOG}
test $? == 0 && msg_done || msg_fail
}
function stop() {
msg_begin "Stopping docker-compose"
${PROG} -p ${PROJ} --project-directory ${RUN_DIR} -f ${CONF} stop &>>${LOG}
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $?