]> BookStack Code Mirror - devops/blob - meta-scripts/bookstack-store-vendor
Debian 13 script: Fixed mysql use for mariadb, removed composer use
[devops] / meta-scripts / bookstack-store-vendor
1 #!/bin/bash
2
3 TARGET_HOST="bs-site"
4 TARGET_DIR="/var/www/files.bookstackapp.com/vendor"
5
6 # Ensure the current working dir is a BookStack install
7 if [ ! -f "version" ] || [ ! -f "composer.lock" ]; then
8     echo "Error: Are you in a BookStack install directory? Could not find version or compose.lock files"
9     exit 1
10 fi
11
12 # Get the version from file and trim whitespace
13 VERSION=$(cat version | tr -d '[:space:]')
14 if [[ $VERSION != v* ]]; then
15     echo "Error: Found version ($VERSION) does not appear to be valid"
16     exit 1
17 fi
18
19 echo "Rebuilding vendor directory..."
20 rm -rf "vendor"
21 composer install --no-dev
22
23 echo "Creating ${ZIP_FILENAME}..."
24 ZIP_FILENAME="${VERSION}.zip"
25 zip -r "${ZIP_FILENAME}" vendor/
26 if [ ! -f "${ZIP_FILENAME}" ]; then
27     echo "Error: Failed to create ZIP file"
28     exit 1
29 fi
30
31 echo "Checking if ZIP already exists on server..."
32 if ssh "${TARGET_HOST}" "test -e ${TARGET_DIR}/${ZIP_FILENAME}"; then
33     echo "Error: ZIP file already exists at ${TARGET_DIR}/${ZIP_FILENAME}"
34     exit 1
35 fi
36
37 echo "Saving SHA-256 checksum of ZIP to dev/checksums/vendor file..."
38 ZIP_SHA=$(sha256sum "${ZIP_FILENAME}" | cut -d ' ' -f 1)
39 echo -n "$ZIP_SHA" > dev/checksums/vendor
40
41 echo "Uploading ${ZIP_FILENAME} to server..."
42 scp "${ZIP_FILENAME}" "${TARGET_HOST}:${TARGET_DIR}/${ZIP_FILENAME}"
43 UPLOAD_RESULT="$?"
44 if [ $UPLOAD_RESULT -ne 0 ]; then
45     #statements
46     echo "Error: Upload via scp failed with error code ${UPLOAD_RESULT}"
47     exit 1
48 fi
49
50 echo "Vendor ZIP creation and update complete!"
51 echo "File stored at: https://files.bookstackapp.com/vendor/${ZIP_FILENAME}"
52 echo "File sha256: ${ZIP_SHA}"
Morty Proxy This is a proxified and sanitized view of the page, visit original site.