]> git.pld-linux.org Git - packages/util-linux.git/blame - rawdevices.init
- use functions
[packages/util-linux.git] / rawdevices.init
CommitLineData
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
16TEXTDOMAIN=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.
22grep -q -v "^#" /etc/sysconfig/rawdevices 2>/dev/null || exit 0
23
24PATH=/usr/bin:/bin:/usr/sbin:/sbin
25
26function 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
a38c175f 53start() {
df8fd0f8 54 if [ ! -f /var/lock/subsys/rawdevices ]; then
a29b23ad 55 msg_starting rawdevices
2aadaee6 56 ok
a29b23ad 57 assign_raw
76781b00 58 touch /var/lock/subsys/rawdevices
a29b23ad 59 else
34616d1c 60 msg_already_running rawdevices
a29b23ad 61 fi
a38c175f
ER
62}
63
64stop() {
df8fd0f8 65 if [ -f /var/lock/subsys/rawdevices ]; then
a29b23ad 66 msg_stopping rawdevices
2aadaee6 67 busy
a29b23ad 68 rm -f /var/lock/subsys/rawdevices >/dev/null 2>&1
2aadaee6 69 ok
a29b23ad 70 else
34616d1c 71 msg_not_running rawdevices
a29b23ad 72 fi
a38c175f
ER
73}
74
75# See how we were called.
76case "$1" in
77 start|reload)
78 start
79 ;;
80 stop)
81 stop
df8fd0f8 82 ;;
bac5fff1 83 status)
a38c175f
ER
84 id=`id -u`
85 if [ "$id" -eq 0 ]; then
df8fd0f8 86 raw -qa
87 else
88 # don't remove the space at the end!!!
89 nls "You need to be root to use this command ! "
90 fi
91 ;;
ac9f4e12 92 restart|force-reload)
a38c175f
ER
93 stop
94 start
df8fd0f8 95 ;;
bac5fff1
PG
96
97 *)
ac9f4e12 98 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
99 exit 3
bac5fff1
PG
100esac
101
102exit 0
This page took 0.080912 seconds and 4 git commands to generate.