Files
sludge-link/deploy.sh
T

23 lines
625 B
Bash
Executable File

#!/bin/bash
BUILD_DIR="/root"
# find newest zip file and extract version
NEWEST_ZIP="$(find "$BUILD_DIR" -maxdepth 1 -name "*.zip" -type f -printf '%T@ %p\n' | sort -rn | head -n 1 | cut -d' ' -f2)"
VERSION="$(basename -s .zip "$NEWEST_ZIP" | cut -d' ' -f2)"
# move sludge.db sqlite file with versioned backup name
cp "$BUILD_DIR/build/sludge.db" "$BUILD_DIR/sludge.db.$VERSION"
# remove build folder
rm -rf "$BUILD_DIR/build/"
# unzip newest zip file
unzip "$NEWEST_ZIP"
# move db file back
cp "$BUILD_DIR/sludge.db.$VERSION" "$BUILD_DIR/build/sludge.db"
# restart sludge webserver
sudo systemctl restart sludge-info