prepare for chezmoi
This commit is contained in:
parent
6d76d9a981
commit
0514f856bc
1 changed files with 0 additions and 28 deletions
|
@ -1,28 +0,0 @@
|
|||
removehost() {
|
||||
hostname="$1"
|
||||
|
||||
if grep -qP "[[:space:]]$hostname" /etc/hosts; then
|
||||
echo "$hostname found in /etc/hosts. Removing now..."
|
||||
sudo sed -ie "/[[:space:]]$hostname/d" /etc/hosts || echo "cannot remove host from /etc/hosts" >&2
|
||||
else
|
||||
echo "$hostname was not found in /etc/hosts" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
addhost() {
|
||||
hostname="$1"
|
||||
|
||||
if grep -qP "[[:space:]]$hostname" /etc/hosts; then
|
||||
echo "$hostname already exists: $(grep "$hostname" /etc/hosts)" >&2
|
||||
else
|
||||
echo "Adding $hostname to /etc/hosts..."
|
||||
printf "%s\t%s\n" "127.0.0.1" "$hostname" | sudo tee -a /etc/hosts > /dev/null || echo "cannot add host to /etc/hosts" >&2
|
||||
|
||||
if grep -q "$hostname" /etc/hosts; then
|
||||
echo "$hostname was added succesfully:"
|
||||
grep "$hostname" /etc/hosts
|
||||
else
|
||||
echo "Failed to add $hostname" >&2
|
||||
fi
|
||||
fi
|
||||
}
|
Loading…
Add table
Reference in a new issue