]>
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 | ||
45 | case "$1" in | |
46 | start|reload) | |
47 | if [ ! -f /var/lock/subsys/vrootdevices ]; then | |
48 | msg_starting vrootdevices | |
49 | ok | |
50 | assign_vroot | |
51 | touch /var/lock/subsys/vrootdevices | |
52 | else | |
53 | msg_already_running vrootdevices | |
54 | fi | |
55 | ||
56 | ;; | |
57 | stop) | |
58 | if [ -f /var/lock/subsys/vrootdevices ]; then | |
59 | msg_stopping vrootdevices | |
60 | ok | |
61 | remove_vroot | |
62 | rm -f /var/lock/subsys/vrootdevices >/dev/null 2>&1 | |
63 | else | |
64 | msg_not_running vrootdevices | |
65 | fi | |
66 | ;; | |
67 | status) | |
68 | ID=`id -u` | |
69 | if [ $ID -eq 0 ]; then | |
70 | echo "There is no way to tell" | |
71 | else | |
72 | # don't remove the space at the end!!! | |
73 | nls "You need to be root to use this command ! " | |
74 | fi | |
75 | ;; | |
76 | restart|force-reload) | |
77 | $0 stop | |
78 | $0 start | |
8989d944 | 79 | ;; |
f40a7521 JR |
80 | *) |
81 | echo "Usage: $0 {start|stop|restart|reload|force-reload|status}" | |
82 | exit 3 | |
83 | ;; | |
84 | esac | |
85 | ||
86 | exit $RETVAL | |
87 | ||
88 | # This must be last line ! | |
89 | # vi:syntax=sh |