-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·291 lines (251 loc) · 8.15 KB
/
setup.sh
File metadata and controls
executable file
·291 lines (251 loc) · 8.15 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/bin/bash
#
# WolfProxy One-Line Installer
# (C) 2026 Wolf Software Systems Ltd - http://wolf.uk.com
#
# Usage:
# curl -sL https://raw.githubusercontent.com/wolfsoftwaresystemsltd/wolfproxy/main/setup.sh | sudo bash
# wget -qO- https://raw.githubusercontent.com/wolfsoftwaresystemsltd/wolfproxy/main/setup.sh | sudo bash
#
set -e
# Colors
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
CYAN='\033[36m'
RESET='\033[0m'
BOLD='\033[1m'
banner() {
echo ""
echo -e "${CYAN} __ ______ _ ______ _____ _____ ______ ____ __${RESET}"
echo -e "${CYAN} \\ \\ / / __ \\| | | ____| __ \\| __ \\ / __ \\ \\ / /\\ \\ / /${RESET}"
echo -e "${CYAN} \\ \\ /\\ / / | | | | | |__ | |__) | |__) | | | \\ V / \\ \\_/ / ${RESET}"
echo -e "${CYAN} \\ \\/ \\/ /| | | | | | __| | ___/| _ /| | | |> < \\ / ${RESET}"
echo -e "${CYAN} \\ /\\ / | |__| | |____| | | | | | \\ \\| |__| / . \\ | | ${RESET}"
echo -e "${CYAN} \\/ \\/ \\____/|______|_| |_| |_| \\_\\\\____/_/ \\_\\ |_| ${RESET}"
echo ""
echo -e "${BOLD} (C) 2026 Wolf Software Systems Ltd - http://wolf.uk.com${RESET}"
echo -e "${BOLD} One-Line Installer${RESET}"
echo ""
}
info() {
echo -e "${BLUE}[INFO]${RESET} $1"
}
success() {
echo -e "${GREEN}[OK]${RESET} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${RESET} $1"
}
error() {
echo -e "${RED}[ERROR]${RESET} $1"
exit 1
}
command_exists() {
command -v "$1" &> /dev/null
}
detect_package_manager() {
if command_exists apt-get; then
echo "apt"
elif command_exists dnf; then
echo "dnf"
elif command_exists yum; then
echo "yum"
elif command_exists pacman; then
echo "pacman"
elif command_exists zypper; then
echo "zypper"
else
echo ""
fi
}
install_dependencies() {
local pm=$1
info "Installing build dependencies using $pm..."
case $pm in
apt)
apt-get update -qq
apt-get install -y build-essential pkg-config libssl-dev git curl
;;
dnf)
dnf install -y gcc gcc-c++ make pkg-config openssl-devel git curl
;;
yum)
yum install -y gcc gcc-c++ make pkg-config openssl-devel git curl
;;
pacman)
pacman -Sy --noconfirm base-devel openssl git curl
;;
zypper)
zypper install -y gcc gcc-c++ make pkg-config libopenssl-devel git curl
;;
*)
error "Unsupported package manager. Please install dependencies manually."
;;
esac
success "Dependencies installed"
}
install_rust() {
if command_exists cargo; then
success "Rust is already installed"
return
fi
# Check in common location
if [ -f "$HOME/.cargo/bin/cargo" ]; then
export PATH="$HOME/.cargo/bin:$PATH"
success "Rust found at ~/.cargo/bin"
return
fi
info "Installing Rust via rustup..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
success "Rust installed"
}
# Main installation
banner
# Check if running as root
if [ "$(id -u)" -ne 0 ]; then
error "This script must be run as root. Use: curl ... | sudo bash"
fi
# Detect package manager
pm=$(detect_package_manager)
if [ -z "$pm" ]; then
error "Could not detect package manager. Supported: apt, dnf, yum, pacman, zypper"
fi
info "Detected package manager: $pm"
# Install dependencies
install_dependencies "$pm"
# Install Rust
install_rust
# Clone or download repository
INSTALL_DIR="/opt/wolfproxy"
REPO_URL="https://github.com/wolfsoftwaresystemsltd/wolfproxy.git"
if [ -d "$INSTALL_DIR" ] && [ -d "$INSTALL_DIR/.git" ]; then
info "Updating existing installation..."
cd "$INSTALL_DIR"
# Back up config before pull (git may conflict with local config)
if [ -f "$INSTALL_DIR/wolfproxy.toml" ]; then
cp "$INSTALL_DIR/wolfproxy.toml" /tmp/wolfproxy.toml.bak
fi
git checkout -- . 2>/dev/null || true
git pull
# Restore config
if [ -f /tmp/wolfproxy.toml.bak ]; then
cp /tmp/wolfproxy.toml.bak "$INSTALL_DIR/wolfproxy.toml"
rm /tmp/wolfproxy.toml.bak
success "Restored existing configuration"
fi
success "Updated to latest version"
elif [ -d "$INSTALL_DIR" ]; then
info "Existing non-git installation found, re-installing..."
# Preserve config
if [ -f "$INSTALL_DIR/wolfproxy.toml" ]; then
cp "$INSTALL_DIR/wolfproxy.toml" /tmp/wolfproxy.toml.bak
info "Backed up existing wolfproxy.toml"
fi
rm -rf "$INSTALL_DIR"
git clone "$REPO_URL" "$INSTALL_DIR"
# Restore config
if [ -f /tmp/wolfproxy.toml.bak ]; then
cp /tmp/wolfproxy.toml.bak "$INSTALL_DIR/wolfproxy.toml"
rm /tmp/wolfproxy.toml.bak
success "Restored existing configuration"
fi
success "Repository cloned"
else
info "Cloning WolfProxy repository..."
git clone "$REPO_URL" "$INSTALL_DIR"
success "Repository cloned"
fi
# Build
info "Building WolfProxy (this may take a few minutes)..."
cd "$INSTALL_DIR"
CARGO="cargo"
if [ -f "$HOME/.cargo/bin/cargo" ]; then
CARGO="$HOME/.cargo/bin/cargo"
fi
$CARGO build --release
success "Build complete"
# Create systemd service file
info "Installing systemd service..."
cat > /etc/systemd/system/wolfproxy.service << 'EOF'
[Unit]
Description=WolfProxy - High Performance Reverse Proxy
After=network.target
[Service]
Type=simple
ExecStart=/opt/wolfproxy/target/release/wolfproxy
WorkingDirectory=/opt/wolfproxy
Restart=always
RestartSec=5
User=root
Environment=RUST_LOG=info
# File descriptor limit - critical for a reverse proxy
LimitNOFILE=65536
# OOM protection - prefer killing other processes
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
success "Service installed"
# Create default config if not exists
if [ ! -f "$INSTALL_DIR/wolfproxy.toml" ]; then
cat > "$INSTALL_DIR/wolfproxy.toml" << 'EOF'
[server]
host = "0.0.0.0"
http_port = 80
https_port = 443
[nginx]
config_dir = "/etc/nginx"
auto_reload = false
[monitoring]
enabled = true
port = 5001
username = "admin"
password = "admin"
EOF
success "Default configuration created"
fi
# Stop existing services and start WolfProxy
info "Activating WolfProxy..."
# Stop wolfproxy if running
if systemctl is-active --quiet wolfproxy 2>/dev/null; then
info "Stopping existing WolfProxy..."
systemctl stop wolfproxy
success "WolfProxy stopped"
fi
# Stop nginx if running (wolfproxy replaces it)
if systemctl is-active --quiet nginx 2>/dev/null; then
info "Stopping nginx (WolfProxy replaces nginx)..."
systemctl stop nginx
systemctl disable nginx 2>/dev/null || true
success "nginx stopped and disabled"
fi
# Start WolfProxy
systemctl enable wolfproxy 2>/dev/null || true
systemctl start wolfproxy
# Verify it started
sleep 2
if systemctl is-active --quiet wolfproxy; then
success "WolfProxy is running!"
else
error "WolfProxy failed to start. Check logs: journalctl -u wolfproxy -n 50"
fi
echo ""
echo -e "${GREEN}${BOLD}═══════════════════════════════════════════════════════════════${RESET}"
echo -e "${GREEN}${BOLD} WolfProxy has been installed and started successfully!${RESET}"
echo -e "${GREEN}${BOLD}═══════════════════════════════════════════════════════════════${RESET}"
echo ""
echo -e " Installation directory: ${CYAN}/opt/wolfproxy${RESET}"
echo -e " Configuration file: ${CYAN}/opt/wolfproxy/wolfproxy.toml${RESET}"
echo ""
echo " Commands:"
echo -e " Status: ${YELLOW}sudo systemctl status wolfproxy${RESET}"
echo -e " Logs: ${YELLOW}journalctl -u wolfproxy -f${RESET}"
echo -e " Restart: ${YELLOW}sudo systemctl restart wolfproxy${RESET}"
echo ""
echo -e " Monitoring: ${CYAN}http://your-server:5001/${RESET}"
echo -e " Documentation: ${CYAN}https://github.com/wolfsoftwaresystemsltd/wolfproxy${RESET}"
echo ""