-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenableAQC111.sh
92 lines (75 loc) · 2.2 KB
/
enableAQC111.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
#title :enableAQC111.sh
#description :This script will make aqc111 driver enable in DSM 6.2.
#author :garynil.tw
#date :20200608
#version :0.1
#usage :bash enableAQC111.sh
#==============================================================================
while getopts p:a: flag
do
case "${flag}" in
a) action=${OPTARG};;
p) path=${OPTARG};;
d) driver=${OPTARG};;
esac
done
SYNOPKG_PKGDEST=$path
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
[ -z "$path" ] && SYNOPKG_PKGDEST=$DIR
ACTION=$action
[ -z "$action" ] && ACTION="up"
driver_name=$driver
[ -z "$driver" ] && driver_name="aqc111"
echo "Action: $ACTION";
echo "Path: $SYNOPKG_PKGDEST";
modArray=( aqc111 usbnet mii )
for i in "${modArray[@]}"
do
echo "detecting.. ".$i.ko
if [ ! -z "$(lsmod | grep $i)" ]
then
echo "removed ".$i.ko
/sbin/rmmod $SYNOPKG_PKGDEST/$i.ko
fi
done
sleep 2;
/sbin/insmod $SYNOPKG_PKGDEST/mii.ko
/sbin/insmod $SYNOPKG_PKGDEST/usbnet.ko
/sbin/insmod $SYNOPKG_PKGDEST/aqc111.ko
# Check if aqc111 is enable in mod
check_aqc111=`/sbin/lsmod | grep $driver_name`
if [ -z "$check_aqc111" ]
then
exit 0;
else
echo -z "$check_aqc111";
fi
for interface_name in $(ls /sys/class/net)
do
if [[ ! $interface_name =~ ^eth ]]
then
continue
fi
driver_location=$(ls -ld /sys/class/net/$interface_name/device/driver)
interface_has_aqc111_driver=false
if [ ! -z "$(echo "$driver_location" | grep $driver_name)" ]
then
interface_has_aqc111_driver=true
fi
echo "interface_has_aqc111_driver is "$interface_has_aqc111_driver
if [ $interface_has_aqc111_driver = true ]
then
config_file=/etc/sysconfig/network-scripts/ifcfg-$interface_name
config_storage_location=$SYNOPKG_PKGDEST/ifcfg-$interface_name
if [ -f "$config_file" ] && [ "$ACTION" = "down" ]
then
cp $config_file $config_storage_location
elif [ "$ACTION" = "up" ] && [ -f "$config_storage_location" ]
then
cp $config_storage_location $config_file
fi
echo $interface_name" is "$ACTION" by ifconfig"
ifconfig $interface_name $ACTION
fi
done