Container-plane docker now routes through the mode-aware helpers instead of sudo: simple calls (exec/ps/run/build/images/inspect/port/logs across ~15 app/check scripts) -> runFileOp docker (rootless socket as the install user; rooted via the docker group). The cd && docker compose paths drop the sudo on the rooted branch (the rootless branch already used dockerCommandRunInstallUser -- byte-identical now, manager-ready later); gluetun, which had no rootless branch, now uses dockerCommandRun so force-recreate works in both modes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
36 lines
1.1 KiB
Bash
Executable File
36 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
hashPassword()
|
|
{
|
|
local password="$1"
|
|
|
|
# htpasswd first (local, instant). docker fallback pulls a ~50MB image.
|
|
if command -v htpasswd &>/dev/null; then
|
|
local bcrypt_hash
|
|
bcrypt_hash=$(sudo htpasswd -bnBC 10 "" "$password" | tr -d ':\n')
|
|
if [[ -n "$bcrypt_hash" ]]; then
|
|
bcrypt_hash=$(echo "$bcrypt_hash" | awk -F= '{print $NF}')
|
|
local escaped_hash
|
|
escaped_hash=$(echo "$bcrypt_hash" | sed 's/\$/\$\$/g')
|
|
echo "$escaped_hash"
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
if command -v docker &>/dev/null; then
|
|
local bcrypt_hash
|
|
bcrypt_hash=$(runFileOp docker run --rm ghcr.io/wg-easy/wg-easy wgpw "$password" 2>/dev/null | tr -d '\n')
|
|
if [[ -n "$bcrypt_hash" ]]; then
|
|
bcrypt_hash=$(echo "$bcrypt_hash" | awk -F= '{print $NF}')
|
|
local escaped_hash
|
|
escaped_hash=$(echo "$bcrypt_hash" | sed 's/\$/\$\$/g')
|
|
echo "$escaped_hash"
|
|
return 0
|
|
fi
|
|
fi
|
|
|
|
isError "Failed to generate bcrypt hash."
|
|
return 1
|
|
}
|
|
|