]> git.pld-linux.org Git - packages/util-linux.git/blob - rawdevices.init
- uniformized configs to use system-auth where possible
[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 [ -f /etc/sysconfig/rawdevices ] || exit 0
14
15 # If the file just has the default comments, exit.
16 grep -q -v "^#" /etc/sysconfig/rawdevices 2>/dev/null || exit 0
17
18 # Source function library.
19 . /etc/rc.d/init.d/functions
20
21 function assign_raw()
22 {
23         cat /etc/sysconfig/rawdevices | egrep -v '^ *#' | while read RAW BLOCK; do
24         if [ -n "$RAW" -a -n "$BLOCK" ]; then
25                 if [ "`dirname $RAW`" = "/dev" -a -d /dev/raw ]; then
26                         nls " Please correct your /etc/sysconfig/rawdevices:"
27                         nls " rawdevices are now located in the directory /dev/raw/ "
28                         nls " If the command 'raw' still refers to /dev/raw as a file."
29                         nls " You'll have to upgrade your util-linux package"
30                         exit 0
31                 fi
32                 if [ "`dirname $RAW`" = "/dev/raw" -a -f /dev/raw ]; then
33                         nls " Please correct your /etc/sysconfig/rawdevices:"
34                         nls " rawdevices are now located in the directory /dev/raw/ "
35                         nls " If the command 'raw' still refers to /dev/raw as a file."
36                         nls " You'll have to upgrade your util-linux package"
37                         exit 0
38                 fi
39
40                 show "$(nls "Assigning device: %s --> %s" "$RAW" "$BLOCK")"
41                 busy
42                 raw $RAW $BLOCK > /dev/null
43                 ok
44         fi
45         done
46 }
47
48 start() {
49         if [ ! -f /var/lock/subsys/rawdevices ]; then
50                 msg_starting rawdevices
51                 ok
52                 assign_raw
53                 touch /var/lock/subsys/rawdevices
54         else
55                 msg_already_running rawdevices
56         fi
57 }
58
59 stop() {
60         if [ -f /var/lock/subsys/rawdevices ]; then
61                 msg_stopping rawdevices
62                 busy
63                 rm -f /var/lock/subsys/rawdevices >/dev/null 2>&1
64                 ok
65         else
66                 msg_not_running rawdevices
67         fi
68 }
69
70 # See how we were called.
71 case "$1" in
72   start|reload)
73         start
74         ;;
75   stop)
76         stop
77         ;;
78   status)
79         raw -qa
80         ;;
81   restart|force-reload)
82         stop
83         start
84         ;;
85
86   *)
87         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
88         exit 3
89 esac
90
91 exit 0
This page took 0.062728 seconds and 3 git commands to generate.