X-Git-Url: https://git.tld-linux.org/?p=packages%2Fqemu.git;a=blobdiff_plain;f=qemu-guest-agent.init;fp=qemu-guest-agent.init;h=2ca1ec56df4013a4635b98485b70fa2611c87613;hp=0000000000000000000000000000000000000000;hb=1808542e6fa13980600d8c824a60da2182ba9c7b;hpb=396c5acf7980f51815dcac219573c9fffc824c1d diff --git a/qemu-guest-agent.init b/qemu-guest-agent.init new file mode 100755 index 0000000..2ca1ec5 --- /dev/null +++ b/qemu-guest-agent.init @@ -0,0 +1,124 @@ +#!/bin/sh +# +# qemu-ga qemu-ga QEMU Guest Agent +# +# chkconfig: 345 12 88 +# +# description: qemu-ga QEMU Guest Agent + +# Source function library +. /etc/rc.d/init.d/functions + +# Get service config - may override defaults +[ -f /etc/sysconfig/qemu-ga ] && . /etc/sysconfig/qemu-ga + +pidfile="/var/run/qemu-ga.pid" + +# configtest itself +# must return non-zero if check failed +# output is discarded if checkconfig is ran without details +configtest() { + /usr/bin/qemu-ga -D + return $? +} + +# wrapper for configtest +checkconfig() { + local details=${1:-0} + + if [ $details = 1 ]; then + # run config test and display report (status action) + show "Checking %s configuration" "qemu-ga"; busy + local out + out=$(configtest 2>&1) + RETVAL=$? + if [ $RETVAL = 0 ]; then + ok + else + fail + fi + [ "$out" ] && echo >&2 "$out" + else + # run config test and abort with nice message if failed + # (for actions checking status before action). + configtest >/dev/null 2>&1 + RETVAL=$? + if [ $RETVAL != 0 ]; then + show "Checking %s configuration" "qemu-ga"; fail + nls 'Configuration test failed. See details with %s "checkconfig"' $0 + exit $RETVAL + fi + fi +} + +start() { + # Check if the service is already running? + if [ -f /var/lock/subsys/qemu-ga ]; then + msg_already_running "qemu-ga" + return + fi + + checkconfig + msg_starting "qemu-ga" + daemon /usr/bin/qemu-ga -d -l /var/log/qemu-ga + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/qemu-ga +} + +stop() { + if [ ! -f /var/lock/subsys/qemu-ga ]; then + msg_not_running "qemu-ga" + return + fi + + # Stop daemons. + msg_stopping "qemu-ga" + killproc --pidfile $pidfile qemu-ga -TERM + rm -f /var/lock/subsys/qemu-ga +} + +condrestart() { + if [ ! -f /var/lock/subsys/qemu-ga ]; then + msg_not_running "qemu-ga" + RETVAL=$1 + return + fi + + checkconfig + stop + start +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + checkconfig + stop + start + ;; + try-restart) + condrestart 0 + ;; + force-reload) + condrestart 7 + ;; + checkconfig|configtest) + checkconfig 1 + ;; + status) + status --pidfile $pidfile qemu-ga + RETVAL=$? + ;; + *) + msg_usage "$0 {start|stop|restart|try-restart|force-reload|checkconfig|status}" + exit 3 +esac + +exit $RETVAL