#!/bin/sh # /usr/local/sbin/hotswap # Rob Russell - 10 Nov 2000 - handle hotswapping of IDE modules # This script is in some serious need of errorckecking. # The syncs are there more for insurance than anything else. I'm a # suspicious person. # This script is distributed under the license terms of the GNU General # Public License, whichever version the Licensee chooses. case "$1" in floppy) echo "floppy module has been initialized." ;; cdrom) sync ; sync ; sync ; sync insmod cdrom # Only needed for RedHat's Linux 2.4 kernels insmod ide-cd ln -s /dev/hdc /dev/cdrom sync ; sync ; sync ; sync echo "CDROM module has been initialized." ;; dvd) sync ; sync ; sync ; sync insmod cdrom # Only needed for RedHat's Linux 2.4 kernels insmod ide-cd ln -s /dev/hdc /dev/cdrom ln -s /dev/hdc /dev/dvd hdparm -d 1 /dev/hdc sync ; sync ; sync ; sync echo "DVD module has been initialized." ;; burner) sync ; sync ; sync ; sync insmod cdrom # Only needed for RedHat's Linux 2.4 kernels insmod scsi_mod # Only needed for RedHat's Linux 2.4 kernels insmod ide-scsi ln -s /dev/scd0 /dev/cdrom sync ; sync ; sync ; sync echo "CDRW module has been initialized." ;; eject) sync ; sync ; sync ; sync umount /mnt/cdrom umount /mnt/floppy sync ; sync ; sync ; sync rm /dev/cdrom rm /dev/dvd sync ; sync ; sync ; sync rmmod ide-cd rmmod ide-scsi rmmod cdrom # Only needed for RedHat's Linux 2.4 kernels rmmod scsi_mod # Only needed for RedHat's Linux 2.4 kernels sync ; sync ; sync ; sync echo "The bay is now ready to be ejected. I hope." apm -s ;; unload) sync ; sync ; sync ; sync umount /mnt/cdrom umount /mnt/floppy sync ; sync ; sync ; sync rm /dev/cdrom rm /dev/dvd sync ; sync ; sync ; sync rmmod ide-cd rmmod ide-scsi rmmod cdrom # Only needed for RedHat's Linux 2.4 kernels rmmod scsi_mod # Only needed for RedHat's Linux 2.4 kernels sync ; sync ; sync ; sync echo "The modules are now unloaded." ;; *) echo "Usage: $0 {floppy|cdrom|burner|dvd|eject|unload}" echo echo " floppy : Initializes a Floppy module" echo " cdrom : Initializes a CDROM module" echo " burner : Initializes a CDRW module" echo " dvd : Initializes a DVD module" echo " eject : Unloads modules so a bay can be ejected" echo " unload : Unloads modules so you can change a drive's mode" exit 1 esac