From e97302b57a2dacf05ed931a02def8959caf9a9a2 Mon Sep 17 00:00:00 2001 From: Araputa <6489501892@protonmail.com> Date: Sat, 17 Jan 2026 00:20:02 +0800 Subject: [PATCH] add zypper support for SUSE --- install.sh | 12 ++++++++---- src/init.sh | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 13e2b7b..e59a58c 100644 --- a/install.sh +++ b/install.sh @@ -34,9 +34,9 @@ warn() { # root [[ $EUID != 0 ]] && err "当前非 ${yellow}ROOT用户.${none}" -# yum or apt-get, ubuntu/debian/centos -cmd=$(type -P apt-get || type -P yum) -[[ ! $cmd ]] && err "此脚本仅支持 ${yellow}(Ubuntu or Debian or CentOS)${none}." +# apt-get, yum or zypper, ubuntu/debian/centos/suse +cmd=$(type -P apt-get || type -P yum || type -P zypper) +[[ ! $cmd ]] && err "此脚本仅支持 ${yellow}(Ubuntu or Debian or CentOS or SUSE)${none}." # systemd [[ ! $(type -P systemctl) ]] && { @@ -144,7 +144,11 @@ install_pkg() { $cmd install -y $pkg &>/dev/null if [[ $? != 0 ]]; then [[ $cmd =~ yum ]] && yum install epel-release -y &>/dev/null - $cmd update -y &>/dev/null + if [[ $cmd =~ zypper ]]; then + $cmd --non-interactive refresh &>/dev/null + else + $cmd update -y &>/dev/null + fi $cmd install -y $pkg &>/dev/null [[ $? == 0 ]] && >$is_pkg_ok else diff --git a/src/init.sh b/src/init.sh index b290b1c..5cf0bf4 100644 --- a/src/init.sh +++ b/src/init.sh @@ -58,8 +58,8 @@ _wget() { wget --no-check-certificate "$@" } -# yum or apt-get -cmd=$(type -P apt-get || type -P yum) +# apt-get, yum or zypper +cmd=$(type -P apt-get || type -P yum || type -P zypper) # x64 case $(arch) in