-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathdeploy.sh
67 lines (56 loc) · 1.66 KB
/
deploy.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
61
62
63
64
65
66
67
#!/bin/sh
# Linux Deploy Component
# (c) Anton Skshidlevsky <[email protected]>, GPLv3
[ -n "${INIT_USER}" ] || INIT_USER="root"
do_start()
{
#local init_level=$(grep ':initdefault:' "${CHROOT_DIR}/etc/inittab" | cut -f2 -d:)
[ -n "${INIT_LEVEL}" ] || return 0
local services=$(ls "${CHROOT_DIR}/etc/rc${INIT_LEVEL}.d/" | grep '^S')
if [ -n "${services}" ]; then
msg ":: Starting ${COMPONENT}: "
local item
for item in ${services}
do
msg -n "${item/S[0-9][0-9]/} ... "
if [ "${INIT_ASYNC}" = "true" ]; then
chroot_exec -u ${INIT_USER} "/etc/rc${INIT_LEVEL}.d/${item} start" 1>&2 &
else
chroot_exec -u ${INIT_USER} "/etc/rc${INIT_LEVEL}.d/${item} start" 1>&2
fi
is_ok "fail" "done"
done
fi
return 0
}
do_stop()
{
[ -n "${INIT_LEVEL}" ] || return 0
local services=$(ls "${CHROOT_DIR}/etc/rc6.d/" | grep '^K')
if [ -n "${services}" ]; then
msg ":: Stopping ${COMPONENT}: "
local item
for item in ${services}
do
msg -n "${item/K[0-9][0-9]/} ... "
if [ "${INIT_ASYNC}" = "true" ]; then
chroot_exec -u ${INIT_USER} "/etc/rc6.d/${item} stop" 1>&2 &
else
chroot_exec -u ${INIT_USER} "/etc/rc6.d/${item} stop" 1>&2
fi
is_ok "fail" "done"
done
fi
return 0
}
do_help()
{
cat <<EOF
--init-level="${INIT_LEVEL}"
Number of init level, e.g "3".
--init-user="${INIT_USER}"
Execute as specific user, by default "root".
--init-async
Asynchronous startup of processes.
EOF
}