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