Created
June 22, 2021 19:14
-
-
Save bgulla/87488d3956df3ec7f943445652f7e9b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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