diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-10-16 12:09:14 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-10-16 12:09:14 +0200 |
commit | 4ca15dd82c255dfad7e4cf5a347b971f97a0bfed (patch) | |
tree | a848847a680f25f04ab6d3a31bb9e10377d78f6d /bin/extra/setip | |
parent | db8f32037483ade8fc3d8fc2cb2c0e18331e442e (diff) | |
parent | 6c78112e19f44ef79eebf1076041feff83c303e6 (diff) |
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/extra/setip')
-rwxr-xr-x | bin/extra/setip | 16 |
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" |