!#bin/bash
BUILD_DIR="/root"
# move sludge.db sqlite file
mv $BUILD_DIR/build/sludge.db $BUILD_DIR/sludge.db

# remove build folder
rm -rf $BUILD_DIR/build/

# remove old build zip
rm -- "$(ls -rt $BUILD_DIR/*.zip | head -n 1)"

# unzip new build zip
unzip *.zip

# move db file back
mv $BUILD_DIR/sludge.db $BUILD_DIR/build/sludge.db

# restart sludge webserver
sudo systemctl restart sludge-info