#!/bin/sh # Copyright Jean-Philippe Guillemin . This program is free software; you can redistribute # it and/or modify it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your option) # any later version. Please take a look at http://www.gnu.org/copyleft/gpl.htm # This script creates cdrom and dvd symlinks in /dev VERBOSE="no" # Log a string via the syslog facility. log() { [ "$VERBOSE" = "yes" ] && logger -p user.$1 -t "rc.uwd[$$]" -- "$2" } # Everything happens there cd /dev start() { for KERNEL in sr[0-9]* ; do [ ! -e $KERNEL ] && continue # echo "KERNEL=$KERNEL" num=0 fstabisready='no' MODEL="$(cat /sys/block/$KERNEL/device/model)" if [ "$( /lib/udev/cdrom_id /dev/$KERNEL | grep 'ID_CDROM_DVD=1' )" ] ; then type="dvd" for i in $(/bin/ls dvd? 2>/dev/null) ; do num=$(($num + 1)) done elif [ "$( /lib/udev/cdrom_id /dev/$KERNEL | grep 'ID_CDROM=1' )" ] ; then type="cdrom" for i in $(/bin/ls cdrom? 2>/dev/null) ; do num=$(($num + 1)) done fi log info "I guess $type$num is a good symlink for $KERNEL" log info "creating symlinks for device $MODEL /dev/$KERNEL -> /dev/$type$num" ln -s $KERNEL $type$num chown root:cdrom $KERNEL chown root:cdrom $type$num if [ "$num" = "0" ] ; then num="" ln -s $KERNEL $type$num chown root:cdrom $type$num fi done if [ ! -e cdrom ] ; then [ -e sr0 ] && ln -s sr0 cdrom chown root:cdrom cdrom fi } stop() { rm -f /dev/cdrom* rm -f /dev/dvd* } restart() { stop start } status() { ls -al /dev/cdrom* ls -al /dev/dvd* } case "$1" in 'start') start ;; 'stop') stop ;; 'restart') restart ;; 'status') status ;; *) echo "Usage $0: start|stop|restart|status" esac