Skip to content

Instantly share code, notes, and snippets.

@bgulla
Created June 22, 2021 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgulla/87488d3956df3ec7f943445652f7e9b3 to your computer and use it in GitHub Desktop.
Save bgulla/87488d3956df3ec7f943445652f7e9b3 to your computer and use it in GitHub Desktop.
#!/bin/bash
## helper script to more easily personalize cloned virtual-machines. add to your bashrc.
## on login, it will test the hostname and if localhost is determined to be a part of the hostname,
## this script will offer to fix that for you.
if [[ $(hostname -s) = localhost* ]]; then
read -p "[!!!] it seems you are still using localhost, would you like to set the hostname? (y/n) " choice
if [[ "${choice}" -eq "y" ]]; then
read -p " new hostname: " newhostname
# set new hostname
sudo hostnamectl set-hostname ${newhostname}
# reload the shell (to fix the env and PS1 prompt)
source ~/.bashrc
myhost=`hostname`
echo "[hostname] = ${myhost}"
## TODO: reach to adguard-api to add the IP and hostname to homelab-dns
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment