This commit is contained in:
Amos Wenger 2011-11-15 14:06:00 -08:00
commit 608d654277
1 changed files with 25 additions and 0 deletions

25
host-manager Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# Idea and interface taken from https://github.com/macmade/host-manager
path="hosts"
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