Use this script
#!/bin/bash
if [[ "$1" == "-h" ]]; then
echo ""
echo "Usage : setup.box"
exit -1
fi
box=$1
if [ ! "$1" ]; then
echo Box name not provided
echo Bailing.
exit -1
fi
ip4=$(hosts sgn)
ip6=$(hosts sgn6)
cat >/dev/null <<DONE
ssh $box sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
ssh $box sudo setenforce 0
ssh $box reboot
ssh $box useradd habib -G wheel
ssh $box sed -i \'s/^%wheel/#%wheel/\' /etc/sudoers
ssh $box sed -i \'s/^# %wheel/%wheel/\' /etc/sudoers
ssh $box rsync /root/.ssh /home/habib/ -va
ssh $box chown habib.habib -R /home/habib/.ssh
rsync /home/habib/.ssh $box:/home/habib -vaz
ssh $box rsync /home/habib/.ssh/ /root/.ssh/ -va && chown root.root -R /root/.ssh
ssh $box sed -i 's/user habib/user root/' /root/.ssh/config
# user switch to habib
ssh $box rsync old:/home/habib/ /home/habib/ -vaz
rsync ~/.ssh $box:~/ -vaz
ssh $box sudo dnf install -y vim
ssh $box sudo dnf install -y letsencrypt
ssh $box sudo dnf install -y lsd
ssh $box sudo dnf install -y dovecot
ssh $box sudo dnf install -y postfix
ssh $box sudo dnf install -y httpd
ssh $box sudo dnf install -y php
ssh $box sudo dnf install -y php-devel
ssh $box sudo dnf install -y php-pear
ssh $box sudo dnf install -y pv
ssh $box sudo dnf install -y php-maxmind-db-reader
ssh $box sudo dnf install -y php-pecl-imagick
ssh $box sudo dnf install -y htop
ssh $box sudo dnf install -y geolite2-asn geolite2-city geolite2-country
ssh $box sudo dnf install -y logrotate
ssh $box sudo dnf install -y time
ssh $box sudo dnf install -y dovecot-lmtp
ssh $box sudo dnf install -y roundcube
ssh $box sudo dnf install -y roundcubemail
ssh $box sudo dnf install -y pypolicyd-spf
ssh $box sudo dnf install -y mlocate
ssh $box sudo dnf install -y sqlite
ssh $box sudo dnf install -y mod_ssl
ssh $box sudo dnf install -y ImageMagick
ssh $box sudo dnf install -y pypolicyd-spf
ssh $box sudo mkdir /web
ssh $box sudo chown habib.habib /web
ssh $box rsync old:/web/ /web/ -az
ssh $box sudo rsync old:/etc/letsencrypt/live/ /etc/letsencrypt/live/ -vaz
ssh $box sudo scp old:/etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf
ssh $box sudo scp old:/etc/httpd/conf.d/roundcubemail.conf /etc/httpd/conf.d/roundcubemail.conf
ssh $box sudo scp old:/etc/dovecot/mailusers /etc/dovecot/mailusers
ssh $box sudo scp old:/etc/dovecot/local.conf /etc/dovecot/local.conf
ssh $box sudo scp old:/etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf
ssh $box sudo scp old:/etc/dovecot/conf.d/10-ssl.conf /etc/dovecot/conf.d/10-ssl.conf
ssh $box sudo scp old:/etc/postfix/master.cf /etc/postfix/master.cf
ssh $box sudo scp old:/etc/postfix/main.cf /etc/postfix/main.cf
ssh $box sudo scp old:/etc/php.ini /etc/php.ini
ssh $box sudo scp old:/etc/php-fpm.conf /etc/php-fpm.conf
ssh $box sudo scp old:/etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf
ssh $box sudo scp old:/etc/php.d/habib.ini /etc/php.d/habib.ini
ssh $box sudo scp old:/etc/letsencrypt/options-ssl-apache.conf /etc/letsencrypt/options-ssl-apache.conf
ssh $box sudo scp old:/etc/dovecot/conf.d/auth-system.conf.ext /etc/dovecot/conf.d/auth-system.conf.ext
ssh $box sudo scp old:/etc/roundcubemail/config.inc.php /etc/roundcubemail/config.inc.php
ssh $box sudo scp old:/etc/python-policyd-spf/policyd-spf.conf /etc/python-policyd-spf/policyd-spf.conf
ssh $box "cd /web/ext/astro && make clean && phpize && ./configure && make && sudo make install"
ssh $box "cd /web/ext/string && make clean && phpize && ./configure && make && sudo make install"
ssh $box "cd /web/ext/tigerit && make clean && phpize && ./configure && make && sudo make install"
ssh $box "sudo chown habib.habib /var/log/httpd"
ssh $box "sudo chown -R habib.habib /etc/roundcubemail"
ssh $box "sudo systemctl enable php-fpm && sudo systemctl start php-fpm"
ssh $box "sudo systemctl enable httpd && sudo systemctl start httpd"
ssh $box "sudo systemctl enable postfix && sudo systemctl start postfix"
ssh $box "sudo systemctl enable dovecot && sudo systemctl start dovecot"
ssh $box "cd /web/cache && make install"
ssh $box "cd /web/news && make install"
ssh old chmod 444 /web/cash/cash.db
ssh old "sudo systemctl stop newsbot"
ssh old "sudo systemctl disable newsbot"
ssh $box "rsync old:/web/news/data/old_news.db /web/cash/old_news.db -vz"
ssh $box "rsync old:/web/cash/data/cash.db /web/cash/data/cash.db -vz"
ip4=$(hosts sgn)
ip6=$(hosts sgn6)
echo migrating to ip4=$ip4 and ip6=$ip6
do.migrate habibur.com code $ip4 $ip6
do.migrate habibur.com facebook $ip4 $ip6
do.migrate habibur.com cash $ip4 $ip6
do.migrate habibur.com smtp $ip4 $ip6
do.migrate habibur.com bangla $ip4 $ip6
do.migrate habibur.com myip $ip4 $ip6
do.migrate habibur.com wiki $ip4 $ip6
do.migrate habibur.com todo $ip4 $ip6
do.migrate habibur.com moon $ip4 $ip6
do.migrate habibur.com rpn $ip4 $ip6
do.migrate habibur.com family $ip4 $ip6
do.migrate habibur.com hajj $ip4 $ip6
do.migrate habibur.com lang $ip4 $ip6
do.migrate habibur.com kitab $ip4 $ip6
do.migrate habibur.com hadith $ip4 $ip6
do.migrate habibur.com quran $ip4 $ip6
do.migrate habibur.com iploc $ip4 $ip6
do.migrate habibur.com hijri $ip4 $ip6
do.migrate habibur.com salat $ip4 $ip6
do.migrate habibur.com cache $ip4 $ip6
do.migrate habibur.com imap $ip4 $ip6
do.migrate habibur.com astro $ip4 $ip6
do.migrate habibur.com notes $ip4 $ip6
do.migrate habibur.com files $ip4 $ip6
do.migrate habibur.com maps $ip4 $ip6
do.migrate habibur.com afis $ip4 $ip6
do.migrate habibur.com news $ip4 $ip6
do.list sanjir.com @ A | tr -s ' ' | cut -d' ' -f1 | xargs -I{} do.del sanjir.com delete {}
do.add sanjir.com @ A $ip4
do.list sanjir.com @ AAAA | tr -s ' ' | cut -d' ' -f1 | xargs -I{} do.del sanjir.com delete {}
do.add sanjir.com @ AAAA $ip6
ssh $box "rsync old:/web/mail/ /web/mail/ -az"
ssh $box sudo chown habib.habib /var/lib/php/session
DONE