nsbin/notebook.sh
2021-05-05 10:54:52 +02:00

26 lines
569 B
Bash
Executable file

#!/bin/sh
if [ $# -ge 1 ]; then
cmd="$@"
else
cmd="hostname;uptime"
fi
for notebook in nb1 nb2 nb3 bridge line hike freiheit; do
found=""
printf "Looking for ${notebook} ... "
for place in place7 place10; do
if [ -z "$found" ]; then
fqdn=${notebook}.${place}.ungleich.ch
ping -c2 ${fqdn} >/dev/null 2>&1 && found=$place
fi
done
if [ "$found" ]; then
echo found ${notebook} in ${found}: ${fqdn}
ssh nico@${fqdn} ${cmd}
else
echo "did not reach ${notebook}."
fi
done