WATCHFILE="/tmp/rusty_sword_arena.rebuild"
function die {
echo
echo "FATAL: $1"
echo
exit 2
}
function banner {
echo "------------------------------------------------------------------------"
echo "Waiting for new watchfile to appear to indicate it is time to rebuild..."
echo "------------------------------------------------------------------------"
}
banner
while true ; do
if [ -e ${WATCHFILE} ] ; then
rm ${WATCHFILE}
git pull || die "Error pulling from GitHub"
rm -rf target/doc || die "Failed cleaning previous docs"
cargo doc --lib --no-deps || die "Failed generating documentation"
cargo build --release --bin server || die "Failed building the server"
systemctl daemon-reload || die "Failed to reload systemctl daemons"
systemctl restart rusty_sword_arena || die "Failed restarting the server"
echo "Started Rusty Sword Arena server version $(grep ^version Cargo.toml | cut -d '"' -f 2)"
exec ./rebuild.sh
fi
sleep 1;
done