COMPLETED
Technical summary
Bash script to perform end-to-end dedicated IP changes on cPanel accounts, including DNS zone updates (/var/named), Apache virtual hosts (httpd.conf), account primary record (/var/cpanel/users/<user>), and per-domain userdata files (including SSL variants).
Executed scope
- Bash reimplementation of legacy
chgacctip(Perl) with functional parity. - Coordinated IP replacement across multiple server configuration layers.
- SOA serial increment in DNS zones after A-record changes.
- Lock control to avoid concurrent
httpd.confwrites. - Execution modes with and without rebuild/restart (
y|n). - Edge-case handling: same source/target IP and zones without old-IP occurrences.
Technical flow
- Validate cPanel username and target IP.
- Detect current account IP from
/var/cpanel/users/<user>. - Process DNS zones under
/var/named(and named chroot if present). - Replace IP in account-related
VirtualHostblocks inhttpd.conf. - Update
IP=in cPanel user file. - Update
ip:in per-domain userdata and_SSLfiles. - If
y, run rebuild/reload sequence (named, userdata cache, userdomains, apache rebuild/restart).
Practical execution
# switch without service rebuild
./cp-chgacctip.sh dominio123 192.168.1.100
# switch with full rebuild/restart
./cp-chgacctip.sh dominio123 192.168.1.100 y
# same-ip edge case
./cp-chgacctip.sh dominio123 51.79.52.232
Affected files/components
/var/named/*.db(and optionally/var/named/chroot/var/named/*.db)/usr/local/apache/conf/httpd.conf/var/cpanel/users/<username>/var/cpanel/userdata/<username>/*and*_SSL
Safe operation and rollback
# recommended pre-change backup
cp -a /var/named/*.db /backup/named/
cp /usr/local/apache/conf/httpd.conf /backup/httpd.conf.bak
cp -a /var/cpanel/users/username /backup/
cp -a /var/cpanel/userdata/username /backup/
Operational troubleshooting
# validate account exists
ls /var/cpanel/users/username
# stuck apache lock
rm -f /usr/local/apache/conf/httpd.conf.lock
# manual rebuilds
rndc reload
/scripts/rebuildhttpdconf
/etc/init.d/httpd graceful
Stack and tooling
- Shell Script / Bash
- cPanel/WHM
- BIND9 / named
- Apache / httpd
- sed
- grep
Operational tags
- cPanel
- Bash
- DNS
- Apache
Operational outcome
- Lower inconsistency risk between DNS, Apache and cPanel metadata during IP switching.
- Reproducible workflow for migration and network remediation operations.
- Reduced manual effort/time in infrastructure changes involving dedicated accounts.
GitHub progress (issues)
Real-time panel with latest repository issues.
live feed
open issues on GitHubcarregando andamento...
não foi possivel carregar as issues agora. abra no github pelo link acima.
Real results
Bash rewrite of the classic chgacctip utility to change dedicated IPs on cPanel accounts with coordinated updates across DNS, Apache, userdata and account files.
Architecture and organization
- Shell Script / Bash
- cPanel/WHM
- BIND9
- Apache
- httpd.conf
- sed
- grep
Execution and operations
The project follows reproducible execution flow with technical validation in production-like environments.
Screenshots
Talk about this project
Apply this implementation pattern in your environment and accelerate delivery with technical consistency.