Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## core
- initialize
- [initialize_env](./initialize_env.md) — Detect and expose common environment variables for other config-v2 modules
- [list_options](./list_options.md) — Show available option groups and their usage for configng-v2 modules.
- [trace](./trace.md) — Lightweight timing and trace message utility for Configng V2 modules.
- [submenu](./submenu.md) — Parse a list_options message and present commands as an interactive menu.
Expand All @@ -23,6 +24,9 @@
## software
- management
- [cockpit](./cockpit.md) — Web-based administrative interface for managing Linux servers.
- [webmin](./webmin.md) — Webmin setup and service control.
- mediaserver
- [plexmediaserver](./plexmediaserver.md) — SDK/development tool to install, remove, or check the status of Plex Media Server via the official repository. Not intended for production use unless otherwise secured and configured.

## system
- kernel
Expand Down
22 changes: 22 additions & 0 deletions docs/initialize_env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# initialize_env
Detect and expose common environment variables for other config-v2 modules

## About
Provides helpers to detect system and project paths (BIN_ROOT, LIB_ROOT, WEB_ROOT, etc.), OS/release metadata (sourced from /etc/os-release and /etc/armbian-release), and runtime info (kernel, default network adapter, local IP/subnet). Intended to be sourced by callers; includes helpers to print or emit export lines suitable for eval. Keep side effects opt-in (INITIALIZE_AUTO) to avoid surprising behavior on source.

## Usage
~~~bash
Usage: initialize_env [help|-h|--help]

About:
The 'initialize_env' module provides environment detection utilities.

Commands:
help - Show this help message.

Notes:
- To set variables in the current shell: source this file and call _initialize_env_vars
- When executed, this file's test entrypoint verifies the environment and prints variables.
~~~

- Autogenerated from `./src/core/initialize/initialize_env.conf` and `./src/core/initialize/initialize_env.sh`
106 changes: 0 additions & 106 deletions docs/modules_metadata.json

This file was deleted.

33 changes: 33 additions & 0 deletions docs/plexmediaserver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# plexmediaserver
SDK/development tool to install, remove, or check the status of Plex Media Server via the official repository. Not intended for production use unless otherwise secured and configured.

## About
This module enables quick setup, removal, and status checks for Plex Media Server on Armbian-based systems as part of SDK or workflow automation. It manages the official repository, GPG keys, and installation process. The module is best suited for development, testing, or controlled environments. Production usage is not recommended unless you have reviewed security and configuration.

## Usage
~~~bash
Usage: plexmediaserver <command> [options]

Commands:
install Install the Plex Media Server.
remove Remove the Plex Media Server.
status Check if the Plex Media Server is installed.
help Show this help message.

Examples:

plexmediaserver install
plexmediaserver remove
plexmediaserver status
plexmediaserver help

Notes:
- This script is intended for use with Armbian Config V2.
- It installs the Plex Media Server from the official repository.
- The server will be available on port 32400 by default.
- Ensure that you have the necessary permissions to run this script.
- Use 'sudo' if required to execute commands that need elevated privileges.
- Keep this help message up to date if commands change.
~~~

- Autogenerated from `./src/software/management/plexmediaserver.conf` and `./src/software/management/plexmediaserver.sh`
42 changes: 42 additions & 0 deletions docs/webmin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# webmin
Webmin setup and service control.

## About
Provides installation removal service management and status checks for the Webmin web-based system administration tool. Supports enabling/disabling on boot and verifying service state.

## Usage
~~~bash
Usage: webmin <command>

Commands:
help - Show this help message
install - Install Webmin
remove - Remove Webmin
start - Start the Webmin service
stop - Stop the Webmin service
enable - Enable Webmin to start on boot
disable - Disable Webmin from starting on boot
status - Show the status of the Webmin service
check - Perform a basic check of Webmin

Examples:
# Install Webmin
webmin install

# Start Webmin
webmin start

# Check Webmin status
webmin status

Notes:
- Maintainer: @Tearran
- Author: @Tearran
- Status: Active
- Documentation: https://webmin.com/docs/
- Port: 10000
- Supported Architectures: x86-64 arm64 armhf
- Group: Management
~~~

- Autogenerated from `./src/software/management/webmin.conf` and `./src/software/management/webmin.sh`
47 changes: 47 additions & 0 deletions staging/promote_staged_module.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# promote_staged_module - Configng V2 metadata

