From 10effcfa661387f92f1bd264a22920f777475fb0 Mon Sep 17 00:00:00 2001 From: casjay Date: Fri, 26 Jun 2026 13:53:36 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Correct=20init.d=20hook=20functi?= =?UTF-8?q?on=20description=20in=20AI.md=20=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The eleven hook functions are fully generated by the start-service template inside each init.d script — they are not stubs the developer writes. Customisation happens via matching *_local() variants. - AI.md: clarify outer hooks are generated (do not redefine them) - AI.md: document the eight *_local() stubs as the customisation points - AI.md: note __update_conf_files_local() as where sed replacements go - AI.md: explain the builtin type -t guard pattern for local variants AI.md --- AI.md | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/AI.md b/AI.md index a66510a..6c1e27b 100644 --- a/AI.md +++ b/AI.md @@ -561,24 +561,41 @@ DATABASE_SERVICE_TYPE="sqlite" # custom|sqlite|redis|postgres|mariadb|mysql|couc RUNAS_USER="root" ``` -### Required Hook Functions in Every Init.d Script +### Hook Functions in Every Init.d Script -All eleven must be defined (even if they just `return 0`): +The `start-service` template **generates all eleven hook functions** fully implemented inside each init.d script — they are not stubs the developer writes from scratch. The developer customises behaviour via a matching `*_local()` variant that each outer hook calls automatically if defined. + +**Outer hooks** (generated, do not redefine): ```bash __run_precopy() # runs before copying /config to /etc -__execute_prerun() # runs before service starts -__run_pre_execute_checks() # validation before exec; non-zero aborts start -__update_conf_files() # update config files (sed replacements, etc.) +__execute_prerun() # custom prerun — e.g. set up WWW_ROOT_DIR +__run_pre_execute_checks() # validation before exec; non-zero exitStatus aborts start +__update_conf_files() # runs sed replacements on config files __pre_execute() # final setup before exec __post_execute() # background post-start tasks -__pre_message() # message to show before exec +__pre_message() # message shown before exec __update_ssl_conf() # SSL certificate setup __create_service_env() # generates /config/env/$SERVICE_NAME.sh template -__run_start_script() # builds and runs the exec script +__run_start_script() # builds and executes the service start command __run_secure_function() # chmod 600 on credential files ``` +**`*_local()` stubs** (customise these — defined as `{ true; }` by default): + +```bash +__run_precopy_local() +__execute_prerun_local() +__run_pre_execute_checks_local() +__update_conf_files_local() # ← put sed/config replacements here +__pre_execute_local() +__post_execute_local() +__pre_message_local() +__update_ssl_conf_local() +``` + +Each outer hook checks `builtin type -t ___local | grep -q 'function'` before calling the local variant, so stubs that are never overridden cost nothing. + ### PID Sentinel Check (CRITICAL) Every init.d script **must** guard on the correct sentinel file: