forked from tilde.black/ops
32 lines
760 B
Bash
Executable File
32 lines
760 B
Bash
Executable File
#!/bin/sh
|
|
|
|
all_users=$(grep /home < /etc/passwd | awk -F: '{print $1}' | sort)
|
|
current_dir=$(dirname "$(readlink -f "$0")")
|
|
template_dir="${current_dir}/templates/web"
|
|
|
|
if [ -z "$1" ]; then
|
|
output_dir="/var/www/htdocs"
|
|
else
|
|
output_dir="$1"
|
|
fi
|
|
|
|
{
|
|
cat "${template_dir}/head.partial.html"
|
|
|
|
# User pages section
|
|
printf "<section id=\"users\">\\n"
|
|
printf "<h3>User pages</h3>\\n"
|
|
printf "<ul>\\n"
|
|
printf "%s" "$all_users" | while read -r n; do
|
|
if [ -f "/var/www/htdocs/users/${n}/index.html" ]; then
|
|
printf "<li><a href='/users/%s'>~%s</a></li>\\n" "$n" "$n"
|
|
fi
|
|
done
|
|
printf "</ul>\\n"
|
|
printf "</section>\\n"
|
|
|
|
cat "${template_dir}/foot.partial.html"
|
|
} > "$output_dir/index.html"
|
|
|
|
cp -R "${template_dir}/assets/" "${output_dir}"
|