]>
Commit | Line | Data |
---|---|---|
f40a7521 JR |
1 | #!/bin/sh |
2 | # | |
3 | # vrootdevices: setup vroot devices | |
4 | # | |
5 | # chkconfig: 345 97 03 | |
6 | # description: Setup vroot devices for use inside vservers | |
5e118b6e ER |
7 | # |
8 | # $Id$ | |
f40a7521 JR |
9 | |
10 | # Source function library | |
11 | . /etc/rc.d/init.d/functions | |
12 | ||
8989d944 | 13 | assign_vroot() |
f40a7521 | 14 | { |
8989d944 | 15 | cat /etc/sysconfig/vrootdevices | egrep -v '^ *#' | while read VROOT BLOCK; do |
f40a7521 JR |
16 | if [ -n "$VROOT" -a -n "$BLOCK" ]; then |
17 | if [ -d /dev/vroot ]; then | |
18 | VROOT="/dev/vroot/$VROOT" | |
19 | else | |
20 | VROOT="/dev/vroot$VROOT" | |
21 | fi | |
22 | show "$(nls "Assigning device: %s --> %s" "$VROOT" "$BLOCK")" | |
23 | busy | |
24 | vrsetup $VROOT $BLOCK > /dev/null | |
25 | ok | |
26 | fi | |
27 | done | |
28 | } | |
29 | ||
8989d944 | 30 | remove_vroot() |
f40a7521 | 31 | { |
8989d944 | 32 | cat /etc/sysconfig/vrootdevices | egrep -v '^ *#' | while read VROOT BLOCK; do |
f40a7521 JR |
33 | if [ -n "$VROOT" -a -n "$BLOCK" ]; then |
34 | if [ -d /dev/vroot ]; then | |
35 | VROOT="/dev/vroot/$VROOT" | |
36 | else | |
37 | VROOT="/dev/vroot$VROOT" | |
38 | fi | |
39 | show "$(nls "Removing assignment: %s --> %s" "$VROOT" "$BLOCK")" | |
40 | busy | |
41 | vrsetup -d $VROOT > /dev/null | |
42 | ok | |
43 | fi | |
44 | done | |
45 | } | |
46 | ||
945c1639 | 47 | start() { |
f40a7521 JR |
48 | if [ ! -f /var/lock/subsys/vrootdevices ]; then |
49 | msg_starting vrootdevices | |
50 | ok | |
51 | assign_vroot | |
52 | touch /var/lock/subsys/vrootdevices | |
53 | else | |
54 | msg_already_running vrootdevices | |
55 | fi | |
945c1639 | 56 | } |
f40a7521 | 57 | |
945c1639 | 58 | stop() { |
f40a7521 JR |
59 | if [ -f /var/lock/subsys/vrootdevices ]; then |
60 | msg_stopping vrootdevices | |
61 | ok | |
62 | remove_vroot | |
63 | rm -f /var/lock/subsys/vrootdevices >/dev/null 2>&1 | |
64 | else | |
65 | msg_not_running vrootdevices | |
66 | fi | |
945c1639 ER |
67 | } |
68 | ||
69 | case "$1" in | |
70 | start|reload) | |
71 | start | |
72 | ;; | |
73 | stop) | |
74 | stop | |
f40a7521 | 75 | ;; |
f40a7521 | 76 | restart|force-reload) |
945c1639 ER |
77 | stop |
78 | start | |
8989d944 | 79 | ;; |
5e118b6e ER |
80 | status) |
81 | echo "There is no way to tell" | |
82 | ;; | |
f40a7521 | 83 | *) |
945c1639 | 84 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
f40a7521 JR |
85 | exit 3 |
86 | ;; | |
87 | esac | |
88 | ||
89 | exit $RETVAL |