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 23XENSTORED_PIDFILE="@XEN_RUN_DIR@/xenstored.pid" 24XENCONSOLED_PIDFILE="@XEN_RUN_DIR@/xenconsoled.pid" 25XENBACKENDD_PIDFILE="@XEN_RUN_DIR@/xenbackendd.pid" 26#XENBACKENDD_DEBUG=1 27#XENCONSOLED_TRACE="@XEN_LOG_DIR@/xenconsole-trace.log" 28#XENSTORED_TRACE="@XEN_LOG_DIR@/xenstore-trace.log" 29 30xen_precmd() 31{ 32 mkdir -p @XEN_RUN_DIR@/xenstored || exit 1 33} 34 35xen_startcmd() 36{ 37 local time=0 38 local timeout=30 39 40 xenstored_pid=$(check_pidfile ${XENSTORED_PIDFILE} ${sbindir}/xenstored) 41 if test -z "$xenstored_pid"; then 42 printf "Cleaning xenstore database.\n" 43 if [ -z "${XENSTORED_ROOTDIR}" ]; then 44 XENSTORED_ROOTDIR="@XEN_LIB_STORED@" 45 fi 46 rm -f ${XENSTORED_ROOTDIR}/tdb* >/dev/null 2>&1 47 printf "Starting xenservices: xenstored, xenconsoled." 48 XENSTORED_ARGS=" --pid-file ${XENSTORED_PIDFILE}" 49 if [ -n "${XENSTORED_TRACE}" ]; then 50 XENSTORED_ARGS="${XENSTORED_ARGS} -T @XEN_LOG_DIR@/xenstored-trace.log" 51 fi 52 ${sbindir}/xenstored ${XENSTORED_ARGS} 53 while [ $time -lt $timeout ] && ! `${bindir}/xenstore-read -s / >/dev/null 2>&1` ; do 54 printf "." 55 time=$(($time+1)) 56 sleep 1 57 done 58 else 59 printf "Starting xenservices: xenconsoled." 60 fi 61 62 XENCONSOLED_ARGS="" 63 if [ -n "${XENCONSOLED_TRACE}" ]; then 64 XENCONSOLED_ARGS="${XENCONSOLED_ARGS} --log=${XENCONSOLED_TRACE}" 65 fi 66 67 ${sbindir}/xenconsoled ${XENCONSOLED_ARGS} 68 69 printf "\n" 70 71 printf "Setting domain 0 name, domid and JSON config...\n" 72 ${LIBEXEC_BIN}/xen-init-dom0 73} 74 75xen_stop() 76{ 77 pids="" 78 printf "Stopping xencommons.\n" 79 printf "WARNING: Not stopping xenstored, as it cannot be restarted.\n" 80 81 rc_pid=$(check_pidfile ${XENCONSOLED_PIDFILE} ${sbindir}/xenconsoled) 82 pids="$pids $rc_pid" 83 84 kill -${sig_stop:-TERM} $pids 85 wait_for_pids $pids 86} 87 88xen_status() 89{ 90 xenstored_pid=$(check_pidfile ${XENSTORED_PIDFILE} ${sbindir}/xenstored) 91 if test -n ${xenstored_pid}; then 92 pids="$pids $xenstored_pid" 93 fi 94 95 xenconsoled_pid=$(check_pidfile ${XENCONSOLED_PIDFILE} ${sbindir}/xenconsoled) 96 if test -n ${xenconsoled_pid}; then 97 pids="$pids $xenconsoled_pid" 98 fi 99 100 if test -n "$xenconsoled_pid" -a -n "$xenstored_pid"; 101 then 102 echo "xencommons are running as pids $pids." 103 return 0 104 fi 105 if test -z "$xenconsoled_pid" -a -z "$xenstored_pid"; 106 then 107 echo "xencommons are not running." 108 return 0 109 fi 110 111 if test -n $xenstored_pid; then 112 echo "xenstored is running as pid $xenstored_pid." 113 else 114 echo "xenstored is not running." 115 fi 116 if test -n $xenconsoled_pid; then 117 echo "xenconsoled is running as pid $xenconsoled_pid." 118 else 119 echo "xenconsoled is not running." 120 fi 121} 122 123load_rc_config $name 124run_rc_command "$1" 125