summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2020-12-10 07:02:15 (EST)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2020-12-10 07:02:44 (EST)
commit315f395aaa844d4a257fb0c9c90a4dd4a19d106c (patch)
tree381d4030587f19ef24e9606336d2c3a231db77f1
parent10ca6a375343b3f61c4ecc0a48372c15964d7d0a (diff)
/etc/rc.common: Rearrange functions
-rw-r--r--src.etc/rc.common97
1 files changed, 44 insertions, 53 deletions
diff --git a/src.etc/rc.common b/src.etc/rc.common
index 50c6020..9db482b 100644
--- a/src.etc/rc.common
+++ b/src.etc/rc.common
@@ -17,37 +17,25 @@ EXTRA_COMMANDS=''
START=''
STOP=''
-main()
-{
- local action=
- local es=
-
- SCRIPT="${1}"
-
- . "${SCRIPT}"
+# Default function definitions
+stop() { :; }
+restart() { stop; start; }
- ALL_CMDS=" start stop restart ${EXTRA_COMMANDS} "
- if [ "x${START:+set}" = 'xset' ] || [ "x${STOP:+set}" = 'xset' ]; then
- ALL_CMDS="${ALL_CMDS} enable disable "
- fi
+enable()
+{
+ local name="${SCRIPT##*/}"
+ name="${name#[SK][0-9][0-9]}"
+ [ "x${START:+set}" = 'xset' ] && \
+ ln -sf "../init.d/${name}" "/etc/rc.d/S${START}${name}"
+ [ "x${STOP:+set}" = 'xset' ] && \
+ ln -sf "../init.d/${name}" "/etc/rc.d/K${STOP}${name}"
+}
- if [ ${#} -ne 2 ]; then
- usage
- return 1
- fi
- action="${2:-<unknown>}"
- if [ "x${ALL_CMDS#* ${action} }" != "x${ALL_CMDS}" ]; then
- [ "x${action%able}" = "x${action}" ] && \
- [ -f /etc/rc.policy ] && \
- [ "x$(cat /etc/rc.policy)" = 'xdisabled' ] && return 0
- ${action}
- es=${?}
- log_end ${es}
- return ${es}
- else
- usage
- return 1
- fi
+disable()
+{
+ local name="${SCRIPT##*/}"
+ name="${name#[SK][0-9][0-9]}"
+ rm -f /etc/rc.d/[SK][0-9][0-9]"${name}"
}
tty_printf()
@@ -95,34 +83,37 @@ log_end()
esac
}
-# Default function definitions
-
-stop()
+main()
{
- :
-}
+ local action=
+ local es=
-restart()
-{
- stop
- start
-}
+ SCRIPT="${1}"
-enable()
-{
- local name="${SCRIPT##*/}"
- name="${name#[SK][0-9][0-9]}"
- [ "x${START:+set}" = 'xset' ] && \
- ln -sf "../init.d/${name}" "/etc/rc.d/S${START}${name}"
- [ "x${STOP:+set}" = 'xset' ] && \
- ln -sf "../init.d/${name}" "/etc/rc.d/K${STOP}${name}"
-}
+ . "${SCRIPT}"
-disable()
-{
- local name="${SCRIPT##*/}"
- name="${name#[SK][0-9][0-9]}"
- rm -f /etc/rc.d/[SK][0-9][0-9]"${name}"
+ ALL_CMDS=" start stop restart ${EXTRA_COMMANDS} "
+ if [ "x${START:+set}" = 'xset' ] || [ "x${STOP:+set}" = 'xset' ]; then
+ ALL_CMDS="${ALL_CMDS} enable disable "
+ fi
+
+ if [ ${#} -ne 2 ]; then
+ usage
+ return 1
+ fi
+ action="${2:-<unknown>}"
+ if [ "x${ALL_CMDS#* ${action} }" != "x${ALL_CMDS}" ]; then
+ [ "x${action%able}" = "x${action}" ] && \
+ [ -f /etc/rc.policy ] && \
+ [ "x$(cat /etc/rc.policy)" = 'xdisabled' ] && return 0
+ ${action}
+ es=${?}
+ log_end ${es}
+ return ${es}
+ else
+ usage
+ return 1
+ fi
}
main "${@}"