-
Notifications
You must be signed in to change notification settings - Fork 2
/
cloudflarecp
72 lines (63 loc) · 2.6 KB
/
cloudflarecp
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
65
66
67
68
69
70
71
72
#!/bin/bash
# @title CloudFlare cPanel Setup Script
# ------------------------------------------------------------------------------------------
# @author Myles McNamara
# @date 5.21.2013
# @version 1.0
# @source https://gh.smyl.es/cloudflarecp
# @description Install CloudFlare Core and add IPs to CSF Firewall ignore list (csf.ignore) on cPanel server
# ------------------------------------------------------------------------------------------
# @usage ./cloudflarecp <company name>
# ------------------------------------------------------------------------------------------
# @copyright Copyright (C) 2013 Myles McNamara
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------------------
#
# Enter your CloudFlare API Key below (REQUIRED)
APIKEY=
#
clear
if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [[ $1 == -* ]]; then
echo "Usage: $0 companyname" >&2
exit
fi
cd /usr/local/cpanel
# Download CloudFlare cPanel Module from GitHub
echo "Downloading CloudFlare"
curl -k -L https://github.com/cloudflare/CloudFlare-CPanel/tarball/master > cloudflare.tar.gz
# Extract and go to directory
tar -zxvf cloudflare.tar.gz
cd cloudflare-CloudFlare-*/cloudflare/
# Start Install
echo "Starting Install, this could take anywhere from 15 seconds to 4 minutes to complete."
./install_cf $APIKEY mod_cf "$1"
echo "Install complete, removing temporary files"
# Remove install files
cd ../../
rm -rf cloudflare-CloudFlare-CPanel-*
echo "Temporary files removed"
# Add CloudFlare IPv4 to CSF ignore list
echo "Adding CloudFlare IPv4 subnets to CSF ignore folder"
wget --output-document=- "https://www.cloudflare.com/ips-v4" >> /etc/csf/csf.ignore
# Add CloudFlare IPv6 to CSF ignore list
echo "Adding CloudFlare IPv6 subnets to CSF ignore folder"
wget --output-document=- "https://www.cloudflare.com/ips-v6" >> /etc/csf/csf.ignore
# Restart CSF
echo "Restarting CSF..."
csf -r
echo "Done."
# Upon completion, output config file
echo "Here's the config:"
cat etc/cloudflare.json