Sophie

Sophie

distrib > Mandriva > 9.1 > i586 > by-pkgid > 8c6202abd5c23d52fed280e28dc23b0a > files > 40

initscripts-7.06-12.3.91mdk.i586.rpm

#!/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

[ -f /usr/bin/raw ] || exit 0
[ -f /etc/sysconfig/rawdevices ] || exit 0
# Exit if the file just has the default comments.
LC_ALL=C /bin/egrep -q -v "^ *#" /etc/sysconfig/rawdevices 2>/dev/null || exit 0

. /etc/init.d/functions

function assign_raw()
{
   LC_ALL=C egrep -v '^ *#' /etc/sysconfig/rawdevices |
   while read RAW BLOCK; do 
     if [ -n "$RAW" -a -n "$BLOCK" ]; then 
	 rawdirname=${RAW%/*}
         if [ "$rawdirname" = "/dev" -a -d /dev/raw ]; then
           gprintf "  Please correct your /etc/sysconfig/rawdevices:\n"
           gprintf "     rawdevices are now located in the directory /dev/raw/ \n"
           gprintf "  If the command 'raw' still refers to /dev/raw as a file.\n"
           gprintf "   you'll have to upgrade your util-linux package\n"
           exit 0
         fi
         if [ "$rawdirname" = "/dev/raw" -a -f /dev/raw ]; then
           gprintf "  Please correct your /etc/sysconfig/rawdevices:\n"
           gprintf "     rawdevices are now located in the directory /dev/raw/ \n"
           gprintf "  If the command 'raw' still refers to /dev/raw as a file.\n"
           gprintf "   you'll have to upgrade your util-linux package\n"
           exit 0
         fi

       raw $RAW $BLOCK >/dev/null && echo -n " $BLOCK" || err=1 
     fi
   done ; return $err;
}

# See how we were called.
case "$1" in
  start)
        # Assign devices
        gprintf "Assigning raw devices:"
	assign_raw && success || failure
	echo
        ;;
  stop)
        # No action to be taken here
        ;;

  status)
        ID=`id -u`
        if [ $ID -eq 0 ]; then 
          raw -qa
        else
          gprintf "You need to be root to use this command ! \n"
        fi
        ;;

  restart|reload)
        $0 start
        ;;

  *)
        gprintf "Usage: %s\n" "$(basename $0) {start|stop|status|restart}"
        exit 1
esac

exit 0