denyhosts/build.sh

114 lines
3.7 KiB
Bash
Raw Permalink Normal View History

2022-11-19 19:30:56 +08:00
:
check_os()
{
if cat /etc/issue | grep -i 'ubuntu' >> /dev/null 2>&1 ; then
OS=ubuntu
OS_VER=$(cat /etc/issue | head -n1 | awk '{print$2}')
echo -e SYSTEM: UBUNTU $(uname -m) ${OS_VER}\\nKERNEL: $(uname -sr)
elif test -f /etc/debian_version ; then
OS=debian
OS_VER=$(cat /etc/debian_version)
echo -e SYSTEM: DEBIAN $(uname -m) ${OS_VER}\\nKERNEL: $(uname -sr)
elif test -f /etc/centos-release ; then
OS=centos
OS_VER=$(cat /etc/centos-release | grep -o -E '[0-9.]{3,}') 2>> /dev/null
echo -e SYSTEM: CENTOS $(uname -m) ${OS_VER}\\nKERNEL: $(uname -sr)
else
echo The system does not support
exit 3
fi
}
pkg_install()
{
if test "$OS" = "ubuntu" -o "$OS" = "debian"; then
apt -y install build-essential
apt -y install make
apt -y install tmux
apt -y install libclamav-dev libip4tc-dev libcurl4-openssl-dev #(或者libcurl4-gnutls-dev)
apt -y install libsystemd-dev libjson-c-dev libpcre2-dev clamav-freshclam
apt -y install libltdl-dev
# Debian系统使用libiptc库需要nftables切换到iptables
# Switching to the legacy version:(切换到 iptables)
2022-11-19 19:30:56 +08:00
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
update-alternatives --set arptables /usr/sbin/arptables-legacy
update-alternatives --set ebtables /usr/sbin/ebtables-legacy
freshclam # 更新病毒库(必要)
else
yum -y groupinstall "Development Tools"
yum -y install make
yum -y install tmux
yum -y install bzip2-devel
yum -y install libxslt-devel libxml2-devel
2022-11-19 19:30:56 +08:00
yum -y install clamav clamav-update clamav-lib clamav-devel json-c-devel pcre2-devel
yum -y install iptables-devel libcurl-devel
yum -y install systemd-devel libtool-ltdl-devel
yum -y install centos-release-scl
yum -y install devtoolset-11-gcc
#source /opt/rh/devtoolset-11/enable #临时
if test "`grep "devtoolset" /etc/profile`" = ""; then
echo "source /opt/rh/devtoolset-11/enable" >> /etc/profile #永久
fi
source /opt/rh/devtoolset-11/enable
2022-11-19 19:30:56 +08:00
freshclam # 更新病毒库(必要)
fi
}
main()
{
#cd clamscan/libclamav
#bash build.sh
#cd ../..
2022-11-19 19:30:56 +08:00
make clean; make
if test "$OS" = "centos"; then
if test -f /etc/cron.d/clamav-update; then # 去除自动更新病毒库
mv /etc/cron.d/clamav-update /root
fi
if test -f /etc/freshclam.conf; then # 更改病毒库镜像
sed -i "s/DatabaseMirror .*/DatabaseMirror clamavdb.c3sl.ufpr.br/g" /etc/freshclam.conf
fi
2022-11-19 19:30:56 +08:00
fi
if test -f /etc/clamav/freshclam.conf; then
sed -i "s/DatabaseMirror .*/DatabaseMirror clamavdb.c3sl.ufpr.br/g" /etc/clamav/freshclam.conf
else
:
2022-11-19 19:30:56 +08:00
fi
if test "$OS" = "debian"; then
condition=$(awk -v num1=${OS_VER} -v num2=11 'BEGIN{print(num1>num2)?"0":"1"}')
if test "$condition" = "1"; then # Debian系统版本小于11时, libclamav库版本低时
cd clamscan/libclamav/; bash build.sh
cp /usr/lib/x86_64-linux-gnu/libclamav.so.9.0.5 /usr/lib/x86_64-linux-gnu/libclamav.so.9.0.5.backup
cp .libs/libclamav.so.9.0.5 /usr/lib/x86_64-linux-gnu/
cd ../../
fi
fi
tmux new-session -s main -d; tmux send -t main 'killall rhost; ./rhost -d' ENTER
2022-11-19 19:30:56 +08:00
tmux at -t main
}
check_os
pkg_install
main