#! /bin/sh #---------------------------------------------------------------------------- # /etc/init.d/usb - load or unload usb drivers # # Creation : 2004-03-12 fh # Last Update: $Id$ # # Copyright (c) 2001-2010 the eisfair team, team(at)eisfair(dot)org # # 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. #---------------------------------------------------------------------------- # include config file . /etc/config.d/usb # include eislib . /var/install/include/eislib # dont unload module if usb-drive given usb_drive=false if [ -f /boot/usb-drive ] then usb_drive=true fi case ${1} in start) if [ "${START_USB}" = "yes" ] then mecho -info "Loading usb drivers ..." /sbin/modprobe usbcore 2>/dev/null # load usb core driver /sbin/modprobe ${USB_LOWLEVEL} 2>/dev/null # load usb host driver if [ "${USB_2}" = "yes" ] then /sbin/modprobe ehci-hcd 2>/dev/null # load usb2 driver fi if [ "${USB_PRINTER}" = "yes" ] then /sbin/modprobe printer 2>/dev/null # load usb printer driver fi if [ "${USB_STORAGE}" = "yes" ] then /sbin/modprobe usb-storage 2>/dev/null # load usb storage driver fi if [ "${USB_SERIAL}" = "yes" ] then /sbin/modprobe usbserial 2>/dev/null # load usb serial drivers /sbin/modprobe "${USB_SERIAL_DRIVER}" "${USB_SERIAL_OPTIONS}" 2>/dev/null fi if [ -z "`mount -t usbfs`" ] then mount -t usbfs usbfs /proc/bus/usb fi fi ;; stop) mecho -info "Unloading usb drivers ..." mount | grep usb > /dev/null if [ ${?} = 0 ] then umount /proc/bus/usb fi if [ "${USB_PRINTER}" = "yes" ] then /sbin/rmmod printer 2>/dev/null # unload usb printer driver fi if [ "${USB_2}" = "yes" ] then if ! ${usb_drive} then /sbin/rmmod ehci-hcd 2>/dev/null # unload usb2 driver fi fi if [ "${USB_STORAGE}" = "yes" ] then if ! ${usb_drive} then /sbin/rmmod usb-storage 2>/dev/null # unload usb storage driver fi fi if [ "${USB_SERIAL}" = "yes" ] then /sbin/rmmod "${USB_SERIAL_DRIVER}" 2>/dev/null # unload usb serial drivers /sbin/rmmod usbserial 2>/dev/null fi ;; start_by_hand) ${0} start if [ "${START_USB}" = "yes" ] then if [ ${USB_DEP_SERVICE_N} -gt 0 ] then mecho -info "Looking for dependent services..." if [ -f /etc/usbdepservices ] then for service in `cat /etc/usbdepservices` do mecho -warn "Found "${service}", starting." /etc/init.d/${service} start done else mecho -std "...nothing to do." fi fi fi ;; stop_by_hand) if [ "${START_USB}" = "yes" ] then if [ ${USB_DEP_SERVICE_N} -gt 0 ] then mecho -info "Looking for dependent services..." if [ -f /etc/usbdepservices ] then for service in `cat /etc/usbdepservices` do mecho -warn "Found "${service}", stopping." /etc/init.d/${service} stop done else mecho -std "...nothing to do." fi fi fi ${0} stop ;; restart) ${0} stop_by_hand ${0} start_by_hand ;; esac