Skip to content

Instantly share code, notes, and snippets.

@xcdr
Last active January 11, 2016 12:07
Show Gist options
  • Save xcdr/0b6582697a9bc25db2d8 to your computer and use it in GitHub Desktop.
Save xcdr/0b6582697a9bc25db2d8 to your computer and use it in GitHub Desktop.
Reset hostname and sshd for vm-template.
#!/bin/sh
find /var/log -name *.gz -print -delete
find /var/log -name *.log-* -print -delete
SRC_HOSTNAME='vm-template'
DST_HOSTNAME='vm-hostname'
sed -i'' -e"s/${SRC_HOSTNAME}/${DST_HOSTNAME}/g" /etc/hostname
sed -i'' -e"s/${SRC_HOSTNAME}/${DST_HOSTNAME}/g" /etc/hosts
/bin/rm -v /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
sed -i'' -e"s/${SRC_HOSTNAME}/${DST_HOSTNAME}/g" /etc/mailname
sed -i'' -e"s/${SRC_HOSTNAME}/${DST_HOSTNAME}/g" /etc/exim4/update-exim4.conf.conf
update-exim4.conf
sed -i'' -e"s/${SRC_HOSTNAME}/${DST_HOSTNAME}/g" /etc/apticron/apticron.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment