Manage Samba Shares

SolidGroundUX DocumentationSolidGroundUX
NL

Manage Samba shares

Source: target-root/usr/local/libexec/solidgroundux/manage-samba-shares.sh

Manage Samba shares

Public functions

Internal functions
FunctionPurposeArgumentsOutput
_dryrun_completeReport the dry-run result without executing the requested host change.——
_refresh_storage_pathsResolve the configured SolidGroundUX share root.——
_smb_ask_selectionKeep selection mechanics local while the manager owns the surrounding UI layout.- --label TEXT—
_share_pathResolve the configured path for a Samba share.——
_share_root_traversableEnsure authenticated share users can traverse the SolidGroundUX share container——
_list_managed_sharesDiscover shares beneath the SolidGroundUX share root.—(globals)
_select_sharesSelect one or more managed shares.—(globals)
_acl_groups_for_shareReturn named group ACL entries for one share.- $1 SHAREWrites GROUP\
_validate_share_nameValidate a managed Samba share name.——
_validate_relative_pathValidate a relative path beneath the share root.- $1 Relative directory path.—
_share_existsTest whether a Samba share exists.- $1: Optional: name of the selected item.—
_share_path_in_useTest whether a backing directory is already used by a managed share.- $1 PATH—
_reload_sambaValidate and reload Samba configuration.——
_resolve_access_group_inputNormalize and validate a persisted/default group without guessing across authentication modes.- $1 User-entered group name; empty means no default access group.—
_apply_group_access_to_groupsShare the ACL/Samba synchronization implementation between interactive access changes- $1 MODE - read or write.—
_create_shareCreate a Samba share and optionally apply a stateful default access group/access level.——
_remove_shareRemove a managed share and optionally its directory.——
_ensure_kerberos_ticketRequire an existing Kerberos TGT before querying Active Directory through LDAP/GSSAPI.——
_discover_ad_groupsQuery Active Directory directly for group names and include groups already—(globals):
_select_groupsAllow one or more Active Directory groups to be selected in a single operation.- $1 OUTPUT_ARRAY_VAR—
_samba_principalFormat an NSS group for a Samba user-list parameter.- $1: Group name.Writes a quoted Samba group principal.
_sync_share_samba_accessSynchronize Samba access lists from POSIX ACLs.- $1 SHARE—
_apply_group_accessApply read or write ACLs to selected shares.- $1 MODE - read or write.—
_select_assigned_groupSelect a group currently assigned to the selected shares.- $1 OUTPUT_VAR—
_remove_group_accessRemove one AD/NSS group's access from selected shares.——
_validate_selectedValidate selected share paths, traversal, ACLs, and Samba configuration.——
_smb_runtime_auth_modeReturn the configured Samba authentication mode.——
_list_local_groups_rawReturn local groups suitable for explicit Samba access management without—Writes one local access-group name per line.
_local_group_displayLabel deliberate standalone access groups consistently in selectors.- $1 Local group name.Writes a display label.
_select_local_groupsSelect one or more local groups.- $1 Output array variable name.—
_pause_return_to_share_managerKeep terminal action results visible.- $1 Optional message.—
_select_access_groupsReturn multiple AD groups in AD mode while retaining single-group selection for- $1 OUTPUT_ARRAY_VAR—
_select_access_groupReuse the authentication-aware access-group selector while enforcing the single- $1 OUTPUT_VAR—
_show_shares_overviewDisplay comprehensive managed-share access information.——
_reconcile_access_groupReconcile share ACL identities after changing Samba authentication mode without guessing mappings.——
_smb_menu_require_selectionRequire at least one Samba share before performing a selection-based action.——
_smb_menu_create_shareOpen the create-share action in the Samba share manager.——
_smb_menu_show_sharesShow the overview of configured Samba shares.——
_smb_menu_reconcileReconcile Samba access groups and return to the share menu.——
_smb_menu_remove_shareOpen the Samba share-removal workflow.——
_smb_menu_select_sharesPrompt for the Samba shares to operate on.——
_smb_menu_grant_readStart the interactive Samba share read-access grant workflow.——
_smb_menu_grant_writeStart the interactive Samba share write-access grant workflow.——
_smb_menu_remove_accessRemove group access from the selected shares and return to the menu.——
_smb_menu_validateRun Samba share configuration checks from the share-management menu.——
_smb_menu_buildRegister and display the Samba share-management menu actions.——

Description

Provides interactive management of SolidGroundUX Samba shares, including share lifecycle, validation, and AD/NSS or standalone group access synchronized through POSIX ACLs and Samba valid-users/write-list settings. Standalone Samba user/group lifecycle is implemented by manage-samba-users.sh; directory lifecycle and directory-level ACL management are implemented by manage-samba-directories.sh.

