Qualify tenant-scoped bootstrap rotation and fresh Windows scripting

This commit is contained in:
2026-11-17 16:19:08 +01:00
parent 81fcd9c8f8
commit fbd24b6d75
26 changed files with 877 additions and 118 deletions
+10 -3
View File
@@ -117,7 +117,10 @@ def device_get(route, size=None, digest=None):
def device_idle():
# The root worker holds the admission lock before consulting this journal.
with sqlite3.connect(f'file:{STATE}/journal.sqlite?mode=ro', uri=True) as conn:
busy, = conn.execute("SELECT EXISTS(SELECT 1 FROM job_attempts WHERE state IN ('requesting','running','verifying'))").fetchone()
busy, = conn.execute(
"SELECT EXISTS(SELECT 1 FROM job_attempts "
"WHERE state IN ('requesting','running','verifying','unknown','awaiting_reboot'))"
).fetchone()
print('busy' if busy else 'idle')
@@ -248,7 +251,7 @@ def enable():
else:
save(path, data.encode())
service('daemon-reload')
service('enable', '--now', SERVICE, TIMER)
service('enable', '--now', SERVICE)
def enrollment_token(path):
@@ -279,6 +282,7 @@ def install(base, token_file):
save_token(ROOT, token, pwd.getpwnam('rmm-discovery').pw_gid)
enable()
require(healthy(read(ROOT / 'current/manifest.json')['version'], 0), 'awaiting authenticated device heartbeat')
service('enable', '--now', TIMER)
(ROOT / 'first.token').unlink(missing_ok=True)
return
require(not STATE.exists() and not any((UNIT_DIR/name).exists() for name in units()),
@@ -302,7 +306,7 @@ def install(base, token_file):
save(staging / 'config.json', {'bootstrap': base, 'gateway': origin(doc['gateway_origin']),
'tenant': canonical_id(doc['tenant_id'])})
updater = staging / 'updater'
remote((base, token), '/agent/v1/bootstrap/updater?platform=' + PLATFORM, updater, doc['updater'])
remote((base, token), '/agent/v1/bootstrap/updater?platform=' + PLATFORM + '&sha256=' + doc['updater']['sha256'], updater, doc['updater'])
updater.chmod(0o755)
releases = staging / 'releases'
releases.mkdir()
@@ -318,6 +322,9 @@ def install(base, token_file):
os.rename(staging, ROOT)
enable()
require(healthy(manifest['version'], 0), 'installed, awaiting authenticated device heartbeat')
# OnBootSec may already be in the past on a running machine. The first
# timer check can run immediately once the device has reported its platform.
service('enable', '--now', TIMER)
(ROOT / 'first.token').unlink(missing_ok=True)