Skip to content

Commit f94ff86

Browse files
committed
2026.7.0beta
1 parent 7464a31 commit f94ff86

3 files changed

Lines changed: 45 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Changed
44
- Fix not parsing cron advanced file
55
- Variant safety nets
6+
- Add subfolder parsing for modules
67

78
## 2026.6.0 2026-06-09 <code at nfrastack dot com>
89

rootfs/container/base/functions/container/available/modules

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Usage:
66
# The `_container_modules_parse` function processes a comma-separated list of modules from an environment variable.
77
# Modules can be added or removed using the following syntax:
8-
# - To add a module: `+module_name` or `+git:<repository_url>#<branch_or_tag>`
8+
# - To add a module: `+module_name` or `+git:<repository_url>#<branch_or_tag>[:<subpath>]`
99
# Example: `+git:https://github.com/user/repo.git#v1.0.0`
1010
# - To remove a module: `-module_name`
1111
#
@@ -15,6 +15,8 @@
1515
# - The repository is cloned into `/container/modules/<repository_name>`.
1616
# - Optionally, a branch or tag can be specified using `#<branch_or_tag>` in the repository URL.
1717
# - Example: `git:https://github.com/user/repo.git#main` (clones the `main` branch).
18+
# - To target a subdirectory within the repository, append `:<subpath>` after the ref.
19+
# - Example: `git:https://github.com/user/modules.git#main:tailscale` (installs from `tailscale/` subdirectory).
1820

1921
if [ -n "${2}" ]; then _container_module_path:-"${2}" ; fi
2022
_container_module_path=${_container_module_path:-"/container/base/modules/"}
@@ -48,13 +50,34 @@ _container_modules_remove() {
4850
_container_modules_install() {
4951
if [[ "${1}" == git:* ]]; then
5052
# Handle Git-based module installation
51-
local repo_url ref module_name
53+
local repo_url ref subpath module_name
5254
repo_url=$(echo "${1}" | sed 's|^git:||' | cut -d'#' -f1) # Extract the repo URL
5355
ref=$(echo "${1}" | grep -o '#.*' | sed 's|#||') # Extract the branch or tag (if specified)
54-
module_name=$(basename "${repo_url}" .git) # Derive module name from repo URL
56+
subpath=""
5557

56-
# Define the target directory for the module
57-
local target_dir="/container/modules/${module_name}"
58+
# Check for optional :<subpath> suffix in the ref portion
59+
if echo "${ref}" | grep -q ':'; then
60+
subpath=$(echo "${ref}" | sed 's|^[^:]*:||')
61+
ref=$(echo "${ref}" | sed 's|:.*||')
62+
fi
63+
64+
# Derive module name from subpath or repo URL
65+
if [ -n "${subpath}" ]; then
66+
module_name=$(basename "${subpath}")
67+
else
68+
module_name=$(basename "${repo_url}" .git)
69+
fi
70+
71+
# Use subpath to derive repo-level directory name
72+
local repo_dir_name
73+
if [ -n "${subpath}" ]; then
74+
repo_dir_name=$(basename "${repo_url}" .git)
75+
else
76+
repo_dir_name="${module_name}"
77+
fi
78+
79+
# Define the target directory for the cloned repository
80+
local target_dir="/container/modules/${repo_dir_name}"
5881

5982
# Clone the repository
6083
if [ -d "${target_dir}" ]; then
@@ -80,9 +103,15 @@ _container_modules_install() {
80103
fi
81104
fi
82105

106+
# Determine where to find the module script
107+
local module_script_path="${target_dir}/module"
108+
if [ -n "${subpath}" ]; then
109+
module_script_path="${target_dir}/${subpath}/module"
110+
fi
111+
83112
# Treat the cloned repository as a local module
84-
if [ -f "${target_dir}/module" ]; then
85-
bash "${target_dir}/module" install
113+
if [ -f "${module_script_path}" ]; then
114+
bash "${module_script_path}" install
86115
case ${?} in
87116
0 )
88117
:

rootfs/container/base/modules/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ IMAGE_MODULES="+git:https://git.repo/user/repo.git#v1.0.0"
4747

4848
This will clone the specified repository into `/container/modules/repo` and check out the specified tag or branch (in this case, `v1.0.0`).
4949

50+
If the repository contains multiple modules in subdirectories, use the `:<subpath>` suffix:
51+
52+
```bash
53+
IMAGE_MODULES="+git:https://git.repo/user/modules.git#main:tailscale"
54+
```
55+
56+
This clones the repository, checks out `main`, and installs the module from the `tailscale/` subdirectory. The same repo can supply multiple modules by repeating the entry with different subpaths.
57+
5058
### Module Configuration
5159

5260
Each module can be configured using environment variables, typically prefixed with the module name (e.g., `APP_` for the 'APP' module).

0 commit comments

Comments
 (0)