Skip to content

Instantly share code, notes, and snippets.

@simbalinux
Created January 25, 2018 15:37
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 simbalinux/264f2556e5ba18ff07b9dbf66f577520 to your computer and use it in GitHub Desktop.
Save simbalinux/264f2556e5ba18ff07b9dbf66f577520 to your computer and use it in GitHub Desktop.
ip-hostname
#!/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