Author: @khoipro, @copilot
- Install ioncube for all PHP versions
- Migrate web application between RunCloud servers
- Fix web applications permission (runcloud chown, file 644 folder 755)
- Disk space cleanup (LiteSpeed cache, swap, journal logs)
- Change SSH port
- Debug WP-CLI issues
- Update Node.js
- Automatic Tweak my.cnf
- Batch update WP Site (using wp-cli)
- WP Security audit installer and WP Security Audit
- Server metrics collector with webhook reporting
- Self-update (auto-pull latest from GitHub)
- OpenLitespeed/Nginx
- Ubuntu 20, 22 or 24 version
Login as root and clone the repo:
cd /root
git clone https://github.com/codetot-web/runcloud-bash-scripts.git
cd runcloud-bash-scripts
chmod +x *.shFull WordPress migration between RunCloud servers. Handles database, config files, uploads, git submodules, and staging URL in one command.
What it does:
- Exports database (wp-cli or mysqldump with corrupted table handling)
- Transfers and imports database on destination
- Syncs wp-config.php, .htaccess, .htninja
- Syncs wp-content/uploads
- Initializes git submodules on destination
- Optionally updates site URL for staging (search-replace)
Prerequisites:
- SSH key auth from source to destination server
- Database and user must already exist on destination (create via RunCloud panel)
- Run as the
runclouduser on the source server
Setup SSH keys (first time only):
./wp-migration.sh runcloud@destination-server.com --setup-sshMigrate a site (same app name on both servers):
./wp-migration.sh runcloud@destination-server.com myappMigrate with a different app name on destination:
./wp-migration.sh runcloud@destination-server.com myapp newappMigrate with staging URL update:
./wp-migration.sh runcloud@destination-server.com myapp --staging-url=http://myapp.example.temp-site.linkCustom SSH port:
./wp-migration.sh runcloud@destination-server.com:2222 myappFull example (typical workflow):
# 1. Setup SSH keys to destination (one-time)
./wp-migration.sh runcloud@sg3.codetot.org --setup-ssh
# 2. Run migration with staging URL
./wp-migration.sh runcloud@sg3.codetot.org myapp --staging-url=http://myapp.staging.temp-site.linkFix file ownership and permissions for RunCloud web applications.
./fix-permission.sh
./fix-permission-site.sh myappInstall ioncube loader for all PHP versions.
./install-ioncube.shInstall and run WordPress security audits.
./wp-security-audit-installer.sh
./wp-security-audit.shFree up disk space by cleaning LiteSpeed caches, swap files, journal logs, and WordPress plugin caches. Shows disk usage before/after.
What it cleans:
wp-content/cache/*— WordPress page cachewp-content/litespeed/cssjs/*— LiteSpeed minified CSS/JSwp-content/wpvivid_image_optimization/*— WPvivid optimization cache/tmp/lsws-rc/swap/*— LiteSpeed swap files (often 5-15G)/home/runcloud/lscaches/*— LiteSpeed external caches- Systemd journal logs (vacuums to 500M)
All cleaned items regenerate automatically — no data loss.
Clean all webapps + system:
./cleanup-disk.shClean a specific webapp + system:
./cleanup-disk.sh --site=myappClean system files only (no webapps):
./cleanup-disk.sh --system-onlyPreview what would be cleaned (no deletions):
./cleanup-disk.sh --dry-runCron job examples (add via RunCloud Dashboard > Cron Job, run as root):
# Daily — clean all webapp caches + system
0 0 * * * /root/runcloud-bash-scripts/cleanup-disk.sh
# Weekly Sunday — system cleanup only
0 0 * * 0 /root/runcloud-bash-scripts/cleanup-disk.sh --system-only
# Daily — specific app only
0 0 * * * /root/runcloud-bash-scripts/cleanup-disk.sh --site=myappAuto-tune MariaDB/MySQL settings based on server RAM and CPU. Optimized for WordPress workloads on RunCloud servers.
What it does:
- Detects server RAM and CPU cores
- Detects config file pattern (sg5:
mariadb.cnfvs sg3:runcloud.cnf) - Calculates optimal settings (~50% RAM for InnoDB buffer pool, scaled instances, IO capacity for SSD, etc.)
- Backs up existing config before any changes
- Applies settings and restarts MariaDB
- Auto-rolls back if MariaDB fails to start
Scaling rules:
| Setting | Formula |
|---|---|
innodb_buffer_pool_size |
~50% of total RAM |
innodb_buffer_pool_instances |
1 per GB of buffer pool (max 8) |
tmp_table_size |
64M (<4G), 96M (4-7G), 128M (8G+) |
innodb_io_capacity |
2000 (assumes SSD) |
max_connections |
300 (not default 4096) |
wait_timeout |
300s (not default 28800s) |
Auto-detect and apply:
./tweak-mycnf.shPreview changes without applying:
./tweak-mycnf.sh --dry-runShow current MariaDB settings:
./tweak-mycnf.sh --statusRestore previous config:
./tweak-mycnf.sh --restoreCollect server metrics (CPU, RAM, disk, load, uptime) and discover all web applications under /home/*/webapps/. Detects WordPress sites and checks for available updates (core, plugins, themes). Sends the JSON payload to any webhook endpoint with optional HMAC-SHA256 signing.
What it collects:
- CPU usage, load averages (1m/5m/15m)
- RAM total/used/percent
- Disk total/used/percent (root partition)
- Uptime in seconds
- Per-webapp: username, app name, disk usage in MB
- WordPress: version, site URL, available core/plugin/theme updates
Print metrics to stdout (no HTTP request):
./server-metrics.sh --printSend to a webhook endpoint:
WEBHOOK_URL=https://example.com/api/webhooks/server-metrics ./server-metrics.shSend with HMAC-SHA256 authentication:
WEBHOOK_URL=https://example.com/api/webhooks/server-metrics \
WEBHOOK_SECRET=your-secret \
./server-metrics.shOverride hostname:
WEBHOOK_URL=https://example.com/webhook \
HOSTNAME_OVERRIDE=my-server-01 \
./server-metrics.shCron job examples (run as root):
# Every 5 minutes — send metrics to webhook
*/5 * * * * WEBHOOK_URL=https://example.com/webhook WEBHOOK_SECRET=your-secret /root/runcloud-bash-scripts/server-metrics.sh >> /var/log/server-metrics.log 2>&1
# Every hour — save metrics locally
0 * * * * /root/runcloud-bash-scripts/server-metrics.sh --print >> /var/log/server-metrics.jsonHMAC-SHA256 Signature:
When WEBHOOK_SECRET is set, the script sends two headers:
X-Webhook-Signature— HMAC-SHA256 of{timestamp}.{payload}X-Webhook-Timestamp— Unix timestamp of the request
Verify on the receiving end with timing-safe comparison (hash_equals in PHP, hmac.compare_digest in Python).
Auto-update the repository by pulling the latest changes from GitHub. Skips if already up to date. Automatically chmod +x all scripts after update.
./self-update.shCron job example (daily at 3:30 AM):
30 3 * * * /root/runcloud-bash-scripts/self-update.sh >> /var/log/runcloud-bash-scripts-update.log 2>&1Change the default SSH port.
./change-ssh-port.sh