diff --git a/ChangeMirrors.sh b/ChangeMirrors.sh index 8df38fc..9bd5bc3 100644 --- a/ChangeMirrors.sh +++ b/ChangeMirrors.sh @@ -152,8 +152,7 @@ function PermissionJudgment() { ## 关闭防火墙和SELinux function CloseFirewall() { - systemctl status firewalld | grep running -q - if [ $? -eq 0 ]; then + if [[ $(systemctl is-active firewalld) == "active" ]]; then CHOICE_C=$(echo -e "\n${BOLD}└─ 是否关闭防火墙和 SELinux ? [Y/n] ${PLAIN}") read -p "${CHOICE_C}" INPUT [ -z ${INPUT} ] && INPUT=Y diff --git a/DockerInstallation.sh b/DockerInstallation.sh index 0f24e72..a3748fc 100644 --- a/DockerInstallation.sh +++ b/DockerInstallation.sh @@ -171,8 +171,7 @@ function NetWorkJudgment() { ## 关闭防火墙 function CloseFirewall() { - systemctl status firewalld | grep running -q - if [ $? -eq 0 ]; then + if [[ $(systemctl is-active firewalld) == "active" ]]; then systemctl disable --now firewalld >/dev/null 2>&1 [ -s $SelinuxConfig ] && sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" $SelinuxConfig && setenforce 0 >/dev/null 2>&1 fi @@ -390,8 +389,7 @@ function DockerEngine() { if [[ ${DOCKER_VERSION_INSTALL_LATEST} == "True" ]]; then echo -e "\n$COMPLETE 检测到已安装最新版本的 Docker Engine,跳过安装" ConfigureMirror - systemctl status docker | grep running -q - if [ $? -eq 0 ]; then + if [[ $(systemctl is-active docker) == "active" ]]; then systemctl restart docker fi echo '' @@ -488,15 +486,13 @@ function ShowVersion() { esac exit fi - systemctl status docker | grep running -q - if [ $? -ne 0 ]; then + if [[ $(systemctl is-active docker) == "active" ]]; then sleep 2 systemctl disable --now docker >/dev/null 2>&1 sleep 2 systemctl enable --now docker >/dev/null 2>&1 sleep 2 - systemctl status docker | grep running -q - if [ $? -ne 0 ]; then + if [[ $(systemctl is-active docker) == "active" ]]; then echo -e "\n$ERROR 检测到 Docker 服务启动异常,可能由于重复安装相同版本导致" echo -e "\n请执行 systemctl start docker 或 service docker start 命令尝试启动" echo -e "\n官方安装文档:https://docs.docker.com/engine/install"