]> git.pld-linux.org Git - packages/util-linux.git/blob - rawdevices.init
- cleaning
[packages/util-linux.git] / rawdevices.init
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.
14 . /etc/rc.d/init.d/functions
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                         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
44
45                 show $(nls "Assigning device: %s --> %s" "$RAW" "$BLOCK")
46                 busy
47                 raw $RAW $BLOCK > /dev/null
48                 ok
49         fi
50         done
51 }
52
53
54 # See how we were called.
55 case "$1" in
56   start)
57         if [ ! -f /var/lock/subsys/rawdevices ]; then
58                 msg_starting rawdevices
59                 ok
60                 assign_raw
61                 touch /var/lock/subsys/rawdevices
62         else
63                 msg_already_running rawdevices
64                 exit 1
65         fi
66         ;;
67   stop)
68         if [ -f /var/lock/subsys/rawdevices ]; then
69                 msg_stopping rawdevices
70                 busy
71                 rm -f /var/lock/subsys/rawdevices >/dev/null 2>&1
72                 ok
73         else
74                 msg_not_running rawdevices
75                 exit 1
76         fi
77         ;;
78   status)
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         ;;
87   restart|reload)
88         $0 stop
89         $0 start
90         ;;
91
92   *)
93         msg_usage "$0 {start|stop|restart|reload|status}"
94         exit 1
95 esac
96
97 exit 0
This page took 0.039208 seconds and 4 git commands to generate.