Last active
February 16, 2017 09:49
-
-
Save dmitriysafronov/204c788cad515234edcf8a202860d388 to your computer and use it in GitHub Desktop.
Костыль для изменения FQDN/hostname
This file contains 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 | |
if [[ -z "$(which wbinfo)" || -z "$(wbinfo -t > /dev/null 2>&1 && echo ok)" ]]; then | |
if [[ -z "$1" ]]; then | |
echo "FQDN/hostname required!" | |
exit 1 | |
fi | |
TMP_FQDN=$1 | |
hostnamectl set-hostname ${TMP_FQDN} | |
if [[ -n "$(echo ${TMP_FQDN} | grep '\.')" ]]; then | |
TMP_FQDN="${TMP_FQDN}\t${TMP_FQDN%%.*}" | |
fi | |
sed "s/^127.0.1.1.*/127.0.1.1\t${TMP_FQDN}/g" -i /etc/hosts | |
else | |
echo "AD member detected. Exiting..." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment