blob: 74f29c4ead1d5cbd85e285a55ac74ff9de6312be (
plain)
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
|
#!/bin/sh
# goal: handle various systemctl commands, particularly for freeipa
# restart X(.service)?
# start
# stop
# enable
# status
# disable
# mask
# unmask
# is-enabled
# list-unit-files --full
# is-active
# reload-or-try-restart X
# condrestart X
# daemon-reload --system
# --now
# log all parameters to learn usage
logfile=/var/log/systemctl.log
printf "%s\n" "${*}" >> "${logfile}"
evalparam() {
# call: evalparam "${_x}" "word/single/double" "${_thisparam}" "${_nextparam}"
printf "%s\n" "evalparam $*"
__paramposition="${1}"
__paramflaglevel="${2}"
__param="${3}"
__nextparam="${4}"
case "${__param}" in
"now")
esac
}
# iterate through all parameters
_param_count="${#}"
_x=0
while test ${_x} -lt ${_param_count} ;
do
_x=$(( _x + 1 ))
eval _thisparam="\${${_x}}"
test ${_x} -lt ${_param_count} && eval _nextparam="\${$(( _x + 1 ))}" || unset _nextparam
#printf "%s\n" "param ${_x} is \"${_thisparam}\" and next is \"${_nextparam:-UNDEFINED}\""
case "${_thisparam}" in
--*)
#printf "%s\n" "This is a double-dash! Send the whole thing."
evalparam "${_x}" "double" "${_thisparam##--}" "${_nextparam:-UNDEFINED}"
;;
-*)
#printf "%s\n" "This is a single dash! Send each char."
_i=2
while test ${_i} -le ${#_thisparam} ;
do
_char="$( printf '%s' "${_thisparam}" | cut -c ${_i})"
evalparam "${_x}" "single" "${_char}" "${_nextparam:-UNDEFINED}" "$(( _i -1 ))"
_i=$(( _i + 1 ))
done
unset _char
;;
*)
#printf "%s\n" "No dash. Evaluate this as a word."
evalparam "${_x}" "word" "${_thisparam}" "${_nextparam:-UNDEFINED}"
;;
esac
done
|