This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathsiteguardlite.sh
executable file
·64 lines (57 loc) · 2.56 KB
/
siteguardlite.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# @sacloud-name "SiteGuard Server Edition"
# @sacloud-once
# @sacloud-desc WAF(Web Application Firewall)は、これまでのL3ファイアウォールでは防御することが難しかった、Web上で動作するアプリケーションなどのL7への攻撃検知・防御や、アクセス制御機構などを提供するものです。
# @sacloud-desc さくらのクラウドではEGセキュアソリューションズ株式会社が開発する純国産のホスト型WAF製品「SiteGuard Server Edition」をさくらのクラウド向け特別版として無料で提供しています。
# @sacloud-desc 完了後自動再起動します。
# @sacloud-desc (このスクリプトは CentOS 7.X, 8.X, AlmaLinux 8.X で動作します)
# @sacloud-desc セットアップ完了後、ご利用ガイド、管理者用ガイドを参照し初期設定を実施してください。
# @sacloud-require-archive distro-centos distro-ver-7.*
# @sacloud-require-archive distro-centos distro-ver-8.*
# @sacloud-require-archive distro-alma distro-ver-8.*
## ScriptName : CentOS_SiteGuardServerEdition-Apache
#===== Startup Script Motd Monitor =====#
_motd() {
LOG=$(ls /root/.sacloud-api/notes/*log)
case $1 in
start)
echo -e "\n#-- Startup-script is \\033[0;32mrunning\\033[0;39m. --#\n\nPlease check the log file: ${LOG}\n" > /etc/motd
;;
fail)
echo -e "\n#-- Startup-script \\033[0;31mfailed\\033[0;39m. --#\n\nPlease check the log file: ${LOG}\n" > /etc/motd
exit 1
;;
end)
cp -f /dev/null /etc/motd
;;
esac
}
_motd start
set -ex
trap '_motd fail' ERR
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent
firewall-cmd --add-port=9443/tcp --zone=public --permanent
firewall-cmd --reload
yum install -y httpd glibc perl wget unzip openssl make file java mod_ssl expect
file_name="siteguard-server-edition-5.00-1.apache.x86_64.rpm"
wget -q "http://progeny.sakura.ad.jp/siteguard/5.0.0/apache/${file_name}" -P /root/.sakuracloud
rpm -Uvh "/root/.sakuracloud/${file_name}"
systemctl enable httpd.service
systemctl start httpd.service
cat > /opt/jp-secure/siteguardlite/conf/dbupdate_waf_url.conf <<-EOF
LATEST_URL=https://www.jp-secure.com/download/siteguardlite_sp/updates_lite/latest-lite.zip
EOF
cd /opt/jp-secure/siteguardlite/
expect -c "
spawn ./setup.sh
set i 0
while {\$i <= 32} {
expect -- \"-->\"
send -- \"\n\"
incr i 1
}
"
_motd end
sh -c "echo -e '##########\nReboot after 10 seconds\n##########' | wall -n; sleep 10; reboot" &
exit 0