tildeblack-ops/gopherroot.sh

15 lines
550 B
Bash
Raw Permalink Normal View History

2019-08-01 12:04:13 +00:00
#!/bin/sh
all_users=$(grep /home < /etc/passwd | awk -F: '{print $1}')
2019-08-01 12:41:01 +00:00
current_dir=$(dirname "$(readlink -f "$0")")
template_dir="${current_dir}/templates/gopher"
output="${template_dir}/users.gophermap"
2019-08-03 21:06:20 +00:00
printf "i [Users]\\n" > "$output"
2019-08-01 12:04:13 +00:00
printf "%s" "$all_users" | while read -r n; do
if [ -f "/var/gopher/users/${n}/gophermap" ]; then
2019-08-03 21:06:20 +00:00
printf "1 ~%s\\t/users/%s\\n" "$n" "$n" >> "$output"
2019-08-01 12:04:13 +00:00
fi
done
2019-08-01 12:41:01 +00:00
cat "${template_dir}/head.gophermap" "${template_dir}/users.gophermap" > /var/gopher/gophermap