rf/rfg.sh

44 lines
1.0 KiB
Bash
Raw Normal View History

2019-03-05 08:04:11 -05:00
#!/run/current-system/sw/bin/bash
set -e
./result/bin/site rebuild
2019-06-11 21:59:42 -04:00
if ! [ -d _gopherhole ]; then
mkdir _gopherhole
2019-03-05 08:04:11 -05:00
fi
2019-06-11 21:59:42 -04:00
cd _gopherhole
2019-03-05 08:04:11 -05:00
if ! [ -d .git ]; then
git init
2019-06-11 21:59:42 -04:00
echo "_working/" >> .gitignore
2019-03-05 08:04:11 -05:00
echo ".gitignore" >> .gitignore
git remote add origin "git@git.lain.church:/tA/gopherhole.git"
fi
2019-06-11 21:59:42 -04:00
if [ -d "_working" ]; then
rm -rf "_working"
2019-03-05 08:04:11 -05:00
fi
2019-06-11 21:59:42 -04:00
cp -r "../_input/posts/" "_working"
2019-03-05 08:04:11 -05:00
if test -n "$(find ./ -maxdepth 1 -name '*.txt' -print -quit)"; then
rm *.txt
fi
2019-06-11 21:59:42 -04:00
cd "_working"
2019-03-05 08:04:11 -05:00
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
2019-06-11 21:59:42 -04:00
for f in ../../_input/*.md; do
2019-03-05 08:04:11 -05:00
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 ../
2019-06-11 21:59:42 -04:00
rm -rf _working
2019-03-05 08:04:11 -05:00
git add .
git commit -m "$(date +%s)"
git push -u origin master