From: Ben Steffen Date: Mon, 9 Dec 2019 04:08:25 +0000 (-0500) Subject: Remove helper scripts for init files which will no longer exist X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-base.git/commitdiff_plain/66c87ef906c26d219edb6fee0d23f84b46695757 Remove helper scripts for init files which will no longer exist --- diff --git a/files/lib/init/config-init.sh b/files/lib/init/config-init.sh deleted file mode 100644 index 33ea582..0000000 --- a/files/lib/init/config-init.sh +++ /dev/null @@ -1,50 +0,0 @@ -# For a package which only configures another, "parent" package. -# -# Usage: -# PACKAGE=short-name -# GEN_FILES=(files to generate) -# PARENTPACKAGE=(parent-package another-parent-package) -# . /lib/init/config-init.sh -# config_init "$1" -# -# PACKAGE - name to appear in log message -# GEN_FILES - files to be generated with gen-files.sh -# PARENTPACKAGE - packages to receive start, etc, commands passed through -# -# Global variables GEN_FILES, PARENTPACKAGE may be unset for zero -# values, or scalars for one. If run under sh, they cannot be arrays. - -. /lib/init/vars.sh -. /lib/lsb/init-functions -. /lib/init/gen-files.sh - -if [ $BASH_VERSION ]; then - handle_parents () { - for p in "${PARENTPACKAGE[@]}"; do - invoke-rc.d "$p" "$1" - done - } -else - handle_parents () { - if [ -n "$PARENTPACKAGE" ]; then - invoke-rc.d "$PARENTPACKAGE" "$1" - fi - } -fi - -config_init () { - case "$1" in - start|reload|force-reload|restart) - log_begin_msg "Reloading config for $PACKAGE" - gen_files - log_end_msg $? - handle_parents "$1" - ;; - stop) - handle_parents "$1" - ;; - *) - log_success_msg "Usage: /etc/init.d/$PACKAGE {start|reload|force-reload|restart|stop}" - ;; - esac -} diff --git a/files/lib/init/gen-files.sh b/files/lib/init/gen-files.sh deleted file mode 100644 index 23ff8ad..0000000 --- a/files/lib/init/gen-files.sh +++ /dev/null @@ -1,17 +0,0 @@ -# Generates files from templates. -# Files should be named in an array variable GEN_FILES. -# If BASH_VERSION is null or unset, accepts only one file. - -if [ $BASH_VERSION ]; then - gen_files() - { - for f in "${GEN_FILES[@]}"; do - invirt-mako-render "$f".mako >"$f" - done - } -else - gen_files() - { - invirt-mako-render "$GEN_FILES".mako >"$GEN_FILES" - } -fi diff --git a/files/lib/init/std-init.sh b/files/lib/init/std-init.sh deleted file mode 100644 index 855ef23..0000000 --- a/files/lib/init/std-init.sh +++ /dev/null @@ -1,92 +0,0 @@ -# Typical Debian initscript, but as a library rather than copy-paste. -# -# Usage: -# NAME=short-name -# DESC="Textual description" -# SCRIPTNAME=/etc/init.d/$NAME # default if omitted -# . /lib/init/std-init.sh -# do_start() { ... } -# do_stop() { ... } -# do_reload() { ... } # optional -# std_init "$1" - -. /lib/init/vars.sh -. /lib/lsb/init-functions - -[ -r /etc/default/"$NAME" ] && . /etc/default/"$NAME" - -SCRIPTNAME="${SCRIPTNAME:-/etc/init.d/$NAME}" - -have_reload() -{ - type do_reload >/dev/null 2>/dev/null -} - -usage_exit() -{ - if have_reload; then - echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - else - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 - fi - exit 3 -} - -std_init() -{ - local cmd - case "$1" in - start|stop|restart) - cmd="$1" ;; - reload) - if have_reload; then cmd=reload; else usage_exit; fi ;; - force-reload) - if have_reload; then cmd=reload; else cmd=restart; fi ;; - *) - usage_exit ;; - esac - - case $cmd in - start) - [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" - do_start - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - stop) - [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; - 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; - esac - ;; - reload) - log_daemon_msg "Reloading $DESC" "$NAME" - do_reload - log_end_msg $? - ;; - restart) - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; - esac - - : -}