#!/bin/bash
echo -e "\t 准备安装南墙WAF..."
yum install -y ca-certificates
sed -i 's/^SELINUX=permissive$/SELINUX=disabled/' /etc/selinux/config
if [ -f "/uuwaf/waf-service" ];then
echo -e "\t 卸载旧版WAF..."
ps -ax | grep waf-service | awk '{print $1}' | xargs kill -9 > /dev/null 2>&1
ps -ax | grep uuwaf | awk '{print $1}' | xargs kill -9 > /dev/null 2>&1
/uuwaf/waf-service -s uninstall > /dev/null 2>&1
rm -rf /uuwaf
fi
echo -e "\t 正在安装数据库..."
if [ -f "/etc/my.cnf" ];then
systemctl stop mysqld
rpm -qa | grep -ie ^mysql | xargs yum -y erase
rpm -qa | grep -ie ^percona | xargs yum -y erase
rm -rf /var/lib/mysql
rm -f /etc/my.cnf
fi
yum -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
percona-release setup pdps-8.0
yum install -y percona-server-server
systemctl start mysqld
TEMP_PASS=$(grep 'temporary password' /var/log/mysqld.log | sed -e 's/.*localhost: //' | tail -1)
mysql "-p${TEMP_PASS}" --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Safe3.WAF';" > /dev/null 2>&1
mysql -pSafe3.WAF -e "update mysql.user set host='%' where user = 'root';flush privileges;" > /dev/null 2>&1
echo -e "\t 正在安装WAF..."
sed -n -e '1,/^exit 0$/!p' $0 > waf.tgz 2>/dev/null
tar zxf waf.tgz -C /
rm -f waf.tgz
sed -i 's/172.22.0.7/127.0.0.1/' /uuwaf/conf/uuwaf.conf
sed -i 's/172.22.0.7/127.0.0.1/' /uuwaf/web/conf/conf.yaml
mysql -pSafe3.WAF --default-character-set=utf8 < /uuwaf/initdb/waf.sql > /dev/null 2>&1
rm -rf /uuwaf/initdb
chmod +x /uuwaf/waf-service
chmod +x /uuwaf/sbin/uuwaf
/uuwaf/waf-service -s install
echo -e "\t 南墙WAF服务安装完成!"
firewall-cmd --permanent --add-port={80,443,4443}/tcp > /dev/null 2>&1
firewall-cmd --reload > /dev/null 2>&1
/uuwaf/waf-service -s start
echo -e "\t 恭喜您,安装成功!"
exit 0
$Cc y\L?3T>bZU^eWi6T(MN%)B%=kEE!}|>^ޏ>u]9g̜\:R#??e=C}]c9z=]i?[Do
d֯?[jKAu_@w???9F]ן_bg?ٖJ:0'85e?u.a&$fMT0\d6Ol4?_۹a;Lwޗ:^AƆ:Wkb