-
Notifications
You must be signed in to change notification settings - Fork 0
/
s6opts.in
executable file
·118 lines (102 loc) · 2.42 KB
/
s6opts.in
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/bash
# Copyright (C) 2015-2017 Eric Vidal <eric@obarun.org>
#
# This file is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
#
# This scripts is under License Beerware.
#
# "THE BEERWARE LICENSE" (Revision 42):
# <eric@obarun.org> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. Eric Vidal http://obarun.org
sourcing(){
local list
for list in /usr/lib/obarun/{common_functions,s6opts_functions} /etc/obarun/s6opts.conf; do
if [[ -f "${list}" ]]; then
source "${list}"
else
echo_error " Missing file : ${list}"
exit
fi
done
unset list
}
sourcing
shellopts_save
shellopts_set_unset "extglob" 0
(( EUID == 0 )) || die " You must be run this script with root privileges"
if [[ -z "${2}" && "${1}" != @(list|which_db|create) || -z "${3}" && "${1}" = @(add|delete|compile|all) ]]; then
usage
exit 1
fi
if [[ ! -h "${RC_DATABASE_COMPILED}/current" ]] || [[ ! -h "${RC_DATABASE_COMPILED}/previous" ]] \
|| [[ ! -h "${RC_DATABASE_COMPILED}/Default.src" ]]; then
cat << EOF
To properly manage the service database, the symlinks current|previous|Default.src must exist.
The default is :
/etc/s6-serv/enabled/rc/compiled/current -> /etc/s6-serv/enabled/rc/compiled/Default
/etc/s6-serv/enabled/rc/compiled/previous -> /etc/s6-serv/enabled/rc/compiled/Default
/etc/s6-serv/enabled/rc/compiled/Default.src -> /etc/s6-serv/enabled/rc/source/default
EOF
exit 1
fi
opts=( "${2}" )
where_which=( "${3}" )
case "${1}" in
add)
add "${opts}" "${where_which[@]}"
;;
delete)
delete "${opts}" "${where_which[@]}"
;;
compile)
compile "${opts}" "${where_which}"
;;
switch)
switch "${opts}"
;;
all)
all "${opts}" "${where_which}"
;;
update)
update "${opts[@]}"
;;
list)
list "${opts}"
;;
list_source)
list_source "${opts}"
;;
verbose)
verbose "${opts}"
;;
remove)
remove "${opts[@]}"
;;
remove_db)
remove_db "${opts[@]}"
;;
which_db)
which_db "${opts}"
;;
enable)
enable "${opts[@]}"
;;
disable)
disable "${opts[@]}"
;;
create)
create
;;
edit)
edit "${opts}"
;;
*)
usage
exit 1
;;
esac
shellopts_restore
exit 0