Added build repo

This commit is contained in:
2022-02-06 23:04:59 +01:00
parent e50130edc1
commit 95aee44f00
3 changed files with 121 additions and 0 deletions

63
build/watch.sh Normal file
View File

@@ -0,0 +1,63 @@
init() {
for dir in frontend backend out; do
if [ ! -d $dir ]; then
mkdir $dir
if [ $dir != "out" ]; then
echo Cloning $dir
git clone https://mhsl.eu/gitea/TheAdversary/$dir.git
fi
fi
done
}
build() {
pwd=$PWD
cd out/backend/
go build .
cp -rf TheAdversary database.sqlite3 ../
if [ ! -f ../../.env ]; then
cp -rf .env ../
else
cp ../../.env ../
fi
cd $pwd
}
start() {
pwd=$PWD
cd out/
./TheAdversary
cd $pwd
}
stop() {
kill $(pidof TheAdversary)
}
process() {
sleep 5
cp -rf frontend/ backend/ out/
build
echo "Restarting"
stop
start &
}
main() {
init
cp -rf frontend/ backend/ out/
build
if [ $? -eq 0 ]; then
start &
fi
while inotifywait -r -e modify frontend/ backend/; do
if [ -d /proc/$! ]; then
kill $!
fi
process &
done
}
main