Created
January 25, 2018 15:37
-
-
Save simbalinux/264f2556e5ba18ff07b9dbf66f577520 to your computer and use it in GitHub Desktop.
ip-hostname
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 | |
set -x | |
#ip vars | |
ip=$(hostname -I | cut -f2 -d' ') | |
#use this when in private newtwork to avoid network issues. | |
ip2="0.0.0.0" | |
this_host=$(hostname -f) | |
#add hostname > /etc/hosts || exit | |
if [ -n "$(grep "$ip" /etc/hosts)" ]; then | |
echo "HOSTNAME exists in /etc/hosts" | |
else | |
echo -e "$ip\t$this_host" >> /etc/hosts | |
fi | |
#disable selinux | |
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config | |
setenforce 0 | |
getenforce |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment