43 lines
1023 B
Bash
Executable File
43 lines
1023 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
./result/bin/site rebuild
|
|
if ! [ -d gopherhole ]; then
|
|
mkdir gopherhole
|
|
fi
|
|
cd gopherhole
|
|
if ! [ -d .git ]; then
|
|
git init
|
|
echo "_gopherhole/" >> .gitignore
|
|
echo ".gitignore" >> .gitignore
|
|
git remote add origin "git@git.lain.church:/tA/gopherhole.git"
|
|
fi
|
|
if [ -d "_gopherhole" ]; then
|
|
rm -rf "_gopherhole"
|
|
fi
|
|
cp -r "../posts/" "_gopherhole"
|
|
if test -n "$(find ./ -maxdepth 1 -name '*.txt' -print -quit)"; then
|
|
rm *.txt
|
|
fi
|
|
cd "_gopherhole"
|
|
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 ../../*.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 ../
|
|
git add .
|
|
git commit -m "$(date +%s)"
|
|
git push -u origin master
|