#!/bin/bash # Atomic install of live /usr/local/bin scripts for the periodic system setup. # # Sourced by setup_periodic_system.sh and periodic_browser.sh. # # Why not `sed ... > /usr/local/bin/x.sh`: that truncates the file in place. # bash reads a script lazily, so a service already running it (the hosts # monitor loops forever) can execute a half-new file. Rendering beside the # target and renaming over it gives the target a NEW inode; a running instance # keeps reading the old one until it exits or is restarted. # Fail-closed: a template that is missing or fails `bash -n` leaves the live # file untouched and returns non-zero. # install_rendered_script