tildelog/lib/make_gophermap.sh

27 lines
782 B
Bash

#!/usr/bin/env bash
declare gophermap
make_gophermap() {
if [ ! -d "${HOME}/public_gopher" ]; then
printf "Creating gopher hole\\n"
mkdir "${HOME}/public_gopher"
fi
if [ ! -L "${HOME}/public_gopher/blog" ]; then
ln -sf "${HOME}/public_html/blog/" "${HOME}/public_gopher/blog"
fi
if [ ! -f "${HOME}/public_gopher/blog/$gophermap" ]; then
cat <<-'EOF' >"${HOME}/public_html/blog/${gophermap}"
#!/usr/bin/env sh
printf "my bashblog posts\n"
user=$(stat -c '%U' .)
for post in $(ls -t *.md); do
post=$(basename $post)
printf "0$post\t/~$user/blog/$post\ttilde.team\t70\n"
done
EOF
chmod +x "${HOME}/public_html/blog/${gophermap}"
fi
chmod 644 ./*.md
}