From: Greg Price Date: Sun, 28 Dec 2008 07:56:18 +0000 (-0500) Subject: config-init.sh: degrade to non-bash gracefully X-Git-Tag: 0.0.18~4 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-base.git/commitdiff_plain/8bd0fc61a1fb3fa5f97dc03d432a60d5bfebf457 config-init.sh: degrade to non-bash gracefully svn path=/trunk/packages/invirt-base/; revision=1928 --- diff --git a/debian/changelog b/debian/changelog index ea065ed..c187e35 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ invirt-base (0.0.18) unstable; urgency=low * run_parts_list: fix unclear docstring + * config-init.sh: degrade to non-bash gracefully -- Greg Price Sun, 28 Dec 2008 01:00:07 -0500 diff --git a/files/lib/init/config-init.sh b/files/lib/init/config-init.sh index 04ca1a0..d9d1f76 100644 --- a/files/lib/init/config-init.sh +++ b/files/lib/init/config-init.sh @@ -1,30 +1,41 @@ # For a package which only configures another, "parent" package. # -# Global variable PARENTPACKAGE names parent; may be array -# for zero or many parents. +# Global variable PARENTPACKAGE names parent; unset for no parent, +# array for (zero or one or) many parents. # # Global variable PACKAGE names this package, for log message. # -# Requires bash. +# If BASH_VERSION is null or unset, accepts only one parent in +# PARENTPACKAGE, or empty for zero. . /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 $? - for p in "${PARENTPACKAGE[@]}"; do - invoke-rc.d "$p" "$1" - done + handle_parents "$1" ;; stop) - for p in "${PARENTPACKAGE[@]}"; do - invoke-rc.d "$p" "$1" - done + handle_parents "$1" ;; *) log_success_msg "Usage: /etc/init.d/$PACKAGE {start|reload|force-reload|restart|stop}"