]>
Commit | Line | Data |
---|---|---|
88d20d00 TP |
1 | #!/bin/bash |
2 | # | |
3 | # vzeventd This shell script takes care of starting and stopping | |
4 | # vzeventd daemon for OpenVZ. | |
5 | # | |
6 | # chkconfig: 2345 95 89 | |
7 | # description: vzeventd is OpenVZ events daemon. \ | |
8 | # It takes care of events sent by the OpenVZ kernel and performs required \ | |
9 | # actions associated with those events. | |
10 | ||
11 | ### BEGIN INIT INFO | |
12 | # Provides: vzeventd | |
13 | # Required-start: $remote_fs | |
14 | # Required-stop: $remote_fs | |
15 | # Default-Start: 2 3 4 5 | |
16 | # Default-Stop: 0 1 6 | |
17 | # X-Start-Before: vz | |
18 | # X-Stop-After: vz | |
19 | # Short-Description: start and stop vzeventd | |
20 | # Description: vzeventd is the OpenVZ events daemon. | |
21 | # It takes care of events sent by the OpenVZ kernel | |
22 | # and performs required actions associated with those events. | |
23 | ### END INIT INFO | |
24 | ||
1062ae9c | 25 | . @SCRIPTDIR@/initd-functions |
88d20d00 TP |
26 | |
27 | prog=vzeventd | |
28 | lockfile=$VARLOCK/$prog | |
29 | ||
30 | load_module() { | |
31 | modprobe vzevent reboot_event=1 | |
32 | } | |
33 | ||
34 | check() { | |
35 | local param=/sys/module/vzevent/parameters/reboot_event | |
36 | ||
37 | show "Checking vzevent kernel module" | |
38 | ||
39 | if ! lsmod | fgrep -qw vzevent; then | |
40 | fail | |
41 | return 1 | |
42 | fi | |
43 | if ! cat $param | fgrep -qw 1; then | |
44 | fail | |
45 | print_warning "vzevent module should be loaded with reboot_event=1 parameter" | |
46 | return 1 | |
47 | fi | |
48 | ok | |
49 | return 0 | |
50 | } | |
51 | ||
52 | start() { | |
53 | [ "$EUID" != "0" ] && exit 4 | |
54 | [ -x @SBINDIR@/vzeventd ] || exit 5 | |
55 | [ -r /etc/sysconfig/vzeventd ] && . /etc/sysconfig/vzeventd | |
56 | [ -r /etc/default/vzeventd ] && . /etc/default/vzeventd | |
57 | ||
58 | [ -f $lockfile ] && exit 0 # Already running | |
59 | ||
60 | load_module | |
61 | check || exit 1 | |
62 | ||
63 | msg_starting "$prog" | |
64 | vzdaemon_start $prog $OPTIONS | |
65 | RETVAL=$? | |
66 | [ $RETVAL -eq 0 ] && touch $lockfile | |
67 | return $RETVAL | |
68 | } | |
69 | ||
70 | stop() { | |
71 | [ "$EUID" != "0" ] && exit 4 | |
72 | msg_stopping "$prog" | |
73 | vzdaemon_stop $prog | |
74 | RETVAL=$? | |
75 | [ $RETVAL -eq 0 ] && rm -f $lockfile | |
76 | return $RETVAL | |
77 | } | |
78 | ||
79 | # See how we were called. | |
80 | case "$1" in | |
81 | start) | |
82 | start | |
83 | ;; | |
84 | stop) | |
85 | stop | |
86 | ;; | |
87 | status) | |
88 | vzdaemon_status $prog | |
89 | ;; | |
90 | restart|force-reload) | |
91 | stop | |
92 | start | |
93 | ;; | |
94 | try-restart|condrestart) | |
95 | if vzdaemon_status $prog >/dev/null 2>&1; then | |
96 | stop | |
97 | start | |
98 | fi | |
99 | ;; | |
100 | reload) | |
101 | exit 3 | |
102 | ;; | |
103 | *) | |
104 | echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" | |
105 | exit 2 | |
106 | esac |