From: Ben Pfaff Date: Wed, 5 Jan 2011 19:00:41 +0000 (-0800) Subject: xenserver: Be compatible with non-XenServer func libraries in init script. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f83469de7edcbeb66449b8488d24a6cfbfb0898;p=openvswitch xenserver: Be compatible with non-XenServer func libraries in init script. XenServer has its function library in /etc/init.d/functions but other distros have it in different places. Currently this init script is specifically intended for XenServer but adding compatibility with other distros seems like a worthwhile goal. Also, SuSE does not have the "action" function, so test whether it is implemented and when not supply a fallback. Signed-off-by: Patrick Mullaney [changed to only define action() if not already defined] Signed-off-by: Ben Pfaff --- diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch index c77132a3..e404c60e 100755 --- a/xenserver/etc_init.d_openvswitch +++ b/xenserver/etc_init.d_openvswitch @@ -27,8 +27,35 @@ # Short-Description: Open vSwitch switch ### END INIT INFO +# source function library +if [ -f /etc/init.d/functions ]; then + . /etc/init.d/functions +elif [ -f /etc/rc.d/init.d/functions ]; then + . /etc/rc.d/init.d/functions +elif [ -f /lib/lsb/init-functions ]; then + . /lib/lsb/init-functions +else + echo "$0: missing LSB shell function library" >&2 + exit 1 +fi -. /etc/init.d/functions +if type action >/dev/null 2>&1; then + : +else + # SUSE lacks action + action() { + STRING=$1 + shift + "$@" + rc=$? + if [ $rc -eq 0 ] ; then + log_success_msg $"$STRING " + else + log_failure_msg $"$STRING " + fi + return $rc + } +fi . /etc/xensource-inventory test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch