One Hat Cyber Team
Your IP :
216.73.216.231
Server IP :
185.33.55.30
Server :
Linux cl30.webspacecontrol.com 5.14.0-611.38.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 10 17:21:28 EDT 2026 x86_64
Server Software :
Apache
PHP Version :
8.1.34
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
opt
/
transferfixer
/
View File Name :
postrestore.sh
#!/bin/bash -x cpuser=$1 if [ "${cpuser}" = "" ]; then echo "Usage: $0 <account>" exit 0 fi change_ns() { local _DOMAIN=$1 local _NS1=$2 local _NS2=$3 # #local WHMCS_URL="$( cat /opt/cxs2/app/config/dotroll.ini | grep -A100 '\[whmcs\]' | grep --max-count=1 url | cut -d= -f2 | tr -d ' ' )" #local WHMCS_USER="$( cat /opt/cxs2/app/config/dotroll.ini | grep -A100 '\[whmcs\]' | grep --max-count=1 user | cut -d= -f2 | tr -d ' ' )" #local WHMCS_PASS="$( echo -n $( cat /opt/cxs2/app/config/dotroll.ini | grep -A100 '\[whmcs\]' | grep --max-count=1 password | cut -d= -f2 | tr -d ' ') | md5sum | cut -d' ' -f1 )" # #echo "Changing NS for domain ${_DOMAIN}. New NS set: ${_NS1}/${_NS2}\n" #curl -6 --request POST ${WHMCS_URL} --data "action=DomainUpdateNameservers" -d "username=${WHMCS_USER}" --data-urlencode "password=${WHMCS_PASS}" --data-urlencode "domain=${_DOMAIN}" -d "ns1=${_NS1}" -d "ns2=${_NS2}" -d "responsetype=json" # } echo "--------- $0 : BEGIN ---------" echo "Harvesting variables" _BACKUPDIR=/opt/transferfixer/backups/${cpuser} _OLD_MAINIP=$( cat ${_BACKUPDIR}/OLDMAINIP) _OLD_IP=$( cat ${_BACKUPDIR}/OLDIP ) _NEW_MAINIP=$( cat /var/cpanel/mainip ) _OLD_HOST=$( cat ${_BACKUPDIR}/OLDHOST ) _OLD_HOST_PHPV=$( cat ${_BACKUPDIR}/OLDHOST_PHPV ) _NEW_HOST=$(hostname -f) _NEW_NS1=ns1.webspacecontrol.com _NEW_NS2=ns2.webspacecontrol.com _ZONEDIR=${_BACKUPDIR}/zones/ _ZONEDIR_NEW=${_BACKUPDIR}/zones_new/ mkdir ${_ZONEDIR_NEW} _ZONES=$( ls -1 ${_ZONEDIR} | /usr/bin/rev | /usr/bin/cut -d. -f2- | rev ) if [ $( echo ${_OLD_MAINIP} | /usr/bin/grep '185\.33\.5' | grep -v '^$' | /usr/bin/wc -l ) -gt 0 ]; then if [ $( echo $( /usr/bin/dig +short AAAA ${cpuser}.ipv6.loginssl.com ) | /usr/bin/grep '2a00:c760:83:def:aced:fff0:0:' | grep -v '^$' | /usr/bin/wc -l ) -gt 0 ]; then echo "Removing IPv6 address from old host (${_OLD_HOST})" ssh -o StrictHostKeyChecking=no ${_OLD_HOST} "ip a del dev bond0 $( /usr/bin/dig +short AAAA ${cpuser}.ipv6.loginssl.com )" fi echo "Disabling default IPv6 address to user ${cpuser} on the new host $(hostname -f)" /usr/local/cpanel/bin/whmapi1 ipv6_disable_account user=${cpuser} echo "Enabling IPv6 to user ${cpuser} on the new host $(hostname -f)" /usr/local/cpanel/bin/whmapi1 ipv6_enable_account user=${cpuser} range=${cpuser} for _ZONE in ${_ZONES}; do if [ "${_OLD_MAINIP}" = "${_OLD_IP}" ]; then echo "Changing ${_OLD_IP} -> ${_NEW_MAINIP} in ${_ZONEDIR_NEW}/${_ZONE}.db" /usr/bin/cat ${_ZONEDIR}/${_ZONE}.db | /usr/bin/sed "s|\b${_OLD_IP}\b|${_NEW_MAINIP}|g" | /usr/bin/sed "s|\b${_OLD_HOST%.}\b|${_NEW_HOST}|g" > ${_ZONEDIR_NEW}/${_ZONE}.db _SERIAL_NSE=$( /usr/bin/dig +short SOA ${_ZONE} @ns1.webspacecontrol.com | /usr/bin/cut -d' ' -f3 ) _SERIAL_NSI=$( /usr/bin/dig +short SOA ${_ZONE} @ns1.webspacecontrol.com | /usr/bin/cut -d' ' -f3 ) if [ ${_SERIAL_NSE} -gt ${_SERIAL_NSI} ]; then _UJSERIAL=$(( _SERIAL_NSE + 1 )) else _UJSERIAL=$(( _SERIAL_NSI + 1 )) fi echo "Changing zone serial to ${_UJSERIAL} in ${_ZONEDIR_NEW}/${_ZONE}.db" /usr/bin/sed -i "s|\s\([0-9]\+\) ;[ ]*Serial Number| ${_UJSERIAL} ;Serial Number|" ${_ZONEDIR_NEW}/${_ZONE}.db /usr/bin/cp -a ${_ZONEDIR_NEW}/${_ZONE}.db /var/named/${_ZONE}.db /usr/local/cpanel/scripts/dnscluster synczone ${_ZONE} fi done else echo "Disabling default IPv6 address to user ${cpuser} on the new host $(hostname -f)" /usr/local/cpanel/bin/whmapi1 ipv6_disable_account user=${cpuser} _ZONELIST="" for _ZONE in ${_ZONES}; do if [ $( /usr/bin/dig +short ns ${_ZONE} | /usr/bin/xargs -n1 /usr/bin/dig +short | /usr/bin/xargs -n1 /usr/bin/dig +short -x | /usr/bin/grep '\.xhu\.hu\.$' | /usr/bin/wc -l ) -gt 1 ]; then if [ $(echo ${_OLD_MAINIP} | /usr/bin/grep '195\.56\.100' | /usr/bin/wc -l) -gt 0 ]; then _OLD_NS1=$( /usr/bin/cat ${_ZONEDIR}/${_ZONE}.db | /usr/bin/grep "[^;].\+\s\+NS\s\+" | /usr/bin/awk '{ print $5 }'| /usr/bin/head -n1 ) _OLD_NS2=$( /usr/bin/cat ${_ZONEDIR}/${_ZONE}.db | /usr/bin/grep "[^;].\+\s\+NS\s\+" | /usr/bin/awk '{ print $5 }' | /usr/bin/head -n2 | /usr/bin/tail -n1 ) _OLD_NS3=$( /usr/bin/cat ${_ZONEDIR}/${_ZONE}.db | /usr/bin/grep "[^;].\+\s\+NS\s\+" | /usr/bin/awk '{ print $5 }' | /usr/bin/head -n3 | /usr/bin/tail -n1 ) _OLD_SOA=$( /usr/bin/cat ${_ZONEDIR}/${_ZONE}.db | /usr/bin/grep "^[^;].\+\s\+SOA\s\+" | /usr/bin/awk '{ print $6 }' ) echo -e "Changing ${_OLD_NS1%.} -> ${_NEW_NS1}, ${_OLD_NS2%.} -> ${_NEW_NS2}, delete ${_OLD_NS3}, and change ${_OLD_SOA%.} -> domreg.dotroll.com, \nand ${_OLD_IP} -> ${_NEW_MAINIP} and ${_OLD_HOST%.} -> ${_NEW_HOST} in ${_ZONEDIR_NEW}/${_ZONE}.db" /usr/bin/cat ${_ZONEDIR}/${_ZONE}.db | sed "s|\b${_OLD_NS1%.}\b|${_NEW_NS1}|g" \ | /usr/bin/sed "s|\b${_OLD_NS2%.}\b|${_NEW_NS2}|g" | /usr/bin/grep -v "[^;].\+\s\+NS\s\+${_OLD_NS3%.}" \ | /usr/bin/sed "s|\b${_OLD_SOA%.}\b|domreg.dotroll.com|g" \ | /usr/bin/sed "s|\b${_OLD_IP}\b|${_NEW_MAINIP}|g" \ | /usr/bin/sed "s|\b${_OLD_HOST%.}|${_NEW_HOST}|g" \ | /usr/bin/sed 's,\(\sTXT\s\+"v=spf.*+ip4:'${_NEW_MAINIP}'\) ,\1 include:spf.webspacecontrol.com ,g' > ${_ZONEDIR_NEW}/${_ZONE}.db _SERIAL_NSE=$( /usr/bin/dig +short SOA ${_ZONE} | cut -d' ' -f3 ) echo "External SOA record for the ${_ZONE} is ${_SERIAL_NSE}" _SERIAL_NSI=$( /usr/bin/dig +short SOA ${_ZONE} @ns1.webspacecontrol.com| cut -d' ' -f3 ) echo "Internal SOA record for the ${_ZONE} is ${_SERIAL_NSI}" if [ ${_SERIAL_NSE} -gt ${_SERIAL_NSI} ]; then _UJSERIAL=$(( _SERIAL_NSE + 2 )) else _UJSERIAL=$(( _SERIAL_NSI + 2 )) fi echo "Changing zone serial to ${_UJSERIAL} in ${_ZONEDIR_NEW}/${_ZONE}.db" /usr/bin/sed -i "s|\s\([0-9]\+\)\s\+;[ ]*[Ss]erial| ${_UJSERIAL} ;Serial Number|" ${_ZONEDIR_NEW}/${_ZONE}.db /usr/bin/cp -a ${_ZONEDIR_NEW}/${_ZONE}.db /var/named/${_ZONE}.db /usr/bin/chown named:named /var/named/${_ZONE}.db /usr/bin/chmod 600 /var/named/${_ZONE}.db /usr/local/cpanel/scripts/dnscluster synczone ${_ZONE} _ZONELIST="${_ZONE},${_ZONELIST}" fi fi done echo "Replacing old (${_OLD_HOST}) MySQL server host to localhost" /usr/bin/grep --exclude=\*.{png,jpg,pdf,jpeg,zip,tar.gz,iso,img,doc,docx,xls,xlsx} --files-with-matches -r '\b10\.20\.30\.2\b' /home/${cpuser}/ | /usr/bin/xargs --verbose -I'()' sed 's/\b10\.20\.30\.2\b/localhost/g' -i '()' echo "Adding IPv6 to user ${cpuser} on the new host $(hostname -f)" /opt/cxs2/loginssl.php ipv6 add ${cpuser} if [ -n "${_ZONELIST}" ]; then echo "Changing ${_ZONELIST} nameservers to ns1.webspacecontrol.com and ns2.webspacecontrol.com" echo "/opt/cxs2/loginssl.php changens dotroll ${_ZONELIST%,} ns1.webspacecontrol.com ns2.webspacecontrol.com" | /usr/bin/at -m now +3 minutes fi fi echo "Setting current PHP version the ${cpuser} user" _CURRENT_PHP=$( /usr/bin/grep "^php[ ]*=[ ]*" /home/${cpuser}/.cl.selector/defaults.cfg | /usr/bin/tr -d ' ' | /usr/bin/cut -d= -f2 ) if [ "${_CURRENT_PHP}" = "native" ]; then if [ "$( selectorctl --show-native-version )" != "${_OLD_HOST_PHPV}" ]; then /usr/bin/selectorctl --set-user-current=${_OLD_HOST_PHPV} --user=${cpuser} else /usr/bin/selectorctl --set-user-current=${_CURRENT_PHP} --user=${cpuser} fi else /usr/bin/selectorctl --set-user-current=${_CURRENT_PHP} --user=${cpuser} fi echo "Fixing user directories and files permissions" /usr/bin/fixperms.sh -a "${cpuser}" echo "Setting Hungarian locale the new user account" /usr/local/cpanel/bin/cpapi2 --user="${cpuser}" SetLang setlocale locale=hu echo "Set the Paper Lantern Basic theme for the transferred accounts" /usr/local/cpanel/scripts/modify_accounts --users="${cpuser}" --theme=jupiter #rm -vrf ${_BACKUPDIR} _OLD_CL_SERIAL=$( echo "${_OLD_HOST}" | cut -d. -f1 | tr -d '[:alpha:]' ) _NEW_CL_SERIAL=$( echo "${_NEW_HOST}" | cut -d. -f1 | tr -d '[:alpha:]' ) echo "_OLD_CL_SERIAL=${_OLD_CL_SERIAL}" echo "_NEW_CL_SERIAL=${_NEW_CL_SERIAL}" if [ ${_OLD_CL_SERIAL} -le 20 -a ${_NEW_CL_SERIAL} -gt 20 ]; then echo ipv6 elvesz, hozzaad /opt/cxs2/loginssl.php ipv6 remove ${cpuser} ; sleep 10 ; /opt/cxs2/loginssl.php ipv6 add ${cpuser} elif [ ${_NEW_CL_SERIAL} -le 20 -a ${_OLD_CL_SERIAL} -gt 20 ]; then echo ipv6 elvesz, hozzaad /opt/cxs2/loginssl.php ipv6 remove ${cpuser} ; sleep 10 ; /opt/cxs2/loginssl.php ipv6 add ${cpuser} fi echo "--------- $0 : END ---------"