Guest User

Change domain name script

a guest
Jan 27th, 2014
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. #!/bin/bash
  2. # Ava Gailliot
  3. # Find and replace domain name from system files
  4.  
  5. olddomain=olddomain.com
  6. newdomain=newdomain.com
  7.  
  8. configs=( '/etc/hosts' '/etc/exports' '/etc/fstab' '/etc/sysconfig/network' )
  9. for file in "${configs[@]}"
  10. do
  11.         # Replace domain name and create backup file
  12.         sed -i.bak -e 's/$olddomain/$newdomain/g' $file
  13. done
  14.  
  15. # Find SSH keys for all users
  16. sed -i.bak -e 's/$olddomain/$newdomain/g' /home/*/.ssh/*
  17.  
  18. # change $HOSTNAME
  19. set $HOSTNAME=$(echo "${HOSTNAME%%.*}.$newdomain")
  20.  
  21. # Restart network
  22. service network restart
  23.  
  24. # Update NFS
  25. exportfs -a
Advertisement
Add Comment
Please, Sign In to add comment