mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-25 06:07:40 +00:00
This commit is contained in:
commit
608d654277
25
host-manager
Normal file
25
host-manager
Normal 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
|
Loading…
Reference in New Issue
Block a user