[ovs-dev] [suse 2/7] xenserver: Be compatible with non-XenServer func libraries in init script.
Ben Pfaff
blp at nicira.com
Wed Dec 15 19:18:59 UTC 2010
From: Patrick Mullaney <pm.mullaney at gmail.com>
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 <pm.mullaney at gmail.com>
[changed to only define action() if not already defined]
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
xenserver/etc_init.d_openvswitch | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch
index 69d62c9..a81643d 100755
--- a/xenserver/etc_init.d_openvswitch
+++ b/xenserver/etc_init.d_openvswitch
@@ -28,8 +28,34 @@
# Description: virtual 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
+ exit 0
+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
--
1.7.1
More information about the dev
mailing list