mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-18 00:17:39 +01:00
- Major updates to README.md and docs/README.md for Pulse v5 - Added technical deep-dives for Pulse Pro (docs/PULSE_PRO.md) and AI Patrol (docs/AI.md) - Updated Prometheus metrics documentation and Helm schema for metrics separation - Refreshed security, installation, and deployment documentation for unified agent models - Cleaned up legacy summary files
1.8 KiB
1.8 KiB
📜 Script Library Guide
This guide explains the shared Bash modules in scripts/lib/ used for building installer scripts.
📂 Structure
| File | Purpose |
|---|---|
common.sh |
Logging, error handling, retry helpers, temp dirs. |
http.sh |
Curl/wget wrappers, GitHub release helpers. |
systemd.sh |
Systemd unit management helpers. |
Conventions:
- Namespaces: Functions are exported as
module::function(e.g.,common::run). - Bundling:
./scripts/bundle.shinlines modules for distribution. - Compatibility: Targets Bash 5 on Debian 11+ and Ubuntu LTS.
🦴 Script Skeleton
#!/usr/bin/env bash
set -euo pipefail
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/lib" && pwd)"
# shellcheck source=../../scripts/lib/common.sh
source "${LIB_DIR}/common.sh"
# shellcheck source=../../scripts/lib/systemd.sh
source "${LIB_DIR}/systemd.sh"
common::init "$@"
common::require_command curl tar
main() {
common::log_info "Starting installer..."
common::temp_dir WORKDIR --prefix pulse-
http::download --url "${URL}" --output "${WORKDIR}/pulse.tar.gz"
systemd::create_service /etc/systemd/system/pulse.service <<'UNIT'
[Unit]
Description=Pulse Monitoring
UNIT
systemd::enable_and_start pulse.service
}
main "$@"
🛠️ Best Practices
- Logging: Use
common::log_info,common::log_warn, etc. They respectPULSE_LOG_LEVEL. - Dry Run: Wrap mutating commands in
common::runto support--dry-run. - Testing: Use
scripts/tests/run.shfor linting andscripts/tests/integration/for scenarios.
📦 Bundling
- Update
scripts/bundle.manifest. - Run
./scripts/bundle.sh. - Verify
dist/artifacts.
Note: Never edit bundled artifacts manually. Always rebuild from source.