#! /bin/sh #---------------------------------------------------------------------------- # /etc/init.d/usb - load or unload usb drivers # # Creation : 2004-03-12 fh # Last Update: $Id$ # # Copyright (c) 2001-2011 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. #---------------------------------------------------------------------------- # read functions . /etc/init.d/functions # include config file . /etc/config.d/usb # dont unload module if usb-drive given if [ -f /boot/usb-drive ] then usb_drive=true fi # --------------------------------------------------------------------------- # usage # --------------------------------------------------------------------------- usage () { cat </dev/null /sbin/modprobe ${USB_LOWLEVEL} 2>/dev/null if [ "${USB_2}" = "yes" ] then /sbin/modprobe ehci-hcd 2>/dev/null fi if [ "${USB_PRINTER}" = "yes" ] then /sbin/modprobe printer 2>/dev/null fi if [ "${USB_STORAGE}" = "yes" ] then /sbin/modprobe usb-storage 2>/dev/null fi if [ "${USB_SERIAL}" = "yes" ] then /sbin/modprobe usbserial 2>/dev/null /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 evaluate_retval fi } # --------------------------------------------------------------------------- # stop usb # --------------------------------------------------------------------------- usb_stop () { boot_mesg " * Stopping usb ..." if mount | grep usb > /dev/null then umount /proc/bus/usb fi if [ "${USB_PRINTER}" = "yes" ] then /sbin/rmmod printer 2>/dev/null fi # dont unload usb2 driver # if [ "${USB_2}" = "yes" ] # then # if ${usb_drive:-false} # then # /sbin/rmmod ehci-hcd 2>/dev/null # fi # fi if [ "${USB_STORAGE}" = "yes" ] then if ${usb_drive:-false} then /sbin/rmmod usb-storage 2>/dev/null fi fi if [ "${USB_SERIAL}" = "yes" ] then /sbin/rmmod "${USB_SERIAL_DRIVER}" 2>/dev/null /sbin/rmmod usbserial 2>/dev/null fi evaluate_retval } # --------------------------------------------------------------------------- # start usb by hand # --------------------------------------------------------------------------- usb_start_by_hand () { usb_start if [ "${START_USB}" = "yes" ] then if [ ${USB_DEP_SERVICE_N} -gt 0 ] then boot_mesg " * Looking for dependent services ..." if [ -s /etc/usbdepservices ] then for service in `cat /etc/usbdepservices` do boot_mesg " * Found "${service}", starting." /etc/init.d/${service} start done else evaluate_retval fi fi fi } # --------------------------------------------------------------------------- # usb stop by hand # --------------------------------------------------------------------------- usb_stop_by_hand () { if [ "${START_USB}" = "yes" ] then if [ ${USB_DEP_SERVICE_N} -gt 0 ] then boot_mesg " * Looking for dependent services ..." if [ -s /etc/usbdepservices ] then for service in `cat /etc/usbdepservices` do boot_mesg " * Found "${service}", stopping." /etc/init.d/${service} stop done else evaluate_retval fi fi fi usb_stop } # --------------------------------------------------------------------------- # restart usb # --------------------------------------------------------------------------- usb_restart() { usb_stop_by_hand sleep 2 usb_start_by_hand } # --------------------------------------------------------------------------- # main usb # --------------------------------------------------------------------------- while [ "${#}" -gt 0 ] do case "${1}" in -q|--quiet) _quiet=true shift ;; *) _action="${1}" shift ;; esac done case "${_action}" in start) usb_start ;; stop) usb_stop ;; restart) usb_restart ;; forcestart) start_force=true usb_start ;; start_by_hand) usb_start_by_hand ;; stop_by_hand) usb_stop_by_hand ;; *) usage exit 1 ;; esac exit 0 # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------