We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2bd673a commit d3d5320Copy full SHA for d3d5320
scripts_all/cpanel_change_ip.sh
@@ -2,4 +2,16 @@
2
# Cpanel change IP
3
# CanhDX NhanHoa Cloud Team
4
5
-#new_ip=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -n 1)
+# 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