]>
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 | { | |
df8fd0f8 | 28 | cat /etc/sysconfig/rawdevices | egrep -v '^ *#' | while read RAW BLOCK; do |
29 | if [ -n "$RAW" -a -n "$BLOCK" ]; then | |
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 | |
df8fd0f8 | 45 | show $(nls "Assigning device: %s --> %s" "$RAW" "$BLOCK") |
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 | |
56 | start) | |
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 |
df8fd0f8 | 64 | exit 1 |
a29b23ad | 65 | fi |
df8fd0f8 | 66 | ;; |
bac5fff1 | 67 | stop) |
df8fd0f8 | 68 | if [ -f /var/lock/subsys/rawdevices ]; then |
a29b23ad | 69 | msg_stopping rawdevices |
2aadaee6 | 70 | busy |
a29b23ad | 71 | rm -f /var/lock/subsys/rawdevices >/dev/null 2>&1 |
2aadaee6 | 72 | ok |
a29b23ad | 73 | else |
34616d1c | 74 | msg_not_running rawdevices |
a29b23ad PG |
75 | exit 1 |
76 | fi | |
df8fd0f8 | 77 | ;; |
bac5fff1 | 78 | status) |
df8fd0f8 | 79 | ID=`id -u` |
80 | if [ $ID -eq 0 ]; then | |
81 | raw -qa | |
82 | else | |
83 | # don't remove the space at the end!!! | |
84 | nls "You need to be root to use this command ! " | |
85 | fi | |
86 | ;; | |
bac5fff1 | 87 | restart|reload) |
df8fd0f8 | 88 | $0 stop |
89 | $0 start | |
90 | ;; | |
bac5fff1 PG |
91 | |
92 | *) | |
df8fd0f8 | 93 | msg_usage "$0 {start|stop|restart|reload|status}" |
94 | exit 1 | |
bac5fff1 PG |
95 | esac |
96 | ||
97 | exit 0 |