From e85db23b7aed03173d681d390b3df9ddc96ef9a7 Mon Sep 17 00:00:00 2001 From: Konano Date: Thu, 16 Nov 2023 11:19:02 +0800 Subject: [PATCH] add command_exists --- init_priv.sh | 2 ++ utils.sh | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/init_priv.sh b/init_priv.sh index 8cdd22d..3ede419 100755 --- a/init_priv.sh +++ b/init_priv.sh @@ -109,6 +109,8 @@ configure_tmux() { } configure_docker() { + command_exists docker && return + if confirm_action "要安装 docker 吗?" "N"; then # 卸载旧版本 sudo apt remove docker docker-engine docker.io diff --git a/utils.sh b/utils.sh index 68c59c2..fee831a 100755 --- a/utils.sh +++ b/utils.sh @@ -53,6 +53,10 @@ confirm_action() { [[ $response =~ ^[Yy]$ ]] } +command_exists() { + command -v "$@" >/dev/null 2>&1; +} + # ============================================================ check_google_access