19 lines
392 B
Bash
19 lines
392 B
Bash
|
#!/usr/bin/env sh
|
||
|
|
||
|
ls_hosts() {
|
||
|
# the containers version of grep does not support perl regex so "[^ ]*(?= # Added by hostman)" does not work
|
||
|
echo $(grep -e "# Added by hostman" /etc/hosts | grep -oe "^[^ ]* [^ ]*" | grep -oe "[^ ]*$")
|
||
|
}
|
||
|
|
||
|
idle() {
|
||
|
echo "Press CTRL C to quit this connection"
|
||
|
sleep infinity
|
||
|
}
|
||
|
|
||
|
if [ -z $SSH_ORIGINAL_COMMAND ]
|
||
|
then
|
||
|
idle
|
||
|
else
|
||
|
ls_hosts
|
||
|
fi
|