Commit 1eec9d1a authored by Vitaly Lipatov's avatar Vitaly Lipatov

add archive_site script

parent 2d2873c9
#!/bin/sh
# remove site to archive:
# $ archive_site.sh /path/to/site
test "$1" || exit 1
SITEPATH="$(realpath $1)"
USERNAME=$(echo "$SITEPATH" | sed -e "s|/home/\(.*\)/.*|\1|g" | sed -e "s|/.*||g")
DOMAINNAME=$(basename "$SITEPATH" | tr [A-Z] [a-z] | sed -e "s/:.*//g")
IP=$(resolve -s $DOMAINNAME)
IPHOST=91.232.225.9
[ -n "$IP" ] || echo "domain $DOMAINNAME is not exists"
if [ -n "$IP" ] && [ "$IP" = "$IPHOST" ] ; then
echo "$DOMAINNAME still on $IPHOST IP ($IP really)"
exit
fi
test -n "$USERNAME" || exit
test -d "/home/$USERNAME" || exit
test -n "$DOMAINNAME" || exit
cd $(dirname $0) || exit
. ./config
. ./functions
. ./functions-apache
set_vars
cd /etc/httpd2/conf/sites-enabled || exit
conffile="$APACHECONF"
[ -n "$conffile" ] || conffile=$DOMAINNAME.conf
echo "$conffile"
# archive config
mkdir -p /home/archive
mv $conffile /home/archive/$conffile
cd "$SITEPATH" || exit
erc a /home/archive/$DOMAINNAME.tar.xz . || exit
rm -vrf "$SITEPATH"
rmdir "/home/$USERNAME/www" && rm -vrf /home/$USERNAME/ && userdel $USERNAME
cd /
serv httpd2 reload
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment