From 17e6047590e14d3ff1dc6c01f0b4755d115fc078 Mon Sep 17 00:00:00 2001 From: anuragpeshne Date: Sun, 1 Jan 2023 10:51:09 -0800 Subject: [PATCH] Adds check for docker executable and adds snap to path --- test/ufw-docker.test.sh | 3 +++ ufw-docker | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/ufw-docker.test.sh b/test/ufw-docker.test.sh index 9d5daa7..7a8fa55 100755 --- a/test/ufw-docker.test.sh +++ b/test/ufw-docker.test.sh @@ -15,6 +15,9 @@ source "$working_dir"/bach/bach.sh @mock iptables --version @mocktrue grep -F '(legacy)' + @mocktrue docker -v + @mock docker -v === @stdout Docker version 0.0.0, build dummy + @ignore remove_blank_lines @ignore echo @ignore err diff --git a/ufw-docker b/ufw-docker index 6ea6b7c..cc5a187 100755 --- a/ufw-docker +++ b/ufw-docker @@ -5,7 +5,7 @@ set -euo pipefail LANG=en_US.UTF-8 LANGUAGE=en_US: LC_ALL=en_US.UTF-8 -PATH="/bin:/usr/bin:/sbin:/usr/sbin" +PATH="/bin:/usr/bin:/sbin:/usr/sbin:/snap/bin/" GREP_REGEXP_INSTANCE_NAME="[-_.[:alnum:]]\\+" DEFAULT_PROTO=tcp @@ -424,6 +424,10 @@ if ! ufw status 2>/dev/null | grep -Fq "Status: active" ; then die "UFW is disabled or you are not root user, or mismatched iptables legacy/nf_tables, current $(iptables --version)" fi +if ! docker -v &> /dev/null; then + die "Docker executable not found." +fi + ufw_action="${1:-help}" case "$ufw_action" in