~gandelman-a/nova/libvirt_refresh_2

« back to all changes in this revision

Viewing changes to debian/nova-volume.init

  • Committer: Chuck Short
  • Date: 2012-02-29 20:08:26 UTC
  • mfrom: (312.1.5 debian-merge)
  • Revision ID: zulcss@ubuntu.com-20120229200826-3s2nektpbonk1dfs
* debain/control: Fix nova-compute-$flavor Depends
* debian/rules: Fix FTBFS.
* Merge Ubuntu/Debian packaging:
  - Thanks to Julien Danjou, Ghe Rivero, and Thomas Goirand
  - debian/copyright: Update copyright file.
  - debian/nova-api.init, debian/nova-compute.init,
    debian/nova-network.init, debian/nova-objectstore,
    debian/nova-scheduler, debian/nova-volume.init:
    Synchronize init scripts.
  - nova-common.install, debian/rules: Install policy.json
  - debian/rules, debian/nova-xcp-network.install,
    debian/nova-xcp-plugins.install, nova-xcp-plugins.postrm,
    debian/nova-xcp-plugins.doc, debian/nova-xcp-plugins.postinst,
    debian/README.xcp_and_openstack, debian/control,
    debian/ubuntu_xen-openvswitch-nova.rules,
    debian/patches/path-to-the-xenhost.conf-fixup.patch:
    Add Xen XCP support.
  - debian/control,
    debian/nova-compute-{kvm,lxc,qemu,xen,uml}.postinst: Make
    nova-compute a virtual package.
  - Dropped ubuntu_ubuntu_control_vars: We dont use it
* New upstream release.
* Dropped python-babel, it will be handled by langpacks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
 
1
#!/bin/sh
2
2
### BEGIN INIT INFO
3
3
# Provides:          nova-volume
4
 
# Required-Start:    $remote_fs $syslog
5
 
# Required-Stop:     $remote_fs $syslog
 
4
# Required-Start:    $network $local_fs $remote_fs $syslog
 
5
# Required-Stop:     $remote_fs
6
6
# Default-Start:     2 3 4 5
7
7
# Default-Stop:      0 1 6
8
 
# Short-Description: nova-volume
9
 
# Description:       provides EBS like storage for your virtual machine instances
 
8
# Short-Description: Nova Volume
 
9
# Description:       Provides EBS like storage for your
 
10
#                    virtual machine instances
10
11
### END INIT INFO
11
12
 
12
 
set -e
 
13
# Author: Julien Danjou <acid@debian.org>
13
14
 
 
15
# PATH should only include /usr/* if it runs after the mountnfs.sh script
 
16
PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
17
DESC="OpenStack Compute Volume"
 
18
NAME=nova-volume
14
19
DAEMON=/usr/bin/nova-volume
15
20
DAEMON_ARGS="--flagfile=/etc/nova/nova.conf"
16
 
PIDFILE=/var/run/nova/nova-volume.pid
17
 
 
18
 
ENABLED=true
19
 
 
20
 
# Guess the VG by getting the first one we see in "vgdisplay -c -A"
21
 
# if nothing was set in the default file
22
 
VGDISPLAY=/sbin/vgdisplay
23
 
if [ -f /etc/default/nova-volume ] ; then
24
 
        . /etc/default/nova-volume
25
 
fi
26
 
if [ -x "${VGDISPLAY}" -a -z "${nova_volume_group}" ] ; then
27
 
        nova_volume_group=`vgdisplay -c -A | tail -n 1 | cut -d":" -f1 | awk '{print $1}'`
28
 
fi
29
 
 
30
 
mkdir -p /var/run/nova
31
 
chown nova:root /var/run/nova/
32
 
 
33
 
mkdir -p /var/lock/nova
34
 
chown nova:root /var/lock/nova/
35
 
 
36
 
uid="$(getent passwd nova | cut -f3 -d:)"
37
 
gid="$(getent passwd nova | cut -f4 -d:)"
38
 
 
39
 
# Adds what has been configured in /etc/default/nova-volume
40
 
if [ -n ${nova_volume_group} ] ; then
41
 
        DAEMON_ARGS="${DAEMON_ARGS} --volume_group=${nova_volume_group}"
42
 
fi
 
21
PIDFILE=/var/run/$NAME.pid
 
22
SCRIPTNAME=/etc/init.d/$NAME
 
23
NOVA_USER=nova
 
24
LOCK_DIR=/var/lock/nova/
 
25
 
 
26
# Exit if the package is not installed
 
27
[ -x $DAEMON ] || exit 0
 
