Adds a simple .sh script that can trigger a refetch locally from a host if required. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated the Linux script used to trigger Fleet refetch operations. It now runs with stricter Bash safety, validates and trims the system identifier before sending the request, and reports clear success/failure status while returning the appropriate nonzero exit code on errors. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
28 lines
667 B
Bash
28 lines
667 B
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
fleet_url="https://fleet.yourdomain.com"
|
|
identifier_file="/opt/orbit/identifier"
|
|
|
|
if [[ ! -r "$identifier_file" ]]; then
|
|
echo "Missing or unreadable orbit identifier: $identifier_file" >&2
|
|
exit 1
|
|
fi
|
|
|
|
orbit_identifier="$(tr -d '[:space:]' < "$identifier_file")"
|
|
if [[ -z "$orbit_identifier" ]]; then
|
|
echo "Orbit identifier is empty." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Triggering refetch..."
|
|
|
|
if curl -sf --connect-timeout 5 --max-time 20 -X POST \
|
|
"$fleet_url/api/v1/fleet/device/$orbit_identifier/refetch" > /dev/null; then
|
|
echo "Refetch triggered successfully!"
|
|
else
|
|
rc=$?
|
|
echo "Refetch failed!" >&2
|
|
exit "$rc"
|
|
fi
|