From ff5c949f5dc783d55461a23f8bd52e7eab24ddab Mon Sep 17 00:00:00 2001 From: "Lockszmith (@wolfpack)" Date: Sun, 8 Dec 2024 14:46:16 -0500 Subject: [PATCH] =Added dls to runtipictl + some script refactoring --- _bin/runtipictl | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/_bin/runtipictl b/_bin/runtipictl index c7476e3..1d7ab36 100755 --- a/_bin/runtipictl +++ b/_bin/runtipictl @@ -7,13 +7,23 @@ jlmkr () { JAIL_UID=${JAIL_UID:-${UID}} jlmkr-exec () { - local cli="cd ${START_DIR:-/srv/runtipi}; ${1:?Must supply command} "${2:+"$( - printf '\"%s\" ' "${@:2}" - )"} + local set_x=" set -x; pwd; id; " + [ -z "$QUIET" ] || set_x="" + local cli="cd ${START_DIR:-/srv/runtipi};${set_x} ${1:?Must supply command} " + if [ -n "$ROOT_EXEC" ]; then + cli="$cli ${*:2}" + else + cli="$cli "${2:+"$( + printf '\"%s\" ' "${@:2}" + )"} + fi if jlmkr exec runtipi true; then - [ -n "$QUIET" ] || printf 'jlmkr UID:\t%s\ncli:\t\t%s\n' "${JAIL_UID}" "$cli" - jlmkr shell --uid "${JAIL_UID}" runtipi /bin/bash -c "$cli" + if [ -n "$ROOT_EXEC" ]; then + jlmkr exec runtipi /bin/bash <<<"$cli" + else + jlmkr shell --uid "${JAIL_UID}" runtipi /bin/bash -c "$cli" + fi else echo "ERROR: ${_ERROR_MGS:-"Please check if runtipi jail has started! Have you tried 'full-start'?"}" >&2 exit -1 @@ -41,6 +51,17 @@ runtipi-app-docker-compose() { ${LOCAL_YML} ${@:2} } +dls() { + # Default docker ps format is: + # jlmkr-exec docker ps --format "table {{ .ID }}\t{{ .Image }}\t{{ .Command }}\t{{ .Created }}\t{{ .Status }}\t{{ .Ports }}\t{{ .Names }}" + + local base='{{.Status}}\t{{.ID}}\t{{.Names}}\t{{.Image}}' #'\t{{.Networks}}\t{{.Ports}}\t{{.Mounts}}' + local compose='{{.Label "com.docker.compose.project"}}\t{{.Label "com.docker.compose.service"}}' + local format="table $compose\t$base" + ROOT_EXEC=1 jlmkr-exec \ + docker "container ls --all --format '$format' | ( sed -u 1q ; sed -Ee 's|^|555|; s|^555runtipi|000runtipi|;' | sort | sed -Ee 's/^[[:digit:]]{3}//' )" +} + case "${1}" in cli) runtipi-cli "${@:2}" @@ -65,6 +86,9 @@ case "${1}" in docker) jlmkr-exec docker "${@:2}" ;; + dls) + dls "${@:2}" + ;; dcoapp) runtipi-app-docker-compose "${@:2}" ;;