#!/bin/sh # A script for use after hotswapping a D-bay drive # when the device wasn't inserted originally. # It will create a mount point, symbolic link to hdc # and update fstab. Not very well tested yet :) # Please note the hotswap program expects the device # to refer to /dev/hdc rather than /dev/cdrom -- read the docs. device_line="/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0" mount_point="/mnt/cdrom" function dir_check { if [ -d $mount_point ] then echo "Directory cdrom exists" else echo "Creating mount point" mkdir $mount_point fi } function device_check { if [ -e /dev/cdrom ] then echo "Device cdrom ready" else echo "Creating device" ln -s /dev/hdc /dev/cdrom fi } if [ -e /dev/hdc ] then device_check if LC_ALL=C grep -q cdrom < /etc/fstab; then dir_check echo "Device cdrom is ready to be mounted" else dir_check echo "Updating fstab" echo $device_line >> /etc/fstab fi else echo "Oops -- how did we get here." fi