| 123456789101112131415161718192021222324252627 |
- #!/bin/bash
- # Licence : GPL v3
- # Author: Laurent HUBERT
- #
- # Changes the machine hostname
- #
- cat <<EOF
- +---------------------------------------------+
- | Changing hostname |
- +---------------------------------------------+
- EOF
- read -p "Please enter new hostname: " answer
- if [ -n "$answer" ]
- then
- echo "Changing hostname to $answer"
- current=$(hostname)
- sed -i.firstboot.backup s/$current/$answer/g /etc/hostname
- sed -i.firstboot.backup s/$current/$answer/g /etc/hosts
- hostname $answer
- echo "> Hostname changed to $answer <"
- exit 0
- else
- # Exit with non zero status
- echo "### Could not change hostname ###"
- exit 1
- fi
|