Each app now carries everything under containers/<app>/: Tools-tab actions in tools/ (declaration <app>.tools.json + function <app>_<tool_id>.sh) and logic helpers in scripts/ (e.g. <app>_auth.sh). The container scan live-sources every .sh under the app (maxdepth 3, prunes only resources/) and webui_tools.sh auto-merges the .tools.json, so an app is a true drop-in — no central edit, no array regen. - Empty the central webui_tools.sh heredoc; all 34 tools across 11 apps now come from per-app declarations (verified byte-identical to the old output). - Retire the orphaned mattermost tool scripts to scripts/unused (there is no containers/mattermost; its install fn already lived in unused). - Update the dispatch comment/error path, the auth-adapter doc, and DEVELOPMENT.md to the new convention. - Regenerate static arrays (files_app.sh no longer lists app/containers/*). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
63 lines
2.4 KiB
Bash
63 lines
2.4 KiB
Bash
#!/bin/bash
|
|
|
|
_giteaCmd() {
|
|
runFileOp docker exec -u git gitea-service gitea admin "$@" 2>&1
|
|
}
|
|
|
|
authAdapter_gitea_setPassword() {
|
|
local user="$1" password="$2"
|
|
[[ -z "$user" ]] && { isError "Username is required."; return 1; }
|
|
[[ -z "$password" ]] && password=$(generateRandomPassword)
|
|
|
|
local out
|
|
out=$(_giteaCmd user change-password --username "$user" --password "$password")
|
|
if [[ $? -ne 0 ]]; then isError "Gitea reset failed: $out"; return 1; fi
|
|
|
|
if [[ "$user" == "${CFG_GITEA_ADMIN_USER:-}" ]]; then
|
|
authPersistCfg gitea ADMIN_PASSWORD "$password"
|
|
fi
|
|
isSuccessful "Gitea password set for $user — New password: $password"
|
|
}
|
|
|
|
authAdapter_gitea_createUser() {
|
|
local user="$1" password="$2" email="$3" isAdmin="$4"
|
|
[[ -z "$user" || -z "$email" ]] && { isError "Username and email are required."; return 1; }
|
|
[[ -z "$password" ]] && password=$(generateRandomPassword)
|
|
|
|
local args=(user create --username "$user" --password "$password" --email "$email" --must-change-password=false)
|
|
[[ "$isAdmin" == "true" ]] && args+=(--admin)
|
|
local out
|
|
out=$(_giteaCmd "${args[@]}")
|
|
if [[ $? -ne 0 ]]; then isError "Gitea create failed: $out"; return 1; fi
|
|
|
|
if [[ "$isAdmin" == "true" && -z "${CFG_GITEA_ADMIN_USER:-}" ]]; then
|
|
authPersistCfg gitea ADMIN_USER "$user"
|
|
authPersistCfg gitea ADMIN_PASSWORD "$password"
|
|
fi
|
|
isSuccessful "Gitea user created — User: $user — Email: $email — Password: $password"
|
|
}
|
|
|
|
authAdapter_gitea_listUsers() {
|
|
_giteaCmd user list | awk 'NR>1 && NF>=3 {
|
|
admin = ($5=="true") ? "admin" : "user"
|
|
printf "EZ_USER\t%s\t%s\t%s\n", $3, $2, admin
|
|
}'
|
|
}
|
|
|
|
authAdapter_gitea_deleteUser() {
|
|
local user="$1"
|
|
[[ -z "$user" ]] && { isError "Username is required."; return 1; }
|
|
local out; out=$(_giteaCmd user delete --username "$user")
|
|
[[ $? -ne 0 ]] && { isError "Gitea delete failed: $out"; return 1; }
|
|
isSuccessful "Gitea user '$user' deleted."
|
|
}
|
|
|
|
authAdapter_gitea_setAdmin() {
|
|
local user="$1" isAdmin="$2"
|
|
[[ -z "$user" ]] && { isError "Username is required."; return 1; }
|
|
local args
|
|
if [[ "$isAdmin" == "true" ]]; then args=(--admin); else args=(--admin=false); fi
|
|
local out; out=$(_giteaCmd user change-password --username "$user" "${args[@]}" 2>&1 || _giteaCmd user must-change-password --username "$user" 2>&1)
|
|
isSuccessful "Gitea user '$user' admin → $isAdmin (CLI may need a restart to fully refresh)."
|
|
}
|