forked from MiteshShah/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathethspeed.sh
executable file
·68 lines (57 loc) · 1.35 KB
/
ethspeed.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
#!/bin/sh
# Make The Script Executable
SCRIPTPATH=`pwd`/$0
echo
echo "Script Absolute Path = $SCRIPTPATH"
echo "Make Script Executable"
sudo chmod 755 $SCRIPTPATH
# Make A New Directory In /Etc
echo
if [ -d /etc/rtcamp ]
then
echo "/etc/rtcamp Directory Exist"
else
echo "Creating /etc/rtcamp Directory"
sudo mkdir /etc/rtcamp
fi
echo
echo "Copy Script in /etc/rtcamp/"
sudo cp -v $SCRIPTPATH /etc/rtcamp/
# Check Ethtool Is Installed
dpkg --list | grep ethtool &> /dev/null
if [ $? -eq 0 ]
then
echo
echo "Ethtool Already Installed "
else
echo
echo "Installing Ethtool... "
sudo apt-get install ethtool
fi
# Set Ethtool Path
echo
ETHTOOL=$(whereis ethtool | cut -d: -f2 | cut -d' ' -f2)
echo Ethtool Path = $ETHTOOL
# Findout No Of Ethernet Cards
echo
DEVICES=$(lshw -class network | grep ' logical name' | cut -d: -f2 | cut -d' ' -f2 | tr '\n' ' ')
echo "Ethernet Cards = $DEVICES"
for SET in $DEVICES
do
echo
echo
echo "Setting $SET Speed 1GB/s Duplex Full... "
$ETHTOOL -s $SET autoneg off speed 100 duplex full;
$ETHTOOL -s $SET autoneg off speed 1000 duplex full;
$ETHTOOL -s $SET autoneg on;
done
# Add Script To RC.LOCAL
cat /etc/rc.local | grep ethspeed.sh &> /dev/null
echo
if [ $? -eq 0 ]
then
echo "Already Script Entry in /etc/rc.local"
else
echo "Adding Script Entry in /etc/rc.local"
sed -i '$ i\/etc/rtcamp/ethspeed.sh' /etc/rc.local
fi