| #!/bin/bash |
| # |
| # Start/Stop BCM.USER |
| # |
| |
| # |
| # Set the directory path to bcm.user, or |
| # allow the user to specify the path to bcm.user as the second argument when calling this script |
| # (the first argument must be one of: [ start, stop ] |
| # |
| if [ -z $2 ]; then |
| |
| # Look for bcm.user, set the starting directory appropriately, or |
| # simple exit if not found |
| # |
| if [ -f /mnt/bcm.user ]; then |
| BCM_USER_BIN_DIR=/mnt/ |
| elif [ -f /broadcom/bcm.user ]; then |
| BCM_USER_BIN_DIR=/broadcom |
| elif [ -f /opt/bcm56450/bcm.user ]; then |
| BCM_USER_BIN_DIR=/opt/bcm56450 |
| elif [ -f ./bcm.user ]; then |
| BCM_USER_BIN_DIR=. |
| else |
| echo "cannot find bcm.user, exiting" |
| exit 1 |
| fi |
| |
| else # the user may choose the starting directory directly using the second argment |
| BCM_USER_BIN_DIR=$2 |
| fi |
| |
| case "$1" in |
| start) |
| echo -n "Starting bcm.user: " |
| cd ${BCM_USER_BIN_DIR} |
| lsmod | grep -q linux_user_bde > /dev/null |
| if [ "$?" == "0" ]; then |
| rmmod linux_user_bde |
| echo -n "(-user)" |
| fi |
| |
| lsmod | grep -q linux_kernel_bde > /dev/null |
| if [ "$?" == "0" ]; then |
| rmmod linux_kernel_bde |
| echo -n "(-kernel)" |
| fi |
| |
| # |
| # The linux_kernel_bde and linux_user_bde modules are loaded by the bcm.user executable |
| # |
| |
| # Create the linux device file, if it does not already exist |
| if [ ! -c /dev/linux-user-bde ]; then |
| mknod /dev/linux-user-bde c 126 0 |
| fi |
| ./bcm.user |
| echo "OK" |
| ;; |
| stop) |
| echo -n "Stopping bcm.user: " |
| pkill -f bcm.user |
| echo "OK" |
| ;; |
| restart|reload) |
| ;; |
| *) |
| echo "Usage: $0 {start|stop|restart}" |
| exit 1 |
| esac |
| |
| exit $? |