18 lines
425 B
Bash
Executable file
18 lines
425 B
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
ls_hosts() {
|
|
# the containers version of grep does not support perl regex so "[^ ]*(?= # Added by hostman)" does not work
|
|
grep -e "# Added by hostman" /etc/hosts | grep -oe "^[^ ]* [^ ]*" | grep -oe "[^ ]*$"
|
|
}
|
|
|
|
idle() {
|
|
echo "Press CTRL C to quit this connection"
|
|
sleep infinity
|
|
}
|
|
|
|
case "$SSH_ORIGINAL_COMMAND" in
|
|
"") idle;;
|
|
ls) ls_hosts;;
|
|
q|quit) exit 0;;
|
|
*) exit 1;;
|
|
esac
|