-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·157 lines (133 loc) · 4.55 KB
/
install.sh
File metadata and controls
executable file
·157 lines (133 loc) · 4.55 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
# SniffCat cPHulk Integration - Installer
# https://github.com/Rexikon/SniffCat-cPanel
#
# Usage:
# bash <(curl -fsSL https://raw.githubusercontent.com/Rexikon/SniffCat-cPanel/main/install.sh)
#
# SPDX-License-Identifier: GPL-3.0-or-later
set -euo pipefail
# --- Configuration ---
INSTALL_DIR="/opt/sniffcat"
CONFIG_FILE="${INSTALL_DIR}/sniffcat.conf"
SCRIPT_NAME="cphulk.sh"
REPO_URL="https://raw.githubusercontent.com/Rexikon/SniffCat-cPanel/main"
LOG_FILE="/var/log/sniffcat.log"
# --- Colors ---
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m'
# --- Functions ---
info() { echo -e "${BLUE}[INFO]${NC} $*"; }
success() { echo -e "${GREEN}[OK]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*"; exit 1; }
banner() {
echo ""
echo -e "${BOLD}"
echo " ╔═══════════════════════════════════════╗"
echo " ║ SniffCat cPHulk Integration ║"
echo " ║ Installer v1.0 ║"
echo " ╚═══════════════════════════════════════╝"
echo -e "${NC}"
}
# --- Banner ---
banner
# --- Pre-checks ---
# Root check
if [[ $EUID -ne 0 ]]; then
error "This script must be run as root. Use: sudo bash install.sh"
fi
# Check for curl
if ! command -v curl &>/dev/null; then
error "curl is required but not installed. Install it with: yum install curl"
fi
# Check for cPanel/WHM
if [[ ! -d "/usr/local/cpanel" ]]; then
warn "cPanel does not appear to be installed on this server."
read -rp "Continue anyway? [y/N]: " confirm
[[ "$confirm" =~ ^[Yy]$ ]] || exit 0
fi
# Check for existing installation
if [[ -f "${INSTALL_DIR}/${SCRIPT_NAME}" ]]; then
warn "Existing installation detected at ${INSTALL_DIR}"
read -rp "Overwrite? [y/N]: " confirm
[[ "$confirm" =~ ^[Yy]$ ]] || exit 0
fi
# --- Token Input ---
echo ""
info "You need a SniffCat API token to continue."
info "Get your token at: ${BOLD}https://sniffcat.com${NC}"
echo ""
read -rp "$(echo -e "${YELLOW}Enter your SniffCat API token: ${NC}")" TOKEN
if [[ -z "$TOKEN" ]]; then
error "Token cannot be empty."
fi
if [[ ${#TOKEN} -lt 10 ]]; then
warn "Token seems too short. Are you sure it's correct?"
read -rp "Continue? [y/N]: " confirm
[[ "$confirm" =~ ^[Yy]$ ]] || exit 0
fi
# --- Installation ---
echo ""
info "Installing SniffCat cPHulk integration..."
# Create install directory
mkdir -p "$INSTALL_DIR"
success "Created directory: ${INSTALL_DIR}"
# Download script
info "Downloading ${SCRIPT_NAME}..."
if curl -fsSL "${REPO_URL}/${SCRIPT_NAME}" -o "${INSTALL_DIR}/${SCRIPT_NAME}"; then
success "Downloaded: ${INSTALL_DIR}/${SCRIPT_NAME}"
else
error "Failed to download ${SCRIPT_NAME} from ${REPO_URL}"
fi
# Create config file
cat > "$CONFIG_FILE" <<EOF
# SniffCat Configuration
# https://sniffcat.com
#
# API Token for authentication
SNIFFCAT_TOKEN="${TOKEN}"
EOF
success "Created config: ${CONFIG_FILE}"
# Set permissions
chmod 755 "${INSTALL_DIR}/${SCRIPT_NAME}"
chmod 600 "$CONFIG_FILE"
success "Set permissions (script: 755, config: 600)"
# Create log file
touch "$LOG_FILE"
chmod 640 "$LOG_FILE"
success "Created log file: ${LOG_FILE}"
# --- Verify installation ---
echo ""
info "Verifying installation..."
if [[ -x "${INSTALL_DIR}/${SCRIPT_NAME}" ]] && [[ -f "$CONFIG_FILE" ]]; then
success "Installation completed successfully!"
else
error "Installation verification failed."
fi
# --- Next steps ---
echo ""
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BOLD} Next Steps${NC}"
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e " 1. Log in to ${BOLD}WHM${NC}"
echo ""
echo -e " 2. Navigate to:"
echo -e " ${BLUE}Security Center → cPHulk Brute Force Protection${NC}"
echo ""
echo -e " 3. In the ${BOLD}IP Address-based Protection${NC} section, set"
echo -e " ${YELLOW}\"Command to Run When an IP Address Triggers"
echo -e " Brute Force Protection\"${NC} to:"
echo ""
echo -e " ${GREEN}${INSTALL_DIR}/${SCRIPT_NAME} %remote_ip% %authservice% %user% %current_failures% %reason%${NC}"
echo ""
echo -e " 4. ${BOLD}Save${NC} the settings."
echo ""
echo -e " ${BLUE}Logs:${NC} ${LOG_FILE}"
echo -e " ${BLUE}Config:${NC} ${CONFIG_FILE}"
echo ""