The task processor is a systemd-service daemon, not a cron job — move it out of the misleadingly-named scripts/crontab/task/ to scripts/task/. To stop the systemd unit from baking the processor's in-tree path (the footprint coupling that forces a reinstall on every reorg), the unit now ExecStarts the stable wrapper: /usr/local/bin/libreportal __task-processor. start.sh intercepts that early (after paths.sh, before the heavy load), exports install_scripts_dir, and exec's the processor with start_script. Future moves/renames need only the one hand-off updated + a regen — no footprint bump. - git mv scripts/crontab/task -> scripts/task (filenames kept; cron-watchdog grep + function names unchanged) - libreportal-svc: ExecStart -> stable wrapper launcher - start.sh: __task-processor internal launcher (export install_scripts_dir; exec) - crontab_task_processor.sh: fix self-location ../.. -> .. for the new 1-level depth (latent bug the move would otherwise have introduced) - regen files_*/function_manifest; add task_scripts to the app/cli aggregates - footprint_version 3 -> 4 (root-owned svc unit changed -> needs a root reinstall) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
48 lines
2.1 KiB
Bash
Executable File
48 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# LibrePortal Task Processor Systemd Service Setup
|
|
# Replaces crontabSetupTaskProcessor with systemd service.
|
|
#
|
|
# Idempotent: computes the desired unit for the CURRENT docker mode and only
|
|
# rewrites + daemon-reloads + restarts when it actually differs from what's on
|
|
# disk. So routine re-runs are no-ops (no needless restart that would kill an
|
|
# in-flight task), while a rooted<->rootless switch — which changes the env
|
|
# block — triggers exactly one rewrite + restart so the processor re-reads the
|
|
# new mode. Safe to call from install AND from the docker-type switcher.
|
|
installLibrePortalWebUITaskService()
|
|
{
|
|
[[ "$CFG_REQUIREMENT_WEBUI_SERVICE" == "true" ]] || return 0
|
|
|
|
local task_processor_script="$install_scripts_dir/task/crontab_task_processor.sh"
|
|
local task_dir="$containers_dir/libreportal/frontend/data/tasks"
|
|
|
|
# Point the processor at the task dir (idempotent). This edits the
|
|
# manager-owned install tree, so no privilege is needed.
|
|
if [ -f "$task_processor_script" ]; then
|
|
sed -i "s|TASK_DIR=\".*\"|TASK_DIR=\"$task_dir\"|g" "$task_processor_script"
|
|
chmod +x "$task_processor_script"
|
|
else
|
|
isNotice "Task processor script not found"
|
|
fi
|
|
|
|
# The unit itself is generated + installed by the root-owned svc helper (it
|
|
# reads the mode + install-user uid from config to build the rootless
|
|
# DOCKER_HOST/XDG_RUNTIME_DIR Environment= lines). Idempotent: only restarts on
|
|
# an actual change, so a rooted<->rootless switch re-reads the new mode without
|
|
# bouncing the processor on routine re-runs.
|
|
local svc_result
|
|
svc_result="$(runSvc install)"
|
|
if [[ "$svc_result" == "updated" ]]; then
|
|
isSuccessful "LibrePortal task processor service installed/updated ($CFG_DOCKER_INSTALL_TYPE)."
|
|
else
|
|
isSuccessful "LibrePortal task processor service already up to date."
|
|
fi
|
|
|
|
# Drop the legacy crontab entry if present (superseded by the service). We are
|
|
# the manager, so operate on its own crontab directly.
|
|
if crontab -l 2>/dev/null | grep -q "task_processor.sh"; then
|
|
crontab -l 2>/dev/null | grep -v "task_processor.sh" | crontab -
|
|
isNotice "Removed task processor from crontab"
|
|
fi
|
|
}
|