isekai.rocks/cgi/lsuser

29 lines
798 B
Bash
Executable file

#!/bin/sh
all_users="$(ls -1 /home/)"
online_users="$(who | awk '{ print $1 }' | sort | uniq)"
printf "20 text/gemini\r\n"
printf "# Users\r\n"
printf "There are $(echo "${all_users}" | wc -l) total users; "
case "${online_users}" in
*[![:blank:]]*) printf "$(echo "${online_users}" | wc -l) are currently online.\r\n\r\n" ;;
*) printf "0 are currently online.\r\n\r\n" ;;
esac
printf "If you'd like to publish your own gemini content, feel free to ask me for an account. "
printf "You'll need access to SSH as well as an SSH key; there are many guides online that can help.\r\n\r\n"
printf "## Online Users\r\n"
for user in $online_users; do
printf "=> /~${user}/ ${user}\r\n"
done
printf "\r\n"
printf "## All Users\r\n"
for user in $all_users; do
printf "=> /~${user}/ ${user}"
done