Shad Ansari | 2f7f9be | 2017-06-07 13:34:53 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Start/Stop BCM.USER |
| 4 | # |
| 5 | |
| 6 | # |
| 7 | # Set the directory path to bcm.user, or |
| 8 | # allow the user to specify the path to bcm.user as the second argument when calling this script |
| 9 | # (the first argument must be one of: [ start, stop ] |
| 10 | # |
| 11 | if [ -z $2 ]; then |
| 12 | |
| 13 | # Look for bcm.user, set the starting directory appropriately, or |
| 14 | # simple exit if not found |
| 15 | # |
| 16 | if [ -f /mnt/bcm.user ]; then |
| 17 | BCM_USER_BIN_DIR=/mnt/ |
| 18 | elif [ -f /broadcom/bcm.user ]; then |
| 19 | BCM_USER_BIN_DIR=/broadcom |
| 20 | elif [ -f /opt/bcm56450/bcm.user ]; then |
| 21 | BCM_USER_BIN_DIR=/opt/bcm56450 |
| 22 | elif [ -f ./bcm.user ]; then |
| 23 | BCM_USER_BIN_DIR=. |
| 24 | else |
| 25 | echo "cannot find bcm.user, exiting" |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | else # the user may choose the starting directory directly using the second argment |
| 30 | BCM_USER_BIN_DIR=$2 |
| 31 | fi |
| 32 | |
| 33 | case "$1" in |
| 34 | start) |
| 35 | echo -n "Starting bcm.user: " |
| 36 | cd ${BCM_USER_BIN_DIR} |
| 37 | lsmod | grep -q linux_user_bde > /dev/null |
| 38 | if [ "$?" == "0" ]; then |
| 39 | rmmod linux_user_bde |
| 40 | echo -n "(-user)" |
| 41 | fi |
| 42 | |
| 43 | lsmod | grep -q linux_kernel_bde > /dev/null |
| 44 | if [ "$?" == "0" ]; then |
| 45 | rmmod linux_kernel_bde |
| 46 | echo -n "(-kernel)" |
| 47 | fi |
| 48 | |
| 49 | # |
| 50 | # The linux_kernel_bde and linux_user_bde modules are loaded by the bcm.user executable |
| 51 | # |
| 52 | |
| 53 | # Create the linux device file, if it does not already exist |
| 54 | if [ ! -c /dev/linux-user-bde ]; then |
| 55 | mknod /dev/linux-user-bde c 126 0 |
| 56 | fi |
| 57 | ./bcm.user |
| 58 | echo "OK" |
| 59 | ;; |
| 60 | stop) |
| 61 | echo -n "Stopping bcm.user: " |
| 62 | pkill -f bcm.user |
| 63 | echo "OK" |
| 64 | ;; |
| 65 | restart|reload) |
| 66 | ;; |
| 67 | *) |
| 68 | echo "Usage: $0 {start|stop|restart}" |
| 69 | exit 1 |
| 70 | esac |
| 71 | |
| 72 | exit $? |