From: Thomas D Date: Fri, 11 Sep 2015 13:06:48 +0000 (-0500) Subject: app-emulation/libvirt: improve new init scripts X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=05d61cc5818612056666915e2e4177ada55c5583;p=gentoo.git app-emulation/libvirt: improve new init scripts Improvement to the new init scripts to use more bits from runscripts instead of rolling our own. Signed-off-by: Doug Goldstein --- diff --git a/app-emulation/libvirt/files/libvirtd.confd-r5 b/app-emulation/libvirt/files/libvirtd.confd-r5 index 3463cb95f275..c326531d469f 100644 --- a/app-emulation/libvirt/files/libvirtd.confd-r5 +++ b/app-emulation/libvirt/files/libvirtd.confd-r5 @@ -6,6 +6,11 @@ # for libvirtd, you may override this. Or if you only use libvirtd locally. rc_need="net" +# The termination timeout (start-stop-daemon parameter "retry") ensures +# that the service will be terminated within a given time (25 + 5 seconds +# per default) when you are stopping the service. +#LIBVIRTD_TERMTIMEOUT="TERM/25/KILL/5" + # LIBVIRTD_OPTS # You may want to add '--listen' to have libvirtd listen for tcp/ip connections # if you want to use libvirt for remote control diff --git a/app-emulation/libvirt/files/libvirtd.init-r15 b/app-emulation/libvirt/files/libvirtd.init-r15 index 7b95bd866015..0c529bd7e78b 100644 --- a/app-emulation/libvirt/files/libvirtd.init-r15 +++ b/app-emulation/libvirt/files/libvirtd.init-r15 @@ -1,35 +1,38 @@ #!/sbin/runscript +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ description="Virtual Machine Management daemon (libvirt)" +LIBVIRTD_OPTS=${LIBVIRTD_OPTS:-"${LIBVIRTD_OPTS}"} +LIBVIRTD_TIMEOUT=${LIBVIRTD_TERMTIMEOUT:-"TERM/25/KILL/5"} + +command="/usr/sbin/libvirtd" +command_args="-d ${LIBVIRTD_OPTS}" +start_stop_daemon_args="--env KRB5_KTNAME=/etc/libvirt/krb5.tab" +pidfile="/var/run/libvirtd.pid" +retry="${LIBVIRTD_TERMTIMEOUT}" + depend() { USE_FLAG_FIREWALLD use USE_FLAG_AVAHI USE_FLAG_ISCSI USE_FLAG_RBD dbus virtlockd after ntp-client ntpd nfs nfsmount portmap rpc.statd iptables ip6tables ebtables corosync sanlock cgconfig xenconsoled } -start() { +start_pre() { # Test configuration directories in /etc/libvirt/ to be either not # present or a directory, i.e. not a regular file, bug #532892 + local has_errors=0 + ebegin "Checking for suitable directories in \"/etc/libvirt\"" + for dir in lxc nwfilter qemu storage; do if [ -f /etc/libvirt/$dir ]; then + has_errors=1 eerror "/etc/libvirt/$dir was created as a regular file. It must be either" eerror "a directory or not present for libvirtd to start up successfully." - return 1 fi done - ebegin "Starting libvirtd" - start-stop-daemon --start \ - --env KRB5_KTNAME=/etc/libvirt/krb5.tab \ - --exec /usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid \ - -- -d ${LIBVIRTD_OPTS} - eend $? -} - -stop() { - ebegin "Stopping libvirtd without shutting down your VMs" - start-stop-daemon --stop --quiet --exec \ - /usr/sbin/libvirtd --pidfile=/var/run/libvirtd.pid - eend $? + eend ${has_errors} "Please correct the error(s) above" }