Skip to content

Commit d3d5320

Browse files
authored
Update cpanel_change_ip.sh
1 parent 2bd673a commit d3d5320

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

scripts_all/cpanel_change_ip.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@
22
# Cpanel change IP
33
# CanhDX NhanHoa Cloud Team
44

5-
#new_ip=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1)
5+
# Get info
6+
NEW_IP=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1)
7+
OLD_IP=$(cat /usr/local/apache/conf/httpd.conf | grep VirtualHost | head -n 1 | awk '{print $2}' | cut -d ':' -f1)
8+
9+
# Sed info
10+
sed -Ei "s/$OLD_IP/$NEW_IP/g" /usr/local/apache/conf/httpd.conf
11+
sed -Ei "s/$OLD_IP/$NEW_IP/g" /etc/wwwacct.conf
12+
sed -Ei "s/$OLD_IP/$NEW_IP/g" /etc/hosts
13+
sed -Ei "s/$OLD_IP/$NEW_IP/g" /var/cpanel/mainip
14+
15+
# Restart Service
16+
service named restart || systemctl restart named
17+
service httpd restart || systemctl restart httpd

0 commit comments

Comments
 (0)