Design principles

  • Executables are explicit: resolve, bootstrap, then run
  • Libraries never auto-execute (composition over inheritance)
  • Framework integration is opt-in and declarative
  • UI and input must be TTY-safe

Role in framework

  • Entry point pattern for all SolidGroundUX-based scripts
  • Defines how scripts integrate with sgnd-bootstrap and common libraries

Non-goals

  • Business logic implementation (provided by the script author)
  • Library behavior (handled in /common modules)

Usage

Run the executable from its shell command (or installed wrapper):

manage-samba-shares --dryrun
manage-samba-shares --verbose

Script identity

Absolute path to the currently executing script

var: SGND_SCRIPT_FILE

Directory containing the currently executing script

var: SGND_SCRIPT_DIR

Filename of the currently executing script

var: SGND_SCRIPT_BASE

Script basename without the .sh extension

var: SGND_SCRIPT_NAME

Framework integration

Optional framework libraries to source after core bootstrap

var: SGND_USING

Libraries to source from SGND_COMMON_LIB. These are loaded automatically by sgnd_bootstrap AFTER core libraries.

Example: SGND_USING=( net.sh fs.sh )

Leave empty if no extra libs are needed.

Script-specific command-line argument specification

var: SGND_ARGS_SPEC

Optional: script-specific arguments

Example: Arguments

Each entry: "name|short|type|var|help|choices"

name = long option name WITHOUT leading -- short - short option name WITHOUT leading - type = flag | value | enum var = shell variable that will be set help = help string for auto-generated --help output choices = for enum: comma-separated values (e.g. fast,slow,auto) for flag/value: leave empty

Notes:

  • -h / --help is built in, you don't need to define it here.
  • After parsing you can use: FLAG_VERBOSE, VAL_CONFIG, ENUM_MODE, ...

Optional help examples for this script

var: SGND_SCRIPT_EXAMPLES

Optional: examples for --help output. Each entry is a string that will be printed verbatim.

Example: SGND_SCRIPT_EXAMPLES=( "Example usage:" " script.sh --verbose --mode fast" " script.sh -v -m slow" )

Leave empty if no examples are needed.

Script globals participating in configuration loading# var: SGND_SCRIPT_GLOBALS - Script globals participating in configuration loading

var: SGND_SCRIPT_GLOBALS

Explicit declaration of global variables intentionally used by this script.

Purpose

  • Declares which globals are part of the script’s public/config contract.
  • Enables optional configuration loading when non-empty.

Behavior

  • If this array is non-empty, sgnd_bootstrap enables config integration.
  • Variables listed here may be populated from configuration files.
  • Unlisted globals will NOT be auto-populated.

Use this to:

  • Document intentional globals
  • Prevent accidental namespace leakage
  • Make configuration behavior explicit and predictable

Only list:

  • Variables that must be globally accessible
  • Variables that may be defined in config files

Leave empty if:

  • The script does not use configuration-driven globals

Script variables participating in persistent state

var: SGND_STATE_VARIABLES

List of variables participating in persistent state.

Purpose

  • Declares which variables should be saved/restored when state is enabled.

Behavior

  • Only used when sgnd_bootstrap is invoked with --state.
  • Variables listed here are serialized on exit (if SGND_STATE_SAVE=1).
  • On startup, previously saved values are restored before main logic runs.

Contract:

  • Variables must be simple scalars (no arrays/associatives unless explicitly supported).
  • Script remains fully functional when state is disabled.

Leave empty if:

  • The script does not use persistent state.

Script-specific exit handler list

var: SGND_ON_EXIT_HANDLERS

List of functions to be invoked on script termination.

Purpose

  • Allows scripts to register cleanup or finalization hooks.

Behavior

  • Functions listed here are executed during framework exit handling.
  • Execution order follows array order.
  • Handlers run regardless of normal exit or controlled termination.

Contract:

  • Functions must exist before exit occurs.
  • Handlers must not call exit directly.
  • Handlers should be idempotent (safe if executed once).

Typical uses:

  • Cleanup temporary files
  • Persist additional state
  • Release locks

Leave empty if:

  • No custom exit behavior is required.

SGND_STATE_SAVE

var$: SGND_STATE_SAVE

State persistence toggle used by sgnd_bootstrap when state support is enabled.

Scripts that want persistent state must:

  1. set SGND_STATE_SAVE=1
  2. call sgnd_bootstrap --state or --autostate