+#!/bin/bash
+
+TARGET_HOST="bs-site"
+TARGET_DIR="/var/www/files.bookstackapp.com/vendor"
+
+# Ensure the current working dir is a BookStack install
+if [ ! -f "version" ] || [ ! -f "composer.lock" ]; then
+ echo "Error: Are you in a BookStack install directory? Could not find version or compose.lock files"
+ exit 1
+fi
+
+# Get the version from file and trim whitespace
+VERSION=$(cat version | tr -d '[:space:]')
+if [[ $VERSION != v* ]]; then
+ echo "Error: Found version ($VERSION) does not appear to be valid"
+ exit 1
+fi
+
+echo "Rebuilding vendor directory..."
+rm -rf "vendor"
+composer install --no-dev
+
+echo "Creating ${ZIP_FILENAME}..."
+ZIP_FILENAME="${VERSION}.zip"
+zip -r "${ZIP_FILENAME}" vendor/
+if [ ! -f "${ZIP_FILENAME}" ]; then
+ echo "Error: Failed to create ZIP file"
+ exit 1
+fi
+
+echo "Saving SHA-256 has of ZIP to vendor_hash file..."
+ZIP_SHA=$(sha256sum "${ZIP_FILENAME}" | cut -d ' ' -f 1)
+echo -n "$ZIP_SHA" > vendor_hash
+
+echo "Checking if ZIP already exists on server..."
+if ssh "${TARGET_HOST}" "test -e ${TARGET_DIR}/${ZIP_FILENAME}"; then
+ echo "Error: ZIP file already exists at ${TARGET_DIR}/${ZIP_FILENAME}"
+ exit 1
+fi
+
+echo "Uploading ${ZIP_FILENAME} to server..."
+scp "${ZIP_FILENAME}" "${TARGET_HOST}:${TARGET_DIR}/${ZIP_FILENAME}"
+UPLOAD_RESULT="$?"
+if [ $UPLOAD_RESULT -ne 0 ]; then
+ #statements
+ echo "Error: Upload via scp failed with error code ${UPLOAD_RESULT}"
+ exit 1
+fi
+
+echo "Vendor ZIP creation and update complete!"
+echo "File stored at: https://files.bookstackapp.com/vendor/${ZIP_FILENAME}"
+echo "File sha256: ${ZIP_SHA}"
\ No newline at end of file