From 6f83469de7edcbeb66449b8488d24a6cfbfb0898 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 5 Jan 2011 11:00:41 -0800 Subject: [PATCH] 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 --- xenserver/etc_init.d_openvswitch | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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 -- 2.30.2