Operational Scripts Reference¶
[!info] Script Inventory Total Scripts: 94+ (72 in root directory, 22 in scripts/ subdirectory) Location:
/home/cjustin/homenet-docker-services/Naming Convention:sh-<action>-<target>.sh
Core Operations Scripts¶
Deployment & Startup¶
| Script | Purpose | Usage |
|---|---|---|
docker-start.sh |
Orchestrated startup of all stacks | ./docker-start.sh |
docker-stop.sh |
Graceful shutdown of all services | ./docker-stop.sh |
install.sh |
Master installer for new nodes | ./install.sh |
homenet.sh |
Main CLI wrapper for operations | homenet <command> |
docker-start.sh workflow:
1. Loads .env file
2. Deploys stacks: homenet1 → homenet2 → homenet3 → homenet4 → rxresume → traefik → swarmpit → immich
3. SSHs to 100.1.100.202 to start ARR docker-compose stack
4. Tails Docker logs via sh-tail-docker-logs.sh
Example:
# Start all infrastructure
./docker-start.sh
# Start specific stack
./docker-start.sh s 2 # Deploy only homenet2
Configuration Synchronization¶
| Script | Purpose | Frequency |
|---|---|---|
sh-sync.sh |
Full bidirectional sync (scripts, YML, config, secrets) | Manual |
sh-sync-up.sh |
Pull config from remote nodes | Every 10 min (cron) |
sh-sync-down.sh |
Push config to remote nodes | Every 10 min (cron) |
sh-sync-config.sh |
Config-only sync (excludes Plex, Transmission) | Manual |
sh-sync-scripts.sh |
Scripts and YML files only | Manual |
Sync exclusions (sh-sync-config.sh):
- Plex cache: config/plex/Library/Application Support/Plex Media Server/Cache/
- Transmission settings: config/transmission/settings.json
- Firefox profiles
- _config directories
- .git directories
- .nfs* temporary files
Example:
# Full sync to all nodes
./sh-sync.sh
# Config only
./sh-sync-config.sh
# Scripts only
./sh-sync-scripts.sh
Session Management¶
| Script | Purpose | Usage |
|---|---|---|
sh-session.sh |
Open tmux session to all 5 nodes | ./sh-session.sh |
sh-status.sh |
Service health check across nodes | ./sh-status.sh |
sh-monitor-nodes.sh |
Monitor node health | ./sh-monitor-nodes.sh |
sh-monitor-simple.sh |
Simple monitoring script | ./sh-monitor-simple.sh |
sh-session.sh behavior: - Opens tmux with 5 panes - SSH to each node (201, 202, 203, 204, 205) - Synchronized pane mode available - Perfect for cluster-wide operations
Node Operations¶
| Script | Purpose | Usage |
|---|---|---|
sh-label-nodes.sh |
Apply Docker node labels | ./sh-label-nodes.sh |
sh-update-node.sh |
Update specific node | ./sh-update-node.sh <node> |
sh-update-all-nodes.sh |
Update all 5 nodes | ./sh-update-all-nodes.sh |
sh-label-nodes.sh: - Applies all service placement labels - Must run after swarm initialization - Required for proper service distribution - See [[01-Infrastructure/Cluster-Overview#Node Labels|Cluster Overview]] for label details
Backup & Recovery¶
Database Backups¶
| Script | Purpose | Schedule |
|---|---|---|
sh-backup-databases.sh |
Backup all databases | Daily 2:00 AM |
sh-backup-vaultwarden.sh |
Backup password vault | Daily 2:00 AM |
sh-monitor-backups.sh |
Check backup health | Every 30 min |
sh-backup-databases.sh backs up:
- MariaDB databases
- PostgreSQL databases
- InfluxDB data
- Backup location: /nfs_data/backups/
Example:
# Manual database backup
./sh-backup-databases.sh
# Manual Vaultwarden backup
./sh-backup-vaultwarden.sh
# Check backup status
./sh-monitor-backups.sh
Recovery Scripts¶
| Script | Purpose | Usage |
|---|---|---|
sh-fix-photoprism-mariadb.sh |
Fix PhotoPrism database issues | ./sh-fix-photoprism-mariadb.sh |
Monitoring & Metrics¶
Monitoring Deployment¶
| Script | Purpose | Usage |
|---|---|---|
sh-deploy-monitoring.sh |
Deploy monitoring stack | ./sh-deploy-monitoring.sh |
sh-deploy-proxmox-monitoring.sh |
Deploy Proxmox exporters | ./sh-deploy-proxmox-monitoring.sh |
sh-deploy-omv-monitoring.sh |
Deploy OMV NFS monitoring | ./sh-deploy-omv-monitoring.sh |
sh-deploy-unifi-monitoring.sh |
Deploy UniFi Poller | ./sh-deploy-unifi-monitoring.sh |
sh-verify-monitoring.sh |
Verify monitoring setup | ./sh-verify-monitoring.sh |
sh-check-monitoring.sh |
Check monitoring health | ./sh-check-monitoring.sh |
Network Monitoring¶
| Script | Purpose | Schedule |
|---|---|---|
sh-edgerouter-prometheus-exporter.sh |
Collect EdgeRouter metrics | Every minute (cron) |
sh-edgerouter-network-stats.sh |
EdgeRouter network statistics | Manual |
EdgeRouter exporter:
- Runs every minute via cron
- Collects network interface stats
- Exports to Prometheus format
- Logs to /var/log/edgerouter-exporter.log
Service Monitoring¶
| Script | Purpose | Usage |
|---|---|---|
sh-infrastructure-status.sh |
Complete infrastructure status | ./sh-infrastructure-status.sh |
sh-check-transcode-progress.sh |
Monitor Tdarr transcoding | ./sh-check-transcode-progress.sh |
Storage & Cleanup¶
| Script | Purpose | Schedule |
|---|---|---|
sh-delete-temp.sh |
Clean temporary files | Wed/Sat 5:00 AM |
sh-clean.sh |
General cleanup | Manual |
sh-correct-mounts.sh |
Verify and fix NFS mounts | Manual |
sh-migrate-storage.sh |
Migrate data between storage | Manual |
sh-update-nfs-mounts.sh |
Update NFS mount configuration | Manual |
sh-update-nfs-mounts-v2.sh |
Alternative NFS mount updater | Manual |
sh-delete-temp.sh cleans: - Temporary downloads - Old log files - Docker build cache - Runs automatically twice per week
sh-correct-mounts.sh: - Verifies all NFS mounts - Remounts if necessary - Reports mount status - Run when experiencing storage issues
Password & Security¶
| Script | Purpose | Usage |
|---|---|---|
sh-generate-passwords.sh |
Generate and store service passwords | ./sh-generate-passwords.sh <service> <field> |
sh-populate-vaultwarden.sh |
Populate Vaultwarden vault | ./sh-populate-vaultwarden.sh |
sh-analyze-and-populate-vaultwarden.sh |
Analyze and populate vault | ./sh-analyze-and-populate-vaultwarden.sh |
sh-generate-passwords.sh workflow:
1. Unlocks Bitwarden vault (requires BW_SESSION)
2. Creates folder homenet-<service>
3. Generates 32-character secure passwords
4. Stores in Bitwarden
5. Updates .env file with <SERVICE>_<FIELD>=<password>
6. Creates timestamped .env backup
7. Syncs vault to server
Example:
# Unlock vault
export BW_SESSION=$(bw unlock --raw)
# Generate passwords for Paperless
./sh-generate-passwords.sh paperless DBPASS SECRET_KEY ADMIN_PASSWORD
# Verify .env updated
grep "PAPERLESS_" .env
CRM Management¶
| Script | Purpose | Usage |
|---|---|---|
sh-deploy-crm.sh |
Deploy EspoCRM stack | ./sh-deploy-crm.sh |
sh-manage-crm.sh |
CRM management operations | ./sh-manage-crm.sh |
Network Analysis¶
| Script | Purpose | Usage |
|---|---|---|
sh-analyze-network-bottlenecks.sh |
Identify network bottlenecks | ./sh-analyze-network-bottlenecks.sh |
sh-analyze-wifi-network.sh |
WiFi network analysis | ./sh-analyze-wifi-network.sh |
UniFi Integration¶
| Script | Purpose | Usage |
|---|---|---|
sh-create-unifi-user-api.sh |
Create UniFi API user | ./sh-create-unifi-user-api.sh |
sh-setup-unifi-user.sh |
Setup UniFi user | ./sh-setup-unifi-user.sh |
sh-setup-unifi-with-admin.sh |
Setup UniFi with admin | ./sh-setup-unifi-with-admin.sh |
System Upgrades¶
| Script | Purpose | Usage |
|---|---|---|
sh-prepare-ubuntu22-upgrade.sh |
Prepare for Ubuntu 22.04 upgrade | ./sh-prepare-ubuntu22-upgrade.sh |
sh-prepare-ubuntu24-upgrade.sh |
Prepare for Ubuntu 24.04 upgrade | ./sh-prepare-ubuntu24-upgrade.sh |
sh-upgrade-all-automated.sh |
Automated upgrade all nodes | ./sh-upgrade-all-automated.sh |
sh-upgrade-all-nodes-to-ubuntu22.sh |
Upgrade all to Ubuntu 22.04 | Manual |
sh-upgrade-all-nodes-to-ubuntu24.sh |
Upgrade all to Ubuntu 24.04 | Manual |
sh-validate-ubuntu24-upgrade.sh |
Validate Ubuntu 24.04 upgrade | ./sh-validate-ubuntu24-upgrade.sh |
Proxmox Operations¶
| Script | Purpose | Usage |
|---|---|---|
sh-create-proxmox-snapshots.sh |
Create VM snapshots | ./sh-create-proxmox-snapshots.sh |
sh-migrate-zfs2-proxmox2.sh |
Migrate ZFS to Proxmox 2 | ./sh-migrate-zfs2-proxmox2.sh |
ARR Stack Management¶
| Script | Purpose | Usage |
|---|---|---|
sh-update-arr.sh |
Update ARR services | ./sh-update-arr.sh |
update_and_restart_stack.sh |
Update and restart stack | ./update_and_restart_stack.sh |
Note: ARR stack runs via Docker Compose on node 202. Must SSH to 202 to manage.
AI & Automation¶
| Script | Purpose | Usage |
|---|---|---|
sh-ai-orchestrator.sh |
AI orchestration | ./sh-ai-orchestrator.sh |
sh-ai-router.sh |
AI routing logic | ./sh-ai-router.sh |
Specialized Scripts¶
| Script | Purpose | Usage |
|---|---|---|
sh-setup-craftopia.sh |
Setup Craftopia game server | ./sh-setup-craftopia.sh |
sh-setup-passwordless-sudo.sh |
Configure passwordless sudo | ./sh-setup-passwordless-sudo.sh |
sh-setup-perplexity-key.sh |
Configure Perplexity API key | ./sh-setup-perplexity-key.sh |
sh-setup-edgerouter-ssh.sh |
Setup EdgeRouter SSH | ./sh-setup-edgerouter-ssh.sh |
sh-run-uptime-kuma-setup.py |
Python script for Uptime Kuma | ./sh-run-uptime-kuma-setup.py |
sh-setup-uptime-kuma-monitors.py |
Setup monitoring targets | ./sh-setup-uptime-kuma-monitors.py |
Completion Scripts¶
| Script | Purpose | Usage |
|---|---|---|
homenet-completion.sh |
Bash completion for homenet CLI | source homenet-completion.sh |
Log Management¶
| Script | Purpose | Usage |
|---|---|---|
sh-tail-docker-logs.sh |
Tail all Docker logs | ./sh-tail-docker-logs.sh |
stack-logs.sh |
View stack logs | ./stack-logs.sh <stack> |
Cron Job Schedule¶
From research and crontab analysis:
| Schedule | Script | Log File |
|---|---|---|
*/30 * * * * |
sh-monitor-backups.sh | logs/backup-health-cron.log |
0 2 * * * |
sh-backup-databases.sh | logs/db-backup-cron.log |
0 2 * * * |
sh-backup-vaultwarden.sh | logs/vaultwarden-backup-cron.log |
* * * * * |
sh-edgerouter-prometheus-exporter.sh | /var/log/edgerouter-exporter.log |
0 5 * * 3,6 |
sh-delete-temp.sh | N/A |
5 4,14 * * * |
Palworld server restart | N/A |
Legacy (not currently active):
- */10 * * * * sh-sync-up.sh
- */10 * * * * sh-sync-down.sh
Script Best Practices¶
Running Scripts Safely¶
# Always run from repository root
cd /home/cjustin/homenet-docker-services
# Check script permissions
ls -la sh-*.sh
# Make executable if needed
chmod +x sh-<script>.sh
# Review script before running
cat sh-<script>.sh | less
# Run with error handling
set -e
./sh-<script>.sh
Common Script Patterns¶
Error handling:
#!/bin/bash
set -e # Exit on error
set -u # Exit on undefined variable
set -o pipefail # Exit on pipe failure
Logging:
Environment variables:
Script Dependencies¶
Required Tools¶
Most scripts depend on:
- docker - Container runtime
- docker-compose - Compose CLI (for ARR stack)
- rsync - File synchronization
- ssh - Remote access
- jq - JSON processing
- curl - HTTP requests
- bw - Bitwarden CLI (password scripts)
Installation Check¶
# Verify required tools
which docker docker-compose rsync ssh jq curl bw
# Install missing tools
sudo apt-get update
sudo apt-get install -y rsync jq curl
Creating New Scripts¶
Template¶
#!/bin/bash
#
# Script: sh-<action>-<target>.sh
# Purpose: <Brief description>
# Usage: ./sh-<action>-<target>.sh [args]
#
set -e # Exit on error
# Variables
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_FILE="${SCRIPT_DIR}/logs/$(basename $0 .sh)-$(date +%Y%m%d).log"
# Functions
log() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG_FILE"
}
error() {
echo "[ERROR] $*" >&2 | tee -a "$LOG_FILE"
exit 1
}
# Main logic
main() {
log "Starting $(basename $0)"
# Your code here
log "Completed successfully"
}
# Execute
main "$@"
Naming Convention¶
- Prefix:
sh- - Action:
backup,deploy,monitor,update,setup, etc. - Target:
databases,monitoring,crm, etc. - Extension:
.sh
Examples:
- sh-backup-databases.sh
- sh-deploy-monitoring.sh
- sh-update-all-nodes.sh
Related Documentation¶
- [[Daily-Operations|Daily Operations]]
- [[Stack-Deployment|Stack Deployment]]
- [[Backup-Procedures|Backup Procedures]]
- [[Cron-Jobs|Cron Jobs]]
- [[08-Templates/Quick-Reference-Cards|Quick Reference Cards]]
Last Updated: 2026-01-11 Total Scripts: 94+ Most Used: sh-sync.sh, sh-backup-databases.sh, sh-label-nodes.sh