Initial managed-container HA resource agent baseline
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# Sourced by managed-container; uses the shared OCF and parameter environment.
|
||||
|
||||
service_uid()
|
||||
{
|
||||
id -u "${SERVICE_USER}"
|
||||
}
|
||||
|
||||
service_home()
|
||||
{
|
||||
getent passwd "${SERVICE_USER}" | cut -d: -f6
|
||||
}
|
||||
|
||||
as_service_user()
|
||||
{
|
||||
local uid home
|
||||
|
||||
uid="$(id -u "$SERVICE_USER")" || return 1
|
||||
home="$(getent passwd "$SERVICE_USER" | cut -d: -f6)" || return 1
|
||||
|
||||
runuser -u "$SERVICE_USER" -- \
|
||||
sh -c '
|
||||
home="$1"
|
||||
runtime="$2"
|
||||
shift 2
|
||||
|
||||
cd "$home" || exit 1
|
||||
|
||||
export HOME="$home"
|
||||
export XDG_RUNTIME_DIR="$runtime"
|
||||
|
||||
exec "$@"
|
||||
' sh \
|
||||
"$home" \
|
||||
"/run/user/$uid" \
|
||||
"$@"
|
||||
}
|
||||
|
||||
service_running()
|
||||
{
|
||||
mc_lifecycle_running "${SERVICE_NAME}"
|
||||
}
|
||||
|
||||
container_running()
|
||||
{
|
||||
local state
|
||||
|
||||
state="$(
|
||||
mc_runtime_inspect \
|
||||
--format '{{.State.Running}}' \
|
||||
"${CONTAINER_NAME}" 2>/dev/null
|
||||
)" || return 1
|
||||
|
||||
[ "${state}" = "true" ]
|
||||
}
|
||||
Reference in New Issue
Block a user