[promote_staged_module]
# Main feature provided by this module (usually the same as the module name).
feature=promote_staged_module

# Short, single-line summary describing what this module does.
description=

# Longer description with more details about the module's features or usage.
extend_desc=

# Comma-separated list of commands supported by this module (e.g., help,status,reload).
options=

# Main category this module belongs to. Must be one of: network, system, software, locales.
parent=

# Group or tag for this module. See docs/readme.md (group index) for options.
# If none fit, suggest a new group in your pull request.
group=

# Contributor's GitHub username (use @username).
contributor=

# Comma-separated list of supported CPU architectures.
arch=

# Comma-separated list of supported operating systems.
require_os=

# What kernel are you using? (minimum required version, e.g., 5.15+)
require_kernel=

# Comma-separated list of network ports used by this module (e.g., 8080,8443). Use 'false' if not applicable.
port=false

# Comma-separated list of functions in this module (all functions except the main feature).
# NOTE: You must include the help message function _about_promote_staged_module; validation will fail if it is missing.
helpers=

# List each command and its description below.
# Example:
# show=Display the current configuration
[options]
help=Show help for this module

113 changes: 113 additions & 0 deletions staging/promote_staged_module.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/env bash
set -euo pipefail

# ./promote_staged_module.sh - Armbian Config V2 module

promote_staged_module() {
case "${1:-}" in
help|-h|--help)
_about_promote_staged_module
;;
*)
_promote_staged_module_main
;;
esac
}