28
 
 
29
mkdir -p ${LOCK_DIR}
 
30
chown ${NOVA_USER} ${LOCK_DIR}
 
31
 
 
32
# Read configuration variable file if it is present
 
33
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
43
34
 
44
35
. /lib/lsb/init-functions
45
36
 
46
 
if ! [ -x ${DAEMON} ] ; then
47
 
        exit 0
48
 
fi
 
37
do_start()
 
38
{
 
39
        # Guess the VG by getting the first one we see in "vgdisplay -c -A"
 
40
        # if nothing was set in the default file
 
41
        VGDISPLAY=/sbin/vgdisplay
 
42
        if [ -z "${nova_volume_group}" -a -x "$VGDISPLAY" ]
 
43
        then
 
44
                nova_volume_group=`$VGDISPLAY -c -A | head -n 1 | cut -d":" -f1 | awk '{print $1}'`
 
45
        fi
 
46
 
 
47
        # Adds what has been configured in /etc/default/nova-volume
 
48
        if [ -n ${nova_volume_group} ] ; then
 
49
                DAEMON_ARGS="${DAEMON_ARGS} --volume_group=${nova_volume_group}"
 
50
        fi
 
51
 
 
52
        start-stop-daemon --start --quiet --background --chuid ${NOVA_USER}:nova --make-pidfile --pidfile $PIDFILE --startas $DAEMON --test > /dev/null \
 
53
                || return 1
 
54
        start-stop-daemon --start --quiet --background --chuid ${NOVA_USER}:nova --make-pidfile --pidfile $PIDFILE --startas $DAEMON -- \
 
55
                $DAEMON_ARGS \
 
56
                || return 2
 
57
}
 
58
 
 
59
do_stop()
 
60
{
 
61
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
 
62
        RETVAL="$?"
 
63
        rm -f $PIDFILE
 
64
        return "$RETVAL"
 
65
}
49
66
 
50
67
case "$1" in
51
68
  start)
52
 
    test "$ENABLED" = "true" || exit 0
53
 
    log_daemon_msg "Starting nova volume" "nova-volume"
54
 
    start-stop-daemon --start --chdir /var/run --chuid ${uid}:${gid} -b -m --pidfile ${PIDFILE} --exec ${DAEMON} -- ${DAEMON_ARGS}
55
 
    log_end_msg $?
56
 
    ;;
 
69
    log_daemon_msg "Starting $DESC " "$NAME"
 
70
    do_start
 
71
    case "$?" in
 
72
                0|1) log_end_msg 0 ;;
 
73
                2) log_end_msg 1 ;;
 
74
        esac
 
75
  ;;
57
76
  stop)
58
 
    test "$ENABLED" = "true" || exit 0
59
 
    log_daemon_msg "Stopping nova volume" "nova-volume"
60
 
    start-stop-daemon --stop --oknodo --pidfile ${PIDFILE}
61
 
    log_end_msg $?
62
 
    ;;
 
77
        log_daemon_msg "Stopping $DESC" "$NAME"
 
78
        do_stop
 
79
        case "$?" in
 
80
                0|1) log_end_msg 0 ;;
 
81
                2) log_end_msg 1 ;;
 
82
        esac
 
83
        ;;
 
84
  status)
 
85
       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
 
86
       ;;
63
87
  restart|force-reload)
64
 
    test "$ENABLED" = "true" || exit 1
65
 
    $0 start
66
 
    sleep 1
67
 
    $0 stop
68
 
    ;;
69
 
  status)
70
 
    test "$ENABLED" = "true" || exit 0
71
 
    status_of_proc -p $PIDFILE $DAEMON nova-volume && exit 0 || exit $?
72
 
    ;;
 
88
        log_daemon_msg "Restarting $DESC" "$NAME"
 
89
        do_stop
 
90
        case "$?" in
 
91
          0|1)
 
92
                do_start
 
93
                case "$?" in
 
94
                        0) log_end_msg 0 ;;
 
95
                        1) log_end_msg 1 ;; # Old process is still running
 
96
                        *) log_end_msg 1 ;; # Failed to start
 
97
                esac
 
98
                ;;
 
99
          *)
 
100
                # Failed to stop
 
101
                log_end_msg 1
 
102
                ;;
 
103
        esac
 
104
        ;;
73
105
  *)
74
 
    log_action_msg "Usage: /etc/init.d/nova-volume {start|stop|restart|force-reload|status}"
75
 
    exit 1
76
 
    ;;
 
106
        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
 
107
        exit 3
 
108
        ;;
77
109
esac
78
110
 
79
 
exit 0
 
111
: