Two shell scripts for CrushFTP management: one automates in-place updates via API, ensuring systems are patched with minimal downtime. The second handles major version upgrades (v10 to v11), migrating all critical settings, user data, and custom branding.
Manually updating and upgrading CrushFTP servers is repetitive and error-prone. In-place updates require logging into admin console. Major version upgrades involve complex migration of settings, users, and customizations. Manual overhead increases risk of misconfiguration across multiple environments.
Leverages CrushFTP API to check for and apply pending updates. Run as cron job for automatic security patching. Logs to /var/log/crushftp_update.log.
[+] crushftp_update.sh
#!/bin/bash
LOG_FILE="/var/log/crushftp_update.log"
CHECK_UPDATE_URL="https://127.0.0.1:443/?command=checkForUpdate"
UPDATE_URL="https://127.0.0.1:443/?command=updateNow"
USERNAME="crushadmin"
PASSWORD="YOUR_SECRET_PASSWORD" # Use vault in production
{
echo "Starting CrushFTP update check..."
echo "Date/Time: $(date)"
RESPONSE=$(curl -k -s -u $USERNAME:$PASSWORD "$CHECK_UPDATE_URL")
RESULT=$(echo "$RESPONSE" | grep -oPm1 "(?<=<response>)[^<]+")
if [ "$RESULT" == "true" ]; then
echo "Update available! Updating..."
UPDATE_RESPONSE=$(curl -k -s -u $USERNAME:$PASSWORD "$UPDATE_URL")
UPDATE_RESULT=$(echo "$UPDATE_RESPONSE" | grep -oPm1 "(?<=<response>)[^<]+")
if [ "$UPDATE_RESULT" == "Success" ]; then
echo "Update successfully completed!"
else
echo "Update process failed!"
fi
else
echo "No updates available."
fi
echo "CrushFTP update check completed."
} 2>&1 | tee -a "$LOG_FILE"
Automates CrushFTP v10 to v11 migration: downloads new version, copies user data, server config (prefs.XML), SSH keys, jobs, and custom logos. Updates system service.
[+] crushftp_v10_to_v11_upgrade.sh
#!/bin/bash # Define the old and new CrushFTP installation paths OLD_CRUSH_PATH="/var/opt/CrushFTP10" NEW_CRUSH_PATH="/var/opt/CrushFTP11" # Download the CrushFTP 11 package echo "Downloading CrushFTP 11..." wget https://www.crushftp.com/early11/CrushFTP11.zip -O "$NEW_CRUSH_PATH.zip" # Unzip the package echo "Unzipping CrushFTP 11 package..." unzip "$NEW_CRUSH_PATH.zip" -d /var/opt # Make the initialization script executable echo "Making initialization script executable..." chmod +x "$NEW_CRUSH_PATH/crushftp_init.sh" # Copy over the necessary files and folders echo "Copying users, prefs, keys, and other critical files..." cp -R "$OLD_CRUSH_PATH/users" "$NEW_CRUSH_PATH/" cp "$OLD_CRUSH_PATH/prefs.XML" "$NEW_CRUSH_PATH/" cp "$OLD_CRUSH_PATH/ssh_host_dsa_key" "$NEW_CRUSH_PATH/" cp "$OLD_CRUSH_PATH/ssh_host_rsa_key" "$NEW_CRUSH_PATH/" cp "$OLD_CRUSH_PATH/ssh_host_dsa_key.pub" "$NEW_CRUSH_PATH/" cp "$OLD_CRUSH_PATH/ssh_host_rsa_key.pub" "$NEW_CRUSH_PATH/" cp -R "$OLD_CRUSH_PATH/TempAccounts" "$NEW_CRUSH_PATH/" cp -R "$OLD_CRUSH_PATH/Previews" "$NEW_CRUSH_PATH/" cp -R "$OLD_CRUSH_PATH/logs" "$NEW_CRUSH_PATH/" cp -R "$OLD_CRUSH_PATH/jobs" "$NEW_CRUSH_PATH/" cp -R "$OLD_CRUSH_PATH/statsDB" "$NEW_CRUSH_PATH/" # Copy custom logo cp "$OLD_CRUSH_PATH/WebInterface/images/logo.png" "$NEW_CRUSH_PATH/WebInterface/images/" # Remove old version daemon launch references echo "Removing old version daemon launch references..." cd "$NEW_CRUSH_PATH" ./crushftp_init.sh uninstall # Install new version daemon launch references echo "Installing new version daemon launch references..." ./crushftp_init.sh install echo "CrushFTP 11 upgrade complete. Verify services are running."
Need to automate your infrastructure? We build robust automation for tedious, critical tasks.
Contact Us