feat(deploy): install the update trigger units (#15)
shellbook-update.path starts the oneshot shellbook-update.service, which runs the fixed root-owned updater and logs to /var/log/shellbook-update.log.
This commit is contained in:
@@ -37,4 +37,17 @@ tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
|
||||
[[ ! -e $tmp/w/notebooks/infra/lxc.md ]] || { echo 'offer_templates: deleted template came back' >&2; exit 1; }
|
||||
[[ $(sort "$tmp/offered" | tr '\n' ' ') == 'notebooks/a.md notebooks/infra/lxc.md ' ]] || { echo 'offer_templates: wrong list' >&2; exit 1; }
|
||||
)
|
||||
printf '9 install script checks passed\n'
|
||||
# Updates from the web UI: the service only touches a request file; root runs the fixed updater.
|
||||
unit_body() { sed -n "/^cat > \/etc\/systemd\/system\/$1 <<'\{0,1\}EOF'\{0,1\}$/,/^EOF$/p" "$dir/install.sh" | sed '1d;$d'; }
|
||||
update_service=$(unit_body shellbook-update.service)
|
||||
update_path=$(unit_body shellbook-update.path)
|
||||
[[ -n $update_service && -n $update_path ]] || { echo 'install.sh: update units not generated' >&2; exit 1; }
|
||||
grep -qxF 'ExecStart=/usr/local/sbin/shellbook-update' <<< "$update_service" || { echo 'update unit: wrong ExecStart' >&2; exit 1; }
|
||||
grep -qxF 'Type=oneshot' <<< "$update_service" || { echo 'update unit: not oneshot' >&2; exit 1; }
|
||||
[[ $update_service$update_path != */opt/shellbook* ]] || { echo 'update units: reference /opt/shellbook' >&2; exit 1; }
|
||||
# Root writes its output only below root-owned /var/log, never into the service user's data dir.
|
||||
grep -qxF 'StandardOutput=truncate:/var/log/shellbook-update.log' <<< "$update_service" || { echo 'update unit: log not in /var/log' >&2; exit 1; }
|
||||
grep -qxF 'PathChanged=$data_dir/update-request' <<< "$update_path" || { echo 'update path unit: wrong request file' >&2; exit 1; }
|
||||
grep -qxF 'Unit=shellbook-update.service' <<< "$update_path" || { echo 'update path unit: wrong unit' >&2; exit 1; }
|
||||
grep -qxF 'systemctl enable --now shellbook-update.path' "$dir/install.sh" || { echo 'install.sh: update trigger not enabled' >&2; exit 1; }
|
||||
printf '17 install script checks passed\n'
|
||||
|
||||
Reference in New Issue
Block a user