📄 launch.sh
字号:
#/bin/bash
KVER=$(uname -r | awk -F [.] '{print $$1}')
# Make sure the user is root - Otherwise rmmod and insmod will fail
if [ $USER != "root" ]; then
echo "Need to be root user to continue!!"
exit 1
fi
# See if older driver versions are loaded
OLD1=$(cat /proc/modules | grep macphy | awk '{print $1}')
OLD2=$(cat /proc/modules | grep natsemi | awk '{print $1}')
if [ "$OLD1" = "macphy" ]; then
echo "Older Macphyter driver is loaded... Unloading it "
OLDETH=$(cat /var/log/messages | grep DP838 | tail -n 1 | awk '{print substr($$1, match($$1, "eth"), 4)}')
echo "Bringdown interface : $OLDETH"
ifconfig $OLDETH down
rmmod macphy
sleep 2
fi
if [ "$OLD2" = "natsemi" ]; then
echo "Community distributed driver is loaded... Unloading it "
OLDETH=$(cat /var/log/messages | grep NatSemi | tail -n 1 | awk '{print substr($$1, match($$1, "eth"), 4)}')
echo "Bringdown interface : $OLDETH"
ifconfig $OLDETH down
rmmod natsemi
sleep 2
fi
#Check the mode in which to load the driver
if [ $1 ]; then
OPMODE=$1
else
OPMODE=0
fi
# Load new driver - depending on the version, after making it (if needed)
if [ $KVER != 6 ] ; then
echo "Kernel ver detected as 2.4.x"
cp -f Makefile.2.4 Makefile
make
insmod macphy.o OpMode=$OPMODE
sleep 1
else
echo "Kernel ver detected as 2.6.x"
cp -f Makefile.2.6 Makefile
make
insmod macphy.ko OpMode=$OPMODE
sleep 1
fi
ETH=$(tail -n 3 /var/log/messages | grep eth | awk '{print substr($$1, match($$1, "eth"), 4)}')
echo "MacPhyter device is" : $ETH
echo "Bringing up" : $ETH
ifconfig $ETH up
echo
echo To assign an IP address do "ifconfig $ETH Ip.ad.re.ss"
echo
# Display the mode in which the driver was loaded
case "$OPMODE" in
0)
echo "Driver was loaded in NORMAL mode!"
echo "---------------------------------"
echo " [Operation] : [Owner] "
echo "---------------------------------"
echo " H/w initialiation : Driver "
echo " Tx and Rx : OS (Network Stack)"
echo " Register access : Driver, Integrity"
echo
;;
1)
echo "Driver was loaded in MONITOR mode!"
echo "---------------------------------"
echo " [Operation] : [Owner] "
echo "---------------------------------"
echo " H/w initialiation : Driver "
echo " Tx and Rx : Integrity "
echo " Register access : Driver, Integrity"
echo
;;
2)
echo "Driver was loaded in LOAD-ONLY mode!"
echo "---------------------------------"
echo " [Operation] : [Owner] "
echo "---------------------------------"
echo " H/w initialiation : Integrity "
echo " Tx and Rx : Integrity "
echo " Register access : Integrity "
echo
esac
echo "To load the Driver in a different mode pass the mode-code as shown below to the Launch Script"
echo "E.g. Launch 1"
echo "---------------------------"
echo "[Mode] : [Code] "
echo "---------------------------"
echo "NORMAL : 0 "
echo "MONITOR : 1 "
echo "LOAD-ONLY : 2 "
echo
sleep 1
exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -