Zhou Zheng Sheng has uploaded a new change for review.
Change subject: make vdsmd.init.in adapt to both Fedora and Ubuntu ......................................................................
make vdsmd.init.in adapt to both Fedora and Ubuntu
The patch is on going work of porting VDSM to Ubuntu http://www.ovirt.org/VDSM_on_Ubuntu
Change-Id: I186743ed7fd345bf150047d4005818e1df3c07fc Signed-off-by: Zhou Zheng Sheng zhshzhou@linux.vnet.ibm.com --- M vdsm/vdsmd.init.in 1 file changed, 75 insertions(+), 24 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/13489/1
diff --git a/vdsm/vdsmd.init.in b/vdsm/vdsmd.init.in index c804ce8..85bc61b 100755 --- a/vdsm/vdsmd.init.in +++ b/vdsm/vdsmd.init.in @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash # # Copyright 2006-2010 Red Hat, Inc. and/or its affiliates. # @@ -23,6 +23,16 @@
. @LIBEXECDIR@/ovirt_functions.sh
+choosePath() { + for P in "$@"; do + if [ -e "$P" ]; then + echo "$P" + return 0 + fi + done + echo "$1" +} + VDSM_BIN=@VDSMDIR@/vdsm CONF_FILE=@CONFDIR@/vdsm.conf GETCONFITEM=@VDSMDIR@/get-conf-item @@ -33,7 +43,24 @@ DOM_METADATA_BACKUP_DIR=/var/log/vdsm/backup CORE_PATTERN=/proc/sys/kernel/core_pattern QEMU_DUMP_PATH="/var/log/core" -NEEDED_SERVICES="iscsid multipathd ntpd wdmd sanlock network" +SERVICE="$(choosePath /sbin/service /usr/sbin/service)" +LOCK_PATH="$(choosePath /var/lock/subsys /var/lock)" + +ISCSID=iscsid +LIBVIRTD=libvirtd +MULTIPATHD=multipathd +NETWORK=network +NTPD=ntpd +SANLOCK=sanlock +WDMD=wdmd +if grep -i ubuntu /etc/*-release >/dev/null 2>&1; then + ISCSID=open-iscsi + LIBVIRTD=libvirt-bin + MULTIPATHD=multipath-tools + NETWORK=netowking + NTPD=ntp +fi +NEEDED_SERVICES="$ISCSID $MULTIPATHD $NTPD $WDMD $SANLOCK $NETWORK" CONFLICTING_SERVICES="libvirt-guests"
# trigger for reconfiguration @@ -41,7 +68,7 @@
LCONF=/etc/libvirt/libvirtd.conf QCONF=/etc/libvirt/qemu.conf -LDCONF=/etc/sysconfig/libvirtd +LDCONF="$(choosePath /etc/sysconfig/libvirtd /etc/default/libvirt-bin)" QLCONF=/etc/libvirt/qemu-sanlock.conf
is_coredump=`$GETCONFITEM $CONF_FILE vars core_dump_enable false | tr A-Z a-z` @@ -49,10 +76,17 @@
SYSTEMCTL_SKIP_REDIRECT=true
-. /etc/init.d/functions - -log_failure_msg() { echo -n "$@"; failure "$@"; echo; } -log_success_msg() { echo -n "$@"; success "$@"; echo; } +if [ -e /etc/init.d/functions ]; then + . /etc/init.d/functions + log_failure_msg() { echo -n "$@"; failure "$@"; echo; } + log_success_msg() { echo -n "$@"; success "$@"; echo; } +else + . /lib/lsb/init-functions + # log_failure_msg and log_success_msg are defined already + # in /lib/lsb/init-functions + failure() { local rc=$?; log_failure_msg; return "$rc"; } + success() { log_success_msg; return 0; } +fi
mk_data_center() { local dc @@ -122,13 +156,13 @@
for srv in $CONFLICTING_SERVICES do - /sbin/chkconfig $srv off - if /sbin/service $srv status > /dev/null 2>&1; + disable_service_sysv $srv + if "$SERVICE" $srv status > /dev/null 2>&1; then if [ "$srv" == "libvirt-guests" ]; then - /bin/rm -f /var/lock/subsys/libvirt-guests + /bin/rm -f "$LOCK_PATH/libvirt-guests" else - /sbin/service $srv stop + "$SERVICE" $srv stop fi fi done @@ -145,10 +179,10 @@
for srv in $NEEDED_SERVICES do - if ! /sbin/service $srv status > /dev/null 2>&1; + if ! "$SERVICE" $srv status > /dev/null 2>&1; then echo "Starting $srv..." - /sbin/service $srv start + "$SERVICE" $srv start ret_val=$? if [ $ret_val -ne 0 ] then @@ -158,7 +192,7 @@ fi done
- /sbin/service iscsid force-start + "$SERVICE" $ISCSID force-start || true }
test_lo() { @@ -216,7 +250,7 @@ # Remove configuration created by vdsm (old "# by vdsm" and the new format) # Argument: configuration file that will be inspected remove_vdsm_conf() { - sed -i --copy -e "/${start_conf_section}/,/${end_conf_section}/d" \ + sed -i -e "/${start_conf_section}/,/${end_conf_section}/d" \ -e "/$by_vdsm/d" "$@" }
@@ -363,7 +397,7 @@ ovirt_store_config "$lconf" "$qconf" "$ldconf" "$llogr"
if libvirt_should_use_upstart; then - /sbin/initctl restart libvirtd 2>/dev/null || : + /sbin/initctl restart $LIBVIRTD 2>/dev/null || : else /bin/systemctl restart libvirtd.service fi @@ -394,12 +428,22 @@ configure_libvirt $args }
+disable_service_sysv() { + if [ -e /sbin/chkconfig ]; then + /sbin/chkconfig "$1" off + elif [ -e /usr/sbin/update-rc.d ]; then + /usr/sbin/update-rc.d "$1" disable + else + false + fi +} + stop_libvirtd_sysv() { # stop libvirt SysV service if we intend to configure upstart
- if libvirt_should_use_upstart && ! [[ -f /etc/init/libvirtd.conf ]]; then - /sbin/chkconfig libvirtd off - /sbin/service libvirtd stop + if libvirt_should_use_upstart && ! [[ -f /etc/init/"$LIBVIRTD".conf ]]; then + disable_service_sysv $LIBVIRTD + "$SERVICE" $LIBVIRTD stop fi }
@@ -408,7 +452,7 @@ local startout
if ! libvirt_should_use_upstart; then - /sbin/service libvirtd start + "$SERVICE" $LIBVIRTD start return fi
@@ -422,7 +466,7 @@ /sbin/initctl reload-configuration fi
- startout=`/sbin/initctl start libvirtd 2>&1` + startout=`/sbin/initctl start $LIBVIRTD 2>&1` if [[ "$?" -eq 0 || "$startout" =~ .*already\ running.* ]]; then return 0 @@ -505,12 +549,19 @@ echo $"Starting up vdsm daemon: " local vdsm_nice=`$GETCONFITEM $CONF_FILE vars vdsm_nice -5`
+ if type daemon >/dev/null 2>&1; then + RUNDAEMON="daemon --user=vdsm" + elif type start_daemon >/dev/null 2>&1; then + RUNDAEMON="start_daemon -n $vdsm_nice -- /usr/bin/sudo -u vdsm" + else + RUNDAEMON="false" + fi LIBVIRT_LOG_FILTERS=`$GETCONFITEM $CONF_FILE vars libvirt_log_filters "1:libvirt 1:remote"` \ LIBVIRT_LOG_OUTPUTS=`$GETCONFITEM $CONF_FILE vars libvirt_log_outputs "1:file:/var/log/vdsm/libvirt.log"` \ - LC_ALL=C NICELEVEL=$vdsm_nice daemon --user=vdsm @VDSMDIR@/respawn --minlifetime 10 --daemon --masterpid $RESPAWNPIDFILE $VDSM_BIN + LC_ALL=C NICELEVEL=$vdsm_nice $RUNDAEMON @VDSMDIR@/respawn --minlifetime 10 --daemon --masterpid $RESPAWNPIDFILE $VDSM_BIN RETVAL=$? [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog start" || log_failure_msg $"$prog start" - [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vdsmd + [ "$RETVAL" -eq 0 ] && touch "$LOCK_PATH/vdsmd" }
stop() { @@ -525,7 +576,7 @@ killproc -p $PIDFILE -d 2 RETVAL=$? [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog stop" || log_failure_msg $"$prog stop" - [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vdsmd + [ "$RETVAL" -eq 0 ] && rm -f "LOCK_PATH/vdsmd" fi python @VDSMDIR@/hooks.pyc after_vdsm_stop return $RETVAL
-- To view, visit http://gerrit.ovirt.org/13489 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I186743ed7fd345bf150047d4005818e1df3c07fc Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Zhou Zheng Sheng zhshzhou@linux.vnet.ibm.com