aboutsummaryrefslogtreecommitdiff
path: root/src/bin/systemctl.ver1
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/systemctl.ver1')
-rwxr-xr-xsrc/bin/systemctl.ver165
1 files changed, 65 insertions, 0 deletions
diff --git a/src/bin/systemctl.ver1 b/src/bin/systemctl.ver1
new file mode 100755
index 0000000..74f29c4
--- /dev/null
+++ b/src/bin/systemctl.ver1
@@ -0,0 +1,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
bgstack15