rf/rfg.sh
2019-12-12 11:53:40 +13:00

45 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
#!/run/current-system/sw/bin/bash
set -e
./result/bin/site rebuild
if ! [ -d _gopherhole ]; then
mkdir _gopherhole
fi
cd _gopherhole
if ! [ -d .git ]; then
git init
echo "_working/" >> .gitignore
echo ".gitignore" >> .gitignore
git remote add origin "git@git.lain.church:/tA/gopherhole.git"
fi
if [ -d "_working" ]; then
rm -rf "_working"
fi
cp -r "../_input/posts/" "_working"
if test -n "$(find ./ -maxdepth 1 -name '*.txt' -print -quit)"; then
rm *.txt
fi
cd "_working"
for f in ./*.md; do
g=$(basename "$f" .md)
t=$(sed '3q;d' "${f}" | cut -d ' ' -f 2)
n="${t}-${g}.txt"
title=$(sed '2q;d' "${f}" | cut -d ' ' -f2-)
echo "# ${title}" > "../${n}"
tail -n +5 "${f}" >> "../${n}"
done
for f in ../../_input/*.md; do
g=$(basename "$f" .md)
[[ $g =~ ^(ChangeLog|README|index)$ ]] && continue
n="0001-$g.txt"
title=$(sed '2q;d' "${f}" | cut -d ' ' -f2-)
echo "# ${title}" > "../${n}"
tail -n +4 "${f}" >> "../${n}"
done
cd ../
rm -rf _working
git add .
git commit -m "$(date +%s)"
git push -u origin master