2022-11-11 22:29:26 +01:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
ls_hosts() {
|
|
|
|
# the containers version of grep does not support perl regex so "[^ ]*(?= # Added by hostman)" does not work
|
2022-11-17 15:46:38 +01:00
|
|
|
grep -e "# Added by hostman" /etc/hosts | grep -oe "^[^ ]* [^ ]*" | grep -oe "[^ ]*$"
|
2022-11-11 22:29:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
idle() {
|
|
|
|
echo "Press CTRL C to quit this connection"
|
|
|
|
sleep infinity
|
|
|
|
}
|
|
|
|
|
2022-11-17 13:01:07 +01:00
|
|
|
case "$SSH_ORIGINAL_COMMAND" in
|
|
|
|
"") idle;;
|
|
|
|
ls) ls_hosts;;
|
|
|
|
q|quit) exit 0;;
|
|
|
|
*) exit 1;;
|
|
|
|
esac
|