#!/bin/bash

# Deploy the Zoho Admin fixer plugin to the Cloudways staging server
# This script will create a ZIP file of the plugin and upload it to the server

# Set variables
SERVER="wordpress-974670-5399585.cloudwaysapps.com"
PLUGIN_DIR="zoho-admin-fixer"
ZIP_FILE="zoho-admin-fixer.zip"
REMOTE_PATH="/home/974670/public_html/wp-content/plugins/"

# Create the plugin directory if it doesn't exist
mkdir -p $PLUGIN_DIR

# Remove any existing ZIP file
rm -f $ZIP_FILE

# Create a ZIP file of the plugin
cd $PLUGIN_DIR
zip -r ../$ZIP_FILE .
cd ..

echo "Created plugin ZIP file: $ZIP_FILE"

# Upload the ZIP file to the server
echo "Uploading ZIP file to server..."
scp $ZIP_FILE $SERVER:$REMOTE_PATH

# SSH into the server to unzip the plugin
echo "Extracting plugin on server..."
ssh $SERVER "cd $REMOTE_PATH && unzip -o $ZIP_FILE && rm $ZIP_FILE"

echo "Plugin deployed successfully!"

# Clean up
rm -f $ZIP_FILE

echo "Deployment completed!"