Closed ym2011 closed 2 years ago
因为在centos 重复执行脚本的时候,老是提示: silversearcher-ag没有安装,其实已经安装了,是the_silver_searcher,centos 仅需:yum install -y the_silver_searcher 同样,在Debian 重复执行的时候,老是提示:the_silver_searcher 没有安装,其实已经安装了,是silversearcher-ag,Debian仅需:apt install -y silversearcher-ag
所以简单调整了一下代码
cmdline=( "net-tools" "telnet" "nc" "lrzsz" "wget" "strace" "htop" "tar" "lsof" "tcpdump" "rkhunter" ) for prog in "${cmdline[@]}"; do
if [ $OS = 'Centos' ]; then soft=$(rpm -q "$prog") if echo "$soft" | grep -E '没有安装|未安装|not installed' >/dev/null 2>&1; then echo -e "$prog 安装中......" yum install -y "$prog" >/dev/null 2>&1 yum install -y the_silver_searcher >/dev/null 2>&1 fi else if dpkg -L $prog | grep 'does not contain any files' >/dev/null 2>&1; then echo -e "$prog 安装中......" apt install -y "$prog" >/dev/null 2>&1 apt install -y silversearcher-ag >/dev/null 2>&1 fi
fi done
因为在centos 重复执行脚本的时候,老是提示: silversearcher-ag没有安装,其实已经安装了,是the_silver_searcher,centos 仅需:yum install -y the_silver_searcher 同样,在Debian 重复执行的时候,老是提示:the_silver_searcher 没有安装,其实已经安装了,是silversearcher-ag,Debian仅需:apt install -y silversearcher-ag
所以简单调整了一下代码
安装应急必备工具
cmdline=( "net-tools" "telnet" "nc" "lrzsz" "wget" "strace" "htop" "tar" "lsof" "tcpdump" "rkhunter" ) for prog in "${cmdline[@]}"; do
if [ $OS = 'Centos' ]; then soft=$(rpm -q "$prog") if echo "$soft" | grep -E '没有安装|未安装|not installed' >/dev/null 2>&1; then echo -e "$prog 安装中......" yum install -y "$prog" >/dev/null 2>&1 yum install -y the_silver_searcher >/dev/null 2>&1 fi else if dpkg -L $prog | grep 'does not contain any files' >/dev/null 2>&1; then echo -e "$prog 安装中......" apt install -y "$prog" >/dev/null 2>&1 apt install -y silversearcher-ag >/dev/null 2>&1 fi
fi done