_promote_staged_module_main() {
for sh_file in ./staging/*.sh; do
[[ -f "$sh_file" ]] || continue
base_name="$(basename "$sh_file" .sh)"
conf_file="./staging/${base_name}.conf"
if [[ -f "$conf_file" ]]; then
parent="$(grep '^parent=' "$conf_file" | head -n1 | cut -d= -f2- | xargs)"
group="$(grep '^group=' "$conf_file" | head -n1 | cut -d= -f2- | xargs)"

if [[ -z "$parent" ]]; then
echo "No parent= in $conf_file, skipping $sh_file"
continue
fi

if [[ -n "$group" ]]; then
dest_dir="./src/$parent/$group"
else
dest_dir="./src/$parent"
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate required conf fields before moving; fail fast on unknown parent path.

Per earlier workflow preferences, promotion should only occur for well-formed configs and known destinations to prevent silent tree pollution (e.g., typos creating new directories).

-			parent="$(grep '^parent=' "$conf_file" | head -n1 | cut -d= -f2- | xargs)"
-			group="$(grep '^group=' "$conf_file" | head -n1 | cut -d= -f2- | xargs)"
+			parent="$(grep -Em1 '^parent=' "$conf_file" | cut -d= -f2- | xargs)"
+			group="$(grep -Em1 '^group=' "$conf_file" | cut -d= -f2- | xargs)"
+			# quick presence/format checks (feature/helpers/description/parent at minimum)
+			if ! grep -Eqm1 '^feature=' "$conf_file" \
+			 || ! grep -Eqm1 '^helpers=' "$conf_file" \
+			 || ! grep -Eqm1 '^description=' "$conf_file" \
+			 || ! grep -Eqm1 '^parent=' "$conf_file"; then
+				echo "ERROR: $conf_file missing one or more required fields (feature/helpers/description/parent). Aborting."
+				exit 1
+			fi-			if [[ -n "$group" ]]; then
-				dest_dir="./src/$parent/$group"
-			else
-				dest_dir="./src/$parent"
-			fi
-			mkdir -p "$dest_dir"
+			if [[ -n "$group" ]]; then
+				dest_dir="./src/$parent/$group"
+			else
+				dest_dir="./src/$parent"
+			fi
+			# Fail if parent path does not pre-exist (typo guard)
+			if [[ ! -d "./src/$parent" ]]; then
+				echo "ERROR: Destination './src/$parent' does not exist. Check 'parent=' in $conf_file."
+				exit 1
+			fi
+			mkdir -p "$dest_dir"

If you prefer, we can invoke the validator first and abort on any failures:

validate_staged_modules || { echo "Validation failed; aborting promotion."; exit 1; }

Say the word and I’ll wire this into the main path.

🤖 Prompt for AI Agents
In staging/promote_staged_module.sh around lines 23 to 35, the script currently
reads parent and group from the .conf and constructs a destination path but does
not validate the config fields or ensure the destination exists, allowing typos
to create new directories; update the logic to (1) validate required fields (at
minimum ensure parent is present and matches an expected pattern or list) and
abort immediately on failure, and (2) verify the computed dest_dir exists under
./src (or call an existing validate_staged_modules function and abort if it
fails) before moving files so promotion fails fast instead of silently creating
new tree entries.

mkdir -p "$dest_dir"

echo "Moving $sh_file and $conf_file to $dest_dir/"
mv "$sh_file" "$dest_dir/"
mv "$conf_file" "$dest_dir/"

# Move any matching image files to the module destination directory
for ext in png jpg jpeg gif svg; do
img_file="./staging/${base_name}.${ext}"
if [[ -f "$img_file" ]]; then
echo "Moving image: $img_file to $dest_dir/"
mv "$img_file" "$dest_dir/"
fi
done
Comment on lines +54 to +65
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Protect against overwriting existing files.

mv will overwrite silently. Safer: bail if a target already exists to avoid accidental clobbering.

-			echo "Moving $sh_file and $conf_file to $dest_dir/"
-			mv "$sh_file" "$dest_dir/"
-			mv "$conf_file" "$dest_dir/"
+			for f in "$sh_file" "$conf_file"; do
+				t="$dest_dir/$(basename "$f")"
+				if [[ -e "$t" ]]; then
+					echo "ERROR: Destination already contains $(basename "$f") at $dest_dir/. Aborting to prevent overwrite."
+					exit 1
+				fi
+			done
+			echo "Moving $sh_file and $conf_file to $dest_dir/"
+			mv "$sh_file" "$dest_dir/"
+			mv "$conf_file" "$dest_dir/"
🤖 Prompt for AI Agents
In staging/promote_staged_module.sh around lines 38 to 49, mv is used and will
silently overwrite existing files; update the script to protect against
clobbering by checking for the existence of each destination file before moving
(for the .sh, .conf and each image extension), and if any target already exists
print an error and exit non-zero. Perform the existence check using a
conditional like [[ -e "$dest_dir/$filename" ]] prior to calling mv, so no moves
occur if a conflict is detected, and keep the quoting of paths when moving and
when reporting the error.

else
echo "ERROR: No .conf file for $sh_file, cannot promote."
exit 1
fi
done

# Check for orphans
if [[ -d "./staging" ]]; then
if [[ -z "$(ls -A ./staging)" ]]; then
echo "Removing empty ./staging directory."
rmdir ./staging
else
echo "ERROR: Orphaned files left in ./staging after promotion!"
ls -l ./staging
exit 1
fi
fi
}

_about_promote_staged_module() {
cat <<EOF
Usage: promote_staged_module <command> [options]

Commands:
test - Run a basic test of the promote_staged_module module
foo - Example 'foo' operation (replace with real command)
bar - Example 'bar' operation (replace with real command)
help - Show this help message

Examples:
# Run the test operation
promote_staged_module test

# Perform the foo operation with an argument
promote_staged_module foo arg1

# Show help
promote_staged_module help

Notes:
- Replace 'foo' and 'bar' with real commands for your module.
- All commands should accept '--help', '-h', or 'help' for details, if implemented.
- Intended for use with the config-v2 menu and scripting.
- Keep this help message up to date if commands change.

EOF
}

### START ./promote_staged_module.sh - Armbian Config V2 test entrypoint

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
# --- Capture and assert help output ---
help_output="$(promote_staged_module help)"
echo "$help_output" | grep -q "Usage: promote_staged_module" || {
echo "fail: Help output does not contain expected usage string"
echo "test complete"
exit 1
}
# --- end assertion ---
promote_staged_module "$@"
fi

### END ./promote_staged_module.sh - Armbian Config V2 test entrypoint

2 changes: 1 addition & 1 deletion staging/setup_scafolding.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ feature=setup_scafolding
description=Generate scaffolding files for new Configng V2 modules

# Longer description with more details about the module's features or usage.
extend_desc=Creates starter `.conf` and `.sh` files for new Configng V2 modules.
extend_desc=Creates starter .conf and .sh files for new Configng V2 modules.
Validates the provided module name, ensures the staging directory exists,
and writes template files to it. Intended to standardize the structure of
new modules and speed up development.
Expand Down
Loading