📝 Correct init.d hook function description in AI.md 📝

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
This commit is contained in:
2026-06-26 13:53:36 -04:00
parent 514ea1c695
commit 10effcfa66
+24 -7
View File
@@ -561,24 +561,41 @@ DATABASE_SERVICE_TYPE="sqlite" # custom|sqlite|redis|postgres|mariadb|mysql|couc
RUNAS_USER="root" 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 ```bash
__run_precopy() # runs before copying /config to /etc __run_precopy() # runs before copying /config to /etc
__execute_prerun() # runs before service starts __execute_prerun() # custom prerun — e.g. set up WWW_ROOT_DIR
__run_pre_execute_checks() # validation before exec; non-zero aborts start __run_pre_execute_checks() # validation before exec; non-zero exitStatus aborts start
__update_conf_files() # update config files (sed replacements, etc.) __update_conf_files() # runs sed replacements on config files
__pre_execute() # final setup before exec __pre_execute() # final setup before exec
__post_execute() # background post-start tasks __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 __update_ssl_conf() # SSL certificate setup
__create_service_env() # generates /config/env/$SERVICE_NAME.sh template __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 __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 __<name>_local | grep -q 'function'` before calling the local variant, so stubs that are never overridden cost nothing.
### PID Sentinel Check (CRITICAL) ### PID Sentinel Check (CRITICAL)
Every init.d script **must** guard on the correct sentinel file: Every init.d script **must** guard on the correct sentinel file: