source: trunk/packages/invirt-xen-config/debian/invirt-xen-config.init @ 1461

Last change on this file since 1461 was 1460, checked in by broder, 16 years ago

Forgot to actually add the path onto the sysvms for generating the
config files

  • Property svn:executable set to *
File size: 2.0 KB
RevLine 
[1275]1#!/bin/bash
[1257]2### BEGIN INIT INFO
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
7# Default-Stop:      0 1 6
8# Short-Description: Startup script for the Invirt Xen host
9# Description:       
10### END INIT INFO
11
[1261]12PACKAGE=invirt-xen-config
[1275]13NAME="$PACKAGE"
[1280]14DESC="Invirt Xen host"
[1261]15PARENTPACKAGE=xend
[1457]16GEN_FILES=(/etc/xen/xend-config.sxp.invirt)
17SYSVMS=(s_master s_remote s_console)
18i=1
19for vm in "${SYSVMS[@]}"; do
[1460]20    GEN_FILES[$i]="/etc/xen/sysvms/$vm"
[1459]21    i=$((i + 1))
[1457]22done
[1257]23
[1261]24dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0
25
26. /lib/init/gen-files.sh
27. /lib/init/std-init.sh
28
[1457]29start_sysvm() {
30    # Attempt to start a sysvm, but only if it's not running already
31    # somewhere on the cluster
32   
33    VM="$1"
34    DISK="/dev/xenvg/${VM}_hda"
35   
36    # Don't bother trying to start the VM if it's already running
37    if xm list "$1" >/dev/null 2>&1; then
38        return 1
39    fi
40   
41    if lvchange -a n "$DISK" >/dev/null 2>&1 && lvchange -a ey "$DISK" >/dev/null 2>&1; then
42        # If we can lock on the VM's disk, then the VM isn't running
43        [ "$VERBOSE" != no ] && log_daemon_msg "Starting sysvm $VM"
44        xm create "sysvms/$VM" >/dev/null
45        [ "$VERBOSE" != no ] && log_end_msg $?
46        RET=0
47    else
48        RET=1
49    fi
50   
51    # Regardless of whether we could get the lock or not, the
52    # lvchange -a n probably disabled the LV somewhere; be sure we
53    # clean up
54    lvchange -a y "$DISK" >/dev/null 2>&1
55   
56    return $RET
57}
58
[1275]59do_startup() {
[1261]60    gen_files
61   
[1457]62    for vm in "${SYSVMS[@]}"; do
63        start_sysvm "$vm"
64    done
65   
[1257]66    echo 1 >/proc/sys/net/ipv4/ip_forward
[1261]67    for i in all default; do
68        echo 1 >/proc/sys/net/ipv4/conf/$i/rp_filter
69        echo 1 >/proc/sys/net/ipv4/conf/$i/proxy_arp
[1257]70    done
[1261]71   
72    invoke-rc.d "$PARENTPACKAGE" "$1"
73}
74
[1275]75do_start() {
76    do_startup "start"
77}
78
[1261]79do_reload() {
[1275]80    do_startup "reload"
[1261]81}
82
83do_stop() {
[1277]84    invoke-rc.d "$PARENTPACKAGE" stop
[1261]85}
86
87std_init "$1"
Note: See TracBrowser for help on using the repository browser.