]>
Commit | Line | Data |
---|---|---|
bac5fff1 PG |
1 | #!/bin/bash |
2 | # | |
3 | # rawdevices This shell script assignes rawdevices to block devices | |
4 | # | |
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 | |
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 | { | |
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 | echo $" Please correct your /etc/sysconfig/rawdevices:" | |
32 | echo $" rawdevices are now located in the directory /dev/raw/ " | |
33 | echo $" If the command 'raw' still refers to /dev/raw as a file." | |
34 | echo $" 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 | echo $" Please correct your /etc/sysconfig/rawdevices:" | |
39 | echo $" rawdevices are now located in the directory /dev/raw/ " | |
40 | echo $" If the command 'raw' still refers to /dev/raw as a file." | |
41 | echo $" you'll have to upgrade your util-linux package" | |
42 | exit 0 | |
43 | fi | |
44 | ||
45 | echo " $RAW --> $BLOCK"; | |
46 | raw $RAW $BLOCK | |
47 | fi | |
48 | done | |
49 | } | |
50 | ||
51 | # See how we were called. | |
52 | case "$1" in | |
53 | start) | |
54 | # Assign devices | |
55 | echo $"Assigning devices: " | |
56 | assign_raw | |
57 | echo $"done" | |
58 | ;; | |
59 | stop) | |
60 | # No action to be taken here | |
751b7ca6 | 61 | echo $"No action can be taken" |
bac5fff1 PG |
62 | ;; |
63 | ||
64 | status) | |
65 | ID=`id -u` | |
66 | if [ $ID -eq 0 ]; then | |
67 | raw -qa | |
68 | else | |
69 | echo $"You need to be root to use this command ! " | |
70 | fi | |
71 | ;; | |
72 | ||
73 | restart|reload) | |
74 | $0 start | |
75 | ;; | |
76 | ||
77 | *) | |
78 | echo $"Usage: $0 {start|stop|status|restart}" | |
79 | exit 1 | |
80 | esac | |
81 | ||
82 | exit 0 |