summaryrefslogtreecommitdiff
path: root/bin/extra/setip
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-10-21 00:35:13 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-10-21 00:35:13 +0200
commitc3c4b8c6b4556e01770a75da4b6fbf8e1eba9ce4 (patch)
tree006d8799585d86557e570f03af93b112a079a697 /bin/extra/setip
parent39a6cea6f2f198aa08189d345e0281a591d17ec4 (diff)
parent3d253cd428e2769e0449fbf0c3ece5c0ab41545c (diff)
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/extra/setip')
-rwxr-xr-xbin/extra/setip16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/extra/setip b/bin/extra/setip
new file mode 100755
index 0000000..b10e7cc
--- /dev/null
+++ b/bin/extra/setip
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+ips="192.168.178.79 192.168.178.52 10.7.0.1 none"
+
+for ip in $ips
+do ping -i .2 -c 1 "$ip" > /dev/null 2>&1 && break
+done
+
+if [ "$ip" = "none" ]
+then
+ >&2 printf 'No ip.\n'
+ exit 1
+fi
+
+sed -i "/Host db/,/^$/s/.*HostName.*/\tHostname $ip/" "$HOME"/.ssh/config
+>&2 printf 'Done: %s \n' "$ip"