Shell scripting primer
Automate Nimbus deployment, health checks, and log rotation with portable POSIX shell scripts.
Shebang & portability
Start every script with #!/bin/sh. Avoid bashisms unless you guard them with a version check. Use POSIX parameter expansion, ${var:-default}, and set -eu to catch unset variables and early exits.
Nimbus CLI wrappers
Wrap nimbusctl in a helper function that captures exit codes and stderr. Pipe JSON output through jq for structured license-status checks before restarting the loader service.
Signal traps
Use trap to clean up temp directories and kill child processes on SIGINT or SIGTERM. Always unset the trap inside the handler to prevent recursive invocations.
Logging & rotation
Write timestamped lines to /var/log/nimbus/. Rotate with logrotate or a simple size check inside a cron script. Keep at least seven days of history for audit trails.
Idempotency
Check for existing lock files before acquiring resources. Use atomic mkdir for advisory locking so scripts are safe to run concurrently from cron or systemd timers.
Next: explore the loader integration recipe for a complete end-to-end automation example.