]>
Commit | Line | Data |
---|---|---|
bac5fff1 PG |
1 | #!/bin/bash |
2 | # | |
df8fd0f8 | 3 | # rawdevices This shell script assignes rawdevices to block devices |
bac5fff1 | 4 | # |
df8fd0f8 | 5 | # chkconfig: 345 56 44 |
6 | # description: This scripts assignes raw devices to block devices \ | |
7 | # (such as hard drive partitions). This is for the use \ | |
8 | # of applications such as Oracle. You can set up the \ | |
9 | # raw device to block device mapping by editing \ | |
10 | # the file /etc/sysconfig/rawdevices. | |
11 | # config: /etc/sysconfig/rawdevices | |
bac5fff1 PG |
12 | |
13 | # Source function library. | |
751b7ca6 | 14 | . /etc/rc.d/init.d/functions |
bac5fff1 PG |
15 | |
16 | TEXTDOMAIN=initscripts | |
17 | ||
18 | [ -f /usr/bin/raw ] || exit 0 | |
19 | [ -f /etc/sysconfig/rawdevices ] || exit 0 | |
20 | ||
21 | # If the file just has the default comments, exit. | |
22 | grep -q -v "^#" /etc/sysconfig/rawdevices 2>/dev/null || exit 0 | |
23 | ||
24 | PATH=/usr/bin:/bin:/usr/sbin:/sbin | |
25 | ||
26 | function assign_raw() | |
27 | { | |
b06f5046 ER |
28 | cat /etc/sysconfig/rawdevices | egrep -v '^ *#' | while read RAW BLOCK; do |
29 | if [ -n "$RAW" -a -n "$BLOCK" ]; then | |
df8fd0f8 | 30 | if [ "`dirname $RAW`" = "/dev" -a -d /dev/raw ]; then |
31 | nls " Please correct your /etc/sysconfig/rawdevices:" | |
32 | nls " rawdevices are now located in the directory /dev/raw/ " | |
33 | nls " If the command 'raw' still refers to /dev/raw as a file." | |
34 | nls " You'll have to upgrade your util-linux package" | |
35 | exit 0 | |
36 | fi | |
37 | if [ "`dirname $RAW`" = "/dev/raw" -a -f /dev/raw ]; then | |
38 | nls " Please correct your /etc/sysconfig/rawdevices:" | |
39 | nls " rawdevices are now located in the directory /dev/raw/ " | |
40 | nls " If the command 'raw' still refers to /dev/raw as a file." | |
41 | nls " You'll have to upgrade your util-linux package" | |
42 | exit 0 | |
43 | fi | |
bac5fff1 | 44 | |
e457171e | 45 | show "$(nls "Assigning device: %s --> %s" "$RAW" "$BLOCK")" |
df8fd0f8 | 46 | busy |
47 | raw $RAW $BLOCK > /dev/null | |
48 | ok | |
49 | fi | |
50 | done | |
bac5fff1 PG |
51 | } |
52 | ||
df8fd0f8 | 53 | |
bac5fff1 PG |
54 | # See how we were called. |
55 | case "$1" in | |
ac9f4e12 | 56 | start|reload) |
df8fd0f8 | 57 | if [ ! -f /var/lock/subsys/rawdevices ]; then |
a29b23ad | 58 | msg_starting rawdevices |
2aadaee6 | 59 | ok |
a29b23ad | 60 | assign_raw |
76781b00 | 61 | touch /var/lock/subsys/rawdevices |
a29b23ad | 62 | else |
34616d1c | 63 | msg_already_running rawdevices |
a29b23ad | 64 | fi |
df8fd0f8 | 65 | ;; |
bac5fff1 | 66 | stop) |
df8fd0f8 | 67 | if [ -f /var/lock/subsys/rawdevices ]; then |
a29b23ad | 68 | msg_stopping rawdevices |
2aadaee6 | 69 | busy |
a29b23ad | 70 | rm -f /var/lock/subsys/rawdevices >/dev/null 2>&1 |
2aadaee6 | 71 | ok |
a29b23ad | 72 | else |
34616d1c | 73 | msg_not_running rawdevices |
a29b23ad | 74 | fi |
df8fd0f8 | 75 | ;; |
bac5fff1 | 76 | status) |
df8fd0f8 | 77 | ID=`id -u` |
b06f5046 | 78 | if [ $ID -eq 0 ]; then |
df8fd0f8 | 79 | raw -qa |
80 | else | |
81 | # don't remove the space at the end!!! | |
82 | nls "You need to be root to use this command ! " | |
83 | fi | |
84 | ;; | |
ac9f4e12 | 85 | restart|force-reload) |
df8fd0f8 | 86 | $0 stop |
87 | $0 start | |
88 | ;; | |
bac5fff1 PG |
89 | |
90 | *) | |
ac9f4e12 | 91 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
92 | exit 3 | |
bac5fff1 PG |
93 | esac |
94 | ||
95 | exit 0 |