LittleDemon WebShell


Linux server27.hostingraja.org 2.6.32-954.3.5.lve1.4.93.el6.x86_64 #1 SMP Wed Oct 4 17:04:29 UTC 2023 x86_64
Path : /scripts/
File Upload :
Command :
Current File : //scripts/prekillacct

#!/bin/bash
######  Hosting Raja Backup starts here, Take backup of the account, Someone can terminate it accidently #######
#==========================================================================
#
#  Backup an account when it is deleted so it can be reversed
#
#  We also backup other stuff:
#   - zones (so we have the IP)
#   - the domain names in a log file /etc/userdomains.deleted
#   - the max emails per domain iff exists
#   - local vs remotedomains status
#
#==========================================================================
ME=${0##*/}
backupdir=/Server-Backup4TB/terminated
LOG_FILE_NAME=$backupdir/terminated.log
date >> $LOG_FILE_NAME
find $backupdir -type f -mtime +90 -exec rm -fv {} \;
umask 077
exec > /tmp/prekillacct.log 2>&1
#
#   Parse argument pairs
#
while [ $# != 0 ]
do
    eval cp_$1="$2"
    shift 2
done
eval homedir='~'$cp_user
set | grep cp_ >> $LOG_FILE_NAME # debug - what args were we given
test -d $backupdir || mkdir -p $backupdir
#
#   Save the user -> domainname mapping for future grepping
#   otherwise this is very hard to find out
#
grep ": $cp_user\$" /etc/userdomains  >> $backupdir/userdomains.deleted
cp $backupdir/userdomains.deleted /etc/userdomains.deleted
# /etc/userdomains excerpt:
# nzsnowstuff.com: snowstuf
# nzsnowstuff.snowstuff.com.au: snowstuf
# snowstuff.com.au: snowstuf
#
#   Backup a whole bunch of assorted files that don't get included normally
#    - Backup a copy of the zone files in ~/.named_hostname
#    - This is so we can find the former IP plus any other special IPs
#
hostname=$(hostname)
namedir=$homedir/.named_$hostname
test ! -d $namedir && mkdir $namedir
grep ": $cp_user\$" /etc/userdomains |
  while IFS=":$IFS" read domain u1
  do
    echo backing up $domain zone ... >> $LOG_FILE_NAME
    # keep them owned by root
    cp -p /var/named/${domain}.db $namedir
    # backup MX hosting for domain as well ...
    grep "^$domain$" /etc/localdomains /etc/remotedomains >> $homedir/.mxhost
    # backup max email limit per domain
    maxem=/var/cpanel/maxemailsperdomain/$domain
    if [ -s $maxem ]
    then
    [ ! -d $homedir/.maxemails ] && mkdir $homedir/.maxemails
        cp -p $maxem $homedir/.maxemails/.
    fi
  done
#/scripts/pkgacct $cp_user $backupdir >> $LOG_FILE_NAME

LittleDemon - FACEBOOK
[ KELUAR ]