Skip to content

Commit

Permalink
add init_host.sh change 127's hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfeng committed Dec 24, 2012
1 parent 3a156cf commit fc33c39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
32 changes: 0 additions & 32 deletions sbin/init_bashrc.sh.bak1217

This file was deleted.

14 changes: 14 additions & 0 deletions sbin/init_hosts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Author : danielfeng
# E-mail : [email protected]

OLOCALHOST=`grep "127.0.0.1" /etc/hosts | awk '{print $2" "$3}'`
NLOCALHOST="localhost.localdomain localhost"
COUNT=`grep -c "127.0.0.1" /etc/hosts`

if [[ ${COUNT} -ge 2 ]] ; then
exit
elif [[ "${OLOCALHOST}" != "${NLOCALHOST}" ]] ; then
sed -i 's/^127/#127/g' /etc/hosts
sed -i '/^#127/a\127.0.0.1 localhost.localdomain localhost' /etc/hosts
fi

0 comments on commit fc33c39

Please sign in to comment.