Proper way to change server hostname

Post Reply
User avatar
dpeca
Site Admin
Posts: 224
Joined: Fri Jun 19, 2020 9:59 am
Location: Serbia, Niš
Proper way to change server hostname

Post by dpeca »

In your SSH, as root, run:

Code: Select all

/usr/loal/vesta/bin/v-change-sys-hostname YOUR-NEW-HOSTNAME-HERE
also:

Code: Select all

ACCOUNT='*'  # don't change this

OLDHOST=''  # enter here old hostname
OLDNS1=''  # enter here old NS1
OLDNS2=''  # enter here old NS2

NEWHOST=''  # enter here new hostname
NEWNS1=''  # enter here new NS1
NEWNS2=''  # enter here new NS2

find /home/$ACCOUNT/conf/dns/ -type f -exec sed -i "s#$OLDHOST#$NEWHOST#g" {} \;
find /home/$ACCOUNT/conf/dns/ -type f -exec sed -i "s#$OLDNS1#$NEWNS1#g" {} \;
find /home/$ACCOUNT/conf/dns/ -type f -exec sed -i "s#$OLDNS2#$NEWNS2#g" {} \;
find /usr/local/vesta/data/users/$ACCOUNT/dns/ -type f -exec sed -i "s#$OLDHOST#$NEWHOST#g" {} \;
find /usr/local/vesta/data/users/$ACCOUNT/dns/ -type f -exec sed -i "s#$OLDNS1#$NEWNS1#g" {} \;
find /usr/local/vesta/data/users/$ACCOUNT/dns/ -type f -exec sed -i "s#$OLDNS2#$NEWNS2#g" {} \;
sed -i "s#$OLDHOST#$NEWHOST#g" /usr/local/vesta/data/users/$ACCOUNT/dns.conf
sed -i "s#$OLDNS1#$NEWNS1#g" /usr/local/vesta/data/users/$ACCOUNT/dns.conf
sed -i "s#$OLDHOST#$NEWHOST#g" /usr/local/vesta/data/users/$ACCOUNT/user.conf
sed -i "s#$OLDNS1#$NEWNS1#g" /usr/local/vesta/data/users/$ACCOUNT/user.conf
sed -i "s#$OLDNS2#$NEWNS2#g" /usr/local/vesta/data/users/$ACCOUNT/user.conf
sed -i "s/$OLDHOST/$NEWHOST/g" /etc/roundcube/plugins/password/config.inc.php
grep -rl "$OLDHOST" /etc | xargs sed -i "s/$OLDHOST/$NEWHOST/g"
grep -rl "$OLDHOST" /usr/local/vesta/conf | xargs sed -i "s/$OLDHOST/$NEWHOST/g"
sed -i "s#$OLDNS1#$NEWNS1#g" /usr/local/vesta/data/packages/*.pkg
sed -i "s#$OLDNS2#$NEWNS2#g" /usr/local/vesta/data/packages/*.pkg
service bind9 reload

Tags:


Post Reply