3 # Provides: invirt-xen-config
4 # Required-Start: $local_fs $remote_fs
5 # Required-Stop: $local_fs $remote_fs
6 # Default-Start: 2 3 4 5
8 # Short-Description: Startup script for the Invirt Xen host
12 PACKAGE=invirt-xen-config
14 DESC="Invirt Xen host"
16 SYSVM_TEMPLATES=(/etc/xen/sysvms/s_*.mako)
17 SYSVM_FILES=("${SYSVM_TEMPLATES[@]/.mako/}")
18 SYSVMS=("${SYSVM_FILES[@]/#\/etc\/xen\/sysvms\/}")
19 GEN_FILES=(/etc/xen/xend-config.sxp.invirt "${SYSVM_FILES[@]}")
21 dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0
23 . /lib/init/gen-files.sh
24 . /lib/init/std-init.sh
27 # Attempt to start a sysvm, but only if it's not running already
28 # somewhere on the cluster
34 # Don't bother trying to start the VM if it's already running
35 if xm list "$VM" >/dev/null 2>&1; then
40 # To keep multiple hosts from trying to start a VM at the same
41 # time, lock VM creation at startup-time with a lock LV, since LV
43 if lvcreate -L 1K -n "lock_${LV}" xenvg >/dev/null 2>&1; then
44 # If we can disable the LV, then the VM isn't already running
46 if lvchange -a n "$DISK" >/dev/null 2>&1; then
47 lvchange -a y "$DISK" >/dev/null 2>&1
49 [ "$VERBOSE" != no ] && log_daemon_msg "Starting sysvm $VM"
50 xm create "sysvms/$VM" >/dev/null
51 [ "$VERBOSE" != no ] && log_end_msg $?
55 # Regardless of whether we could get the lock or not, the
56 # lvchange -a n probably disabled the LV somewhere; be sure we
58 lvchange -a y "$DISK" >/dev/null 2>&1
60 # Cleanup the lock, regardless of whether we started the LV
61 lvchange -a n "/dev/xenvg/lock_${LV}" >/dev/null 2>&1
62 lvchange -a ey "/dev/xenvg/lock_${LV}" >/dev/null 2>&1
63 lvremove -f "/dev/xenvg/lock_${LV}" >/dev/null 2>&1
72 for vm in "${SYSVMS[@]}"; do
76 echo 1 >/proc/sys/net/ipv4/ip_forward
77 for i in all default; do
78 echo 1 >/proc/sys/net/ipv4/conf/$i/rp_filter
79 echo 1 >/proc/sys/net/ipv4/conf/$i/proxy_arp
82 invoke-rc.d "$PARENTPACKAGE" "$1"
94 invoke-rc.d "$PARENTPACKAGE" stop