#!/bin/bash # # rawdevices This shell script assignes rawdevices to block devices # # chkconfig: 345 56 44 # description: This scripts assignes raw devices to block devices \ # (such as hard drive partitions). This is for the use \ # of applications such as Oracle. You can set up the \ # raw device to block device mapping by editing \ # the file /etc/sysconfig/rawdevices. # config: /etc/sysconfig/rawdevices # Source function library. . /etc/rc.d/init.d/functions TEXTDOMAIN=initscripts [ -f /usr/bin/raw ] || exit 0 [ -f /etc/sysconfig/rawdevices ] || exit 0 # If the file just has the default comments, exit. grep -q -v "^#" /etc/sysconfig/rawdevices 2>/dev/null || exit 0 PATH=/usr/bin:/bin:/usr/sbin:/sbin function assign_raw() { cat /etc/sysconfig/rawdevices | egrep -v '^ *#' | while read RAW BLOCK; do if [ -n "$RAW" -a -n "$BLOCK" ]; then if [ "`dirname $RAW`" = "/dev" -a -d /dev/raw ]; then echo $" Please correct your /etc/sysconfig/rawdevices:" echo $" rawdevices are now located in the directory /dev/raw/ " echo $" If the command 'raw' still refers to /dev/raw as a file." echo $" you'll have to upgrade your util-linux package" exit 0 fi if [ "`dirname $RAW`" = "/dev/raw" -a -f /dev/raw ]; then echo $" Please correct your /etc/sysconfig/rawdevices:" echo $" rawdevices are now located in the directory /dev/raw/ " echo $" If the command 'raw' still refers to /dev/raw as a file." echo $" you'll have to upgrade your util-linux package" exit 0 fi show "Assigning device: $RAW --> $BLOCK" busy raw $RAW $BLOCK > /dev/null deltext ok fi done } # See how we were called. case "$1" in start) if [ ! -f /var/lock/subsys/rawdevices ]; then msg_starting rawdevices ok assign_raw touch /var/lock/subsys/rawdevices else msg_already_running rawdevices fi ;; stop) if [ -f /var/lock/subsys/rawdevices ]; then msg_stopping rawdevices busy rm -f /var/lock/subsys/rawdevices >/dev/null 2>&1 deltext ok else msg_not_running rawdevices exit 1 fi ;; status) ID=`id -u` if [ $ID -eq 0 ]; then raw -qa else echo $"You need to be root to use this command ! " fi ;; restart|reload) $0 stop $0 start ;; *) msg_usage "$0 {start|stop|status|restart}" exit 1 esac exit 0