-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfixcentos7.sh
55 lines (45 loc) · 1.66 KB
/
fixcentos7.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
#!/bin/bash
#Fix centos 7 instalation
#Felipe Ferreira, Feb 2017
SVCS="wpa_supplicant alsa-state cups abrt-xorg abrt-oops avahi-daemon atd abrtd irqbalance packagekit getty@tty1 libstoragemgmt NetworkManager"
function disablesvc()
{
# echo "Stoping/Disablingservice $SVC"
if systemctl -t service |grep runn |grep $SVC; then systemctl stop $SVC ; fi
if systemctl list-unit-files --type service |grep enabled |grep $SVC; then systemctl disable $SVC; fi
}
#REMOVE IPV6 FROM CENTOS 7
function rmipv6()
{
if [[ $(ip addr |grep -c inet6) > 0 ]]; then
echo "IPV6 IP found"
#GET network interface configuration file
if [[ $(find /etc/sysconfig/network-scripts/ -name 'ifcfg-eno*' -exec grep -c 'IPV6_DEFROUTE="yes"' {} \;) = 1 ]]; then
echo "IPV6 e ativato"
FILE=$(find /etc/sysconfig/network-scripts/ -name 'ifcfg-eno*' |tail -n1 )
sed -e '/IPV6_PEERDNS="yes"/d' -e '/IPV6_PEERROUTES="yes"/d' -e '/IPV6_PRIVACY="no"/d' -e '/IPV6_DEFROUTE="yes"/d' -e '/IPV6_AUTOCONF="yes"/d' -e '/IPV6_FAILURE_FATAL/d' -e '/IPV6INIT/c\IPV6INIT="no"' -i $FILE
cat <<EOF>>/etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
EOF
sysctl -p >/dev/null
sed -i '/::1/d' /etc/hosts
echo "IPV6 disabled, please restart network service"
fi
fi
}
################################## MAIN
LINUXVER=$(cat /etc/*release |tail -n 1 |awk '{ print $(NF - 1) }')
LINUXVER_MINOR=$(echo $LINUXVER |awk -F"." '{ print $NF}' )
LINUXVER=$(echo $LINUXVER |awk -F"." '{ print $1}' )
if [ $LINUXVER -eq 7 ]; then
rmipv6
for SVC in $SVCS
do
disablesvc $SVC
done
else
echo "Only works for Linux CentOS/RedHat 7"
fi
#echo "Run systemctl restart network"
echo -e "\nDONE"