Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 121 lines (105 sloc) 3.47 KB
#! /bin/sh
################################################################
# Begin xlapp-domains
#
# Description : Start Xen Domains
#
# Author : Qrux - qrux dot qed @ gmail.com
#
# Version : X/LAPP-0.01
#
################################################################
### BEGIN INIT INFO
# Provides: xlapp-domains
# Required-Start: xencommons
# Should-Start: network
# Required-Stop: sendsignals
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Starts Xen Domains.
# Description: Starts Xen Domains.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
XLAPP_COMMAND=/usr/sbin/xl
XLAPP_AUTO_DOMAIN_DIR=/etc/xen/auto
XLAPP_RUN_DIR=/var/run/xlapp
XLAPP_SHUTDOWN_TIMEOUT=60
XLAPP_INTERVAL_BETWEEN_DOTS=1
CMD="${1}"
if [ ! -x ${XLAPP_COMMAND} ] ; then
log_warning_msg "Xen domain-management command [ ${XLAPP_COMMAND} ] missing; aborting"
exit
fi
if [ ! -d $XLAPP_RUN_DIR ] ; then
log_info_msg "Creating X/LAPP run dir [ $XLAPP_RUN_DIR ] to track started domains..."
mkdir -p ${XLAPP_RUN_DIR} > /dev/null 2>&1
evaluate_retval
fi
case "${CMD}" in
# Check definitions dir
# Check for definitions
# For each definition...
# xl create <domain>
start)
if [ ! -d $XLAPP_AUTO_DOMAIN_DIR ] ; then log_info_msg "Auto-start domain dir [ $XLAPP_AUTO_DOMAIN_DIR ] doesn't exist; exiting.\n" ; exit ; fi
is_dir_empty $XLAPP_AUTO_DOMAIN_DIR
if [ 1 -ne $? ] ; then log_info_msg "No auto-start domain definitions found; exiting.\n" ; exit ; fi
log_info_msg "Starting auto-start Xen Domains...\n"
for _XD in $(echo ${XLAPP_AUTO_DOMAIN_DIR}/*) ; do
_XDNAME=$(basename ${_XD} | cut -d '.' -f 1)
log_info_msg " Starting [ ${_XDNAME} ] DomU ..."
echo "Starting [ ${_XDNAME} ] DomU from config file [ ${_XD} ]..." > ${XLAPP_RUN_DIR}/start-${_XDNAME}
${XLAPP_COMMAND} create ${_XD} >> ${XLAPP_RUN_DIR}/start-${_XDNAME} 2>&1
if [ 0 -eq $? ] ; then
true
else
mv ${XLAPP_RUN_DIR}/start-${_XDNAME} ${XLAPP_RUN_DIR}/FAIL-${_XDNAME}
false
fi
evaluate_retval
done
;;
# Check auto-start run dir
# Check for auto-started domains
# For each auto-started domain
# xl create <domain>
stop)
if [ ! -d $XLAPP_RUN_DIR ] ; then log_info_msg "Auto-start domain run dir [ $XLAPP_RUN_DIR ] doesn't exist; exiting.\n" ; exit ; fi
is_dir_empty $XLAPP_RUN_DIR
if [ 1 -ne $? ] ; then log_info_msg "No auto-start domains started; exiting.\n" ; exit ; fi
log_info_msg "Shutting down auto-started Xen Domains...\n"
_XDLIST=$(xl list | egrep -v "^Name[[:space:]]|^Domain-0[[:space:]]" | awk '{print $1}')
log_info_msg " domU list: $(echo ${_XDLIST})\n"
for _XD in $(echo ${_XDLIST}) ; do
log_info_msg " Shutting down [ ${_XD} ] DomU..."
# Uncomment this when working!
#${XLAPP_COMMAND} shutdown -w ${_XD} > ${XLAPP_RUN_DIR}/stop-${_XD} 2>&1
${XLAPP_COMMAND} shutdown ${_XD} > ${XLAPP_RUN_DIR}/stop-${_XD} 2>&1
${XLAPP_COMMAND} console ${_XD}
# Wait 10 seconds, and see if the VM actually stopped...
#_GOOD_SHUTDOWN=1
#for _WAIT in $(seq 1 $((${XLAPP_SHUTDOWN_TIMEOUT} / ${XLAPP_INTERVAL_BETWEEN_DOTS}))) ; do
#${XLAPP_COMMAND} list | awk '{print $1}' | grep -w "${_XD}" > /dev/null
#if [ $? -ne 0 ] ; then
#_GOOD_SHUTDOWN=0
#break
#else
#echo -e -n "."
#sleep ${XLAPP_INTERVAL_BETWEEN_DOTS}
#fi
#done
#test 0 -eq ${_GOOD_SHUTDOWN}
evaluate_retval
done
;;
status)
${XLAPP_COMMAND} list
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac
# End xlapp-domains bootscript
You can’t perform that action at this time.