feat: dkprune -r option

This commit is contained in:
AngeD 2023-03-26 12:58:30 +02:00
parent 89d4708de5
commit 924bd4262f

View File

@ -14,6 +14,7 @@ Options:
-I Remove unused images -I Remove unused images
-n Remove unused networks -n Remove unused networks
-a All of the above, equivalent of -CvIn -a All of the above, equivalent of -CvIn
-r Run as root
EOF EOF
exit 0 exit 0
} }
@ -30,11 +31,7 @@ function add_opt() {
echo "$RESULT" echo "$RESULT"
} }
RUNTIME="$(basename "$(command -v podman || command -v docker)")" RUNTIME="$(command -v podman || command -v docker)"
if ! $RUNTIME container ls > /dev/null 2>&1 && [ "$EUID" != 0 ]; then
exec sudo -- "$0" "$@"
fi
c=1 c=1
# C=2 # C=2
@ -45,7 +42,7 @@ n=32
# a="$((c + C + v + I + n))" # a="$((c + C + v + I + n))"
CLEAN=0 CLEAN=0
while getopts hcCviIna o; do while getopts hcCviInar o; do
case "$o" in case "$o" in
h) h)
usage usage
@ -75,6 +72,9 @@ while getopts hcCviIna o; do
CON_OPT='-f' CON_OPT='-f'
IMG_OPT='-a' IMG_OPT='-a'
;; ;;
r)
exec sudo -- "$0" "$(sed 's/r//' <<< "${@:1}")"
;;
*) *)
exit 1 exit 1
;; ;;