1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-28 15:56:33 +00:00
hosts/host-manager

26 lines
496 B
Plaintext
Raw Normal View History

2011-11-15 22:06:00 +00:00
#!/bin/bash
# Idea and interface taken from https://github.com/macmade/host-manager
2011-11-15 22:06:53 +00:00
path="/etc/hosts"
2011-11-15 22:06:00 +00:00
addusage="Usage: `basename $0` -add host address"
remusage="Usage: `basename $0` -remove host"
case "$1" in
-add)
if [ $# -eq 3 ]; then
printf "$3\t$2\n" >> ${path}
else
echo $addusage;
fi
;;
-remove)
if [ $# -eq 2 ]; then
sed -i '' -e "s/^[^#].*[^A-Za-z0-9\.]$2$//g" -e "/^$/ d" ${path}
else
echo $remusage;
fi
;;
*)
echo $addusage;
echo $remusage;
esac