-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
rebuild.sh
executable file
·40 lines (34 loc) · 1.22 KB
/
rebuild.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
WATCHFILE="/tmp/rusty_sword_arena.rebuild"
# For when things go horribly wrong
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
# Cleanup watchfile
rm ${WATCHFILE}
# Pull new source code
git pull || die "Error pulling from GitHub"
# Build the docs
rm -rf target/doc || die "Failed cleaning previous docs"
cargo doc --lib --no-deps || die "Failed generating documentation"
# Build new server binary
cargo build --release --bin server || die "Failed building the server"
# Restart 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