tildeblack-ops/gopherroot.sh

15 lines
550 B
Bash
Executable File

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