1#!/bin/sh 2# 3# PROVIDE: xencommons 4# REQUIRE: DAEMON 5 6. /etc/rc.subr 7 8DIR=$(dirname "$0") 9. "${DIR}/xen-hotplugpath.sh" 10 11LD_LIBRARY_PATH="${libdir}" 12export LD_LIBRARY_PATH 13 14name="xencommons" 15rcvar=xend 16start_precmd="xen_precmd" 17start_cmd="xen_startcmd" 18stop_cmd="xen_stop" 19status_cmd="xen_status" 20extra_commands="status" 21required_files="/kern/xen/privcmd" 22 23XENCONSOLED_PIDFILE="@XEN_RUN_DIR@/xenconsoled.pid" 24#XENCONSOLED_TRACE="none|guest|hv|all" 25 26XENSTORED_PIDFILE="@XEN_RUN_DIR@/xenstored.pid" 27#XENSTORED_TRACE="@XEN_LOG_DIR@/xenstore-trace.log" 28 29xen_precmd() 30{ 31 mkdir -p @XEN_RUN_DIR@/xenstored || exit 1 32} 33 34xen_startcmd() 35{ 36 local time=0 37 local timeout=30 38 39 xenstored_pid=$(check_pidfile ${XENSTORED_PIDFILE} ${sbindir}/xenstored) 40 if test -z "$xenstored_pid"; then 41 printf "Starting xenservices: xenstored, xenconsoled." 42 XENSTORED_ARGS=" --pid-file ${XENSTORED_PIDFILE}" 43 if [ -n "${XENSTORED_TRACE}" ]; then 44 XENSTORED_ARGS="${XENSTORED_ARGS} -T @XEN_LOG_DIR@/xenstored-trace.log" 45 fi 46 ${sbindir}/xenstored ${XENSTORED_ARGS} 47 while [ $time -lt $timeout ] && ! `${bindir}/xenstore-read -s / >/dev/null 2>&1` ; do 48 printf "." 49 time=$(($time+1)) 50 sleep 1 51 done 52 else 53 printf "Starting xenservices: xenconsoled." 54 fi 55 56 XENCONSOLED_ARGS="" 57 if [ -n "${XENCONSOLED_TRACE}" ]; then 58 XENCONSOLED_ARGS="${XENCONSOLED_ARGS} --log=${XENCONSOLED_TRACE}" 59 fi 60 61 ${sbindir}/xenconsoled ${XENCONSOLED_ARGS} 62 63 printf "\n" 64 65 printf "Setting domain 0 name, domid and JSON config...\n" 66 ${LIBEXEC_BIN}/xen-init-dom0 67} 68 69xen_stop() 70{ 71 pids="" 72 printf "Stopping xencommons.\n" 73 printf "WARNING: Not stopping xenstored, as it cannot be restarted.\n" 74 75 rc_pid=$(check_pidfile ${XENCONSOLED_PIDFILE} ${sbindir}/xenconsoled) 76 pids="$pids $rc_pid" 77 78 kill -${sig_stop:-TERM} $pids 79 wait_for_pids $pids 80} 81 82xen_status() 83{ 84 xenstored_pid=$(check_pidfile ${XENSTORED_PIDFILE} ${sbindir}/xenstored) 85 if test -n ${xenstored_pid}; then 86 pids="$pids $xenstored_pid" 87 fi 88 89 xenconsoled_pid=$(check_pidfile ${XENCONSOLED_PIDFILE} ${sbindir}/xenconsoled) 90 if test -n ${xenconsoled_pid}; then 91 pids="$pids $xenconsoled_pid" 92 fi 93 94 if test -n "$xenconsoled_pid" -a -n "$xenstored_pid"; 95 then 96 echo "xencommons are running as pids $pids." 97 return 0 98 fi 99 if test -z "$xenconsoled_pid" -a -z "$xenstored_pid"; 100 then 101 echo "xencommons are not running." 102 return 0 103 fi 104 105 if test -n $xenstored_pid; then 106 echo "xenstored is running as pid $xenstored_pid." 107 else 108 echo "xenstored is not running." 109 fi 110 if test -n $xenconsoled_pid; then 111 echo "xenconsoled is running as pid $xenconsoled_pid." 112 else 113 echo "xenconsoled is not running." 114 fi 115} 116 117load_rc_config $name 118run_rc_command "$1" 119