LibrePortal/scripts/docker/checks/running_for_user.sh
librelad 3ecf213cab refactor(de-sudo): docker calls via runFileOp/dockerCommandRun, drop sudo
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>
2026-05-24 16:29:22 +01:00

27 lines
720 B
Bash
Executable File

#!/bin/bash
dockerCheckIsRunningForUser()
{
local type="$1"
# Check if Docker is running for the specified user
if [[ $type == "rootless" ]]; then
local docker_command='docker ps 2>&1'
local result=$(dockerCommandRunInstallUser "$docker_command")
elif [[ $type == "rooted" ]]; then
local docker_command='docker ps 2>&1'
local result=$(eval "$docker_command")
else
echo "Invalid user type specified."
fi
# Check the result
if [[ $result =~ "Cannot connect to the Docker daemon" ]]; then
#echo "Docker is not running for the specified user."
:
else
#echo "Docker is running for the specified user."
:
fi
}