# names FILE: the account names in FILE, sorted, one per line. names() { tr -s ' ,\t' '\n' <"$1" 2>/dev/null | sed 's/:.*//' | grep -v '^$' | sort -u; } shells() { grep -v -E 'nologin|false|sync$' /etc/passwd | cut -d: -f1 | sort -u; } uids() { awk -F: '$3 >= 1000 { print $1 }' /etc/passwd | sort -u; } # same_set FILE CMD: FILE names the same accounts as CMD prints (sync is # optional, since its shell is /bin/sync). same_set() { [ -s "$1" ] && [ "$(names "$1" | grep -vx sync)" = "$($2 | grep -vx sync)" ]; } # The service: the process listening on 8080. port_pid() { ss -Hltnp 'sport = :8080' | grep -o 'pid=[0-9]*' | head -n1 | cut -d= -f2; } web_up() { local i for i in $(seq 20); do curl -s --max-time 2 http://localhost:8080/ | grep -qi '