-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathptero.sh
More file actions
422 lines (353 loc) · 16 KB
/
ptero.sh
File metadata and controls
422 lines (353 loc) · 16 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
#!/bin/bash
# Pterodactyl Management Interface
# Quick access to common commands
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
clear
show_banner() {
echo ""
echo -e "${CYAN}╔════════════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║${NC} ${BLUE}PTERODACTYL MANAGEMENT INTERFACE${NC} ${CYAN}║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════════════════════╝${NC}"
echo ""
}
show_menu() {
echo -e "${GREEN}SYSTEM MANAGEMENT:${NC}"
echo " 1) Update all scripts from GitHub"
echo " 2) Reinstall scripts only (keeps all data/services)"
echo " 3) Check service status"
echo " 4) View logs"
echo ""
echo -e "${GREEN}P.R.I.S.M AI ASSISTANT:${NC}"
echo " 5) Enable P.R.I.S.M"
echo " 6) Disable P.R.I.S.M"
echo " 7) Check P.R.I.S.M status"
echo " 8) Run system optimization"
echo " 9) Ask P.R.I.S.M a question"
echo ""
echo -e "${GREEN}WEB CONSOLE:${NC}"
echo " 10) Start web console"
echo " 11) Stop web console"
echo " 12) Restart web console"
echo " 13) View web console logs"
echo ""
echo -e "${GREEN}CLOUDFLARE TUNNEL:${NC}"
echo " 14) Start tunnel"
echo " 15) Stop tunnel"
echo " 16) Restart tunnel"
echo " 17) View tunnel logs"
echo ""
echo -e "${GREEN}DISCORD BOT:${NC}"
echo " 18) Start Discord bot"
echo " 19) Stop Discord bot"
echo " 20) Restart Discord bot"
echo " 21) View Discord bot logs"
echo " 22) Update Discord bot"
echo ""
echo -e "${GREEN}OTHER:${NC}"
echo " 23) Install/Setup P.R.I.S.M"
echo " 24) Open shell in /opt/ptero"
echo " 25) Help - What does each option do?"
echo ""
echo " 0) Exit"
echo ""
}
update_scripts() {
echo -e "${BLUE}[INFO]${NC} Updating scripts from GitHub..."
cd /opt/ptero
git reset --hard HEAD
git pull origin main
chmod +x *.sh 2>/dev/null || true
find /opt/ptero -type f -name "*.sh" -exec chmod +x {} \;
echo -e "${GREEN}[SUCCESS]${NC} Scripts updated!"
read -e -p "Press Enter to continue..."
}
update_discord_bot() {
echo -e "${BLUE}[INFO]${NC} Updating Discord bot..."
echo ""
# Pull latest changes
cd /opt/ptero
echo -e "${BLUE}[INFO]${NC} Fetching latest code from GitHub..."
git fetch origin
git reset --hard origin/main
# Restore execute permissions
chmod +x *.sh 2>/dev/null || true
find /opt/ptero -type f -name "*.sh" -exec chmod +x {} \; 2>/dev/null
# Copy updated bot files
echo -e "${BLUE}[INFO]${NC} Copying bot files..."
cp /opt/ptero/discord-bot/bot.py /opt/pterodactyl-bot/
cp /opt/ptero/discord-bot/voice_handler.py /opt/pterodactyl-bot/ 2>/dev/null || true
cp /opt/ptero/discord-bot/requirements.txt /opt/pterodactyl-bot/ 2>/dev/null || true
# Install/update dependencies (skip if already installed)
echo -e "${BLUE}[INFO]${NC} Checking dependencies..."
/opt/pterodactyl-bot/venv/bin/pip install -q -r /opt/pterodactyl-bot/requirements.txt 2>/dev/null || echo "Dependencies already installed"
# Restart bot
echo -e "${BLUE}[INFO]${NC} Restarting Discord bot..."
systemctl restart pterodactyl-bot
echo ""
echo -e "${GREEN}[SUCCESS]${NC} Discord bot updated!"
echo ""
echo "Check status with option 21 (View Discord bot logs)"
echo ""
read -e -p "Press Enter to continue..."
}
clean_install() {
echo -e "${BLUE}[INFO]${NC} This will reinstall scripts from GitHub."
echo -e "${GREEN}[SAFE]${NC} Your panel, databases, and services are NOT affected."
echo -e "${GREEN}[SAFE]${NC} Only the management scripts in /opt/ptero are replaced."
echo ""
read -e -p "Are you sure? (y/n): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
echo -e "${BLUE}[INFO]${NC} Removing old scripts..."
rm -rf /opt/ptero
rm -f /usr/local/bin/chatbot
echo -e "${BLUE}[INFO]${NC} Running installer..."
curl -sSL https://raw.githubusercontent.com/SirJBiscuit/automatic-system/main/install.sh | bash
echo -e "${GREEN}[SUCCESS]${NC} Clean install complete!"
else
echo "Cancelled."
fi
read -e -p "Press Enter to continue..."
}
check_status() {
echo -e "${BLUE}[INFO]${NC} Checking service status..."
echo ""
echo -e "${CYAN}=== Pterodactyl Panel ===${NC}"
systemctl is-active --quiet nginx && echo -e " Nginx: ${GREEN}Running${NC}" || echo -e " Nginx: ${RED}Stopped${NC}"
systemctl is-active --quiet mysql && echo -e " MySQL: ${GREEN}Running${NC}" || echo -e " MySQL: ${RED}Stopped${NC}"
systemctl is-active --quiet redis-server && echo -e " Redis: ${GREEN}Running${NC}" || echo -e " Redis: ${RED}Stopped${NC}"
echo ""
echo -e "${CYAN}=== Wings ===${NC}"
systemctl is-active --quiet wings && echo -e " Wings: ${GREEN}Running${NC}" || echo -e " Wings: ${RED}Stopped${NC}"
echo ""
echo -e "${CYAN}=== Web Console ===${NC}"
systemctl is-active --quiet pterodactyl-web-console && echo -e " Web Console: ${GREEN}Running${NC}" || echo -e " Web Console: ${RED}Stopped${NC}"
echo ""
echo -e "${CYAN}=== Cloudflare Tunnel ===${NC}"
systemctl is-active --quiet cloudflared && echo -e " Tunnel: ${GREEN}Running${NC}" || echo -e " Tunnel: ${RED}Stopped${NC}"
echo ""
echo -e "${CYAN}=== P.R.I.S.M ===${NC}"
systemctl is-active --quiet ptero-assistant && echo -e " P.R.I.S.M: ${GREEN}Running${NC}" || echo -e " P.R.I.S.M: ${RED}Stopped${NC}"
systemctl is-active --quiet ollama && echo -e " Ollama: ${GREEN}Running${NC}" || echo -e " Ollama: ${RED}Stopped${NC}"
echo ""
read -e -p "Press Enter to continue..."
}
view_logs() {
echo ""
echo "Select logs to view:"
echo " 1) Web Console"
echo " 2) Cloudflare Tunnel"
echo " 3) P.R.I.S.M"
echo " 4) Wings"
echo " 5) Nginx Error Log"
echo ""
read -e -p "Select [1-5]: " log_choice
case $log_choice in
1) journalctl -u pterodactyl-web-console -f ;;
2) journalctl -u cloudflared -f ;;
3) tail -f /var/log/ptero-assistant.log ;;
4) journalctl -u wings -f ;;
5) tail -f /var/log/nginx/error.log ;;
*) echo "Invalid choice" ;;
esac
}
ask_prism() {
echo ""
read -e -p "Ask P.R.I.S.M: " question
if [ -n "$question" ]; then
chatbot ask "$question"
fi
echo ""
read -e -p "Press Enter to continue..."
}
show_help() {
cat << 'HELPEOF' | less -R
╔════════════════════════════════════════════════════════════════════════╗
║ PTERODACTYL MANAGEMENT HELP ║
╚════════════════════════════════════════════════════════════════════════╝
SYSTEM MANAGEMENT:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1) Update all scripts from GitHub
• Pulls latest code from GitHub repository
• Resets any local changes to scripts
• Sets execute permissions automatically
• Quick way to get bug fixes and new features
• SAFE: Does not affect your panel, databases, or game servers
2) Reinstall scripts only (keeps all data/services)
• Deletes /opt/ptero and /usr/local/bin/chatbot
• Downloads fresh copy from GitHub
• Preserves ALL services, configs, and data
• SAFE: Only reinstalls management scripts
• Your panel, databases, P.R.I.S.M config are untouched
• Use when scripts are corrupted or you want a fresh start
3) Check service status
• Shows if all services are running or stopped
• Checks: Nginx, MySQL, Redis, Wings, Web Console, Tunnel, P.R.I.S.M
• Color-coded: Green = running, Red = stopped
• Quick health check of your entire system
4) View logs
• Opens real-time logs for any service
• Choose from: Web Console, Tunnel, P.R.I.S.M, Wings, Nginx
• Press Ctrl+C to exit log view
• Useful for troubleshooting errors
P.R.I.S.M AI ASSISTANT:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
5) Enable P.R.I.S.M
• Starts the AI monitoring service
• Begins 24/7 system monitoring
• Auto-fixes common issues
• Same as running: chatbot -enable
6) Disable P.R.I.S.M
• Stops the AI monitoring service
• Monitoring pauses until re-enabled
• Same as running: chatbot -disable
7) Check P.R.I.S.M status
• Shows if P.R.I.S.M is running
• Displays current configuration
• Shows AI model being used
• Same as running: chatbot status
8) Run system optimization
• AI analyzes your ENTIRE system
• Checks: CPU, RAM, disk, services, security
• Suggests specific optimizations
• Offers to apply fixes automatically
• Takes 1-2 minutes to complete
• Same as running: chatbot detect
9) Ask P.R.I.S.M a question
• Interactive prompt to ask AI anything
• Examples:
- "Why is CPU usage high?"
- "How do I optimize MySQL?"
- "What's causing high memory usage?"
• Get instant expert advice
• Same as running: chatbot ask "question"
WEB CONSOLE:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
10) Start web console
• Starts the Pterodactyl Web Console service
• Makes it accessible at https://console.cloudmc.online
• Use when console is stopped
11) Stop web console
• Stops the web console service
• Console becomes inaccessible
• Use for maintenance or troubleshooting
12) Restart web console
• Stops then starts the service
• Use after config changes
• Use if console is stuck or not responding
13) View web console logs
• Real-time logs from the web console
• See login attempts, errors, API calls
• Press Ctrl+C to exit
• Useful for debugging connection issues
CLOUDFLARE TUNNEL:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
14) Start tunnel
• Starts the Cloudflare tunnel service
• Makes your services accessible via custom domain
• Required for external access
15) Stop tunnel
• Stops the tunnel
• External access via domain stops working
• Local access still works
16) Restart tunnel
• Restarts the tunnel service
• Use after config changes
• Use if tunnel shows connection errors
17) View tunnel logs
• Real-time tunnel logs
• See connection status, errors, requests
• Press Ctrl+C to exit
• Useful for debugging 502 errors
DISCORD BOT:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
18) Start Discord bot
• Starts the Pterodactyl Discord bot service
• Enables Discord commands for server management
• Use when bot is stopped
19) Stop Discord bot
• Stops the Discord bot service
• Bot goes offline in Discord
• Use for maintenance or troubleshooting
20) Restart Discord bot
• Stops then starts the bot service
• Use after updating bot code
• Use if bot is stuck or not responding
21) View Discord bot logs
• Real-time logs from the Discord bot
• See command usage, errors, connections
• Press Ctrl+C to exit
• Useful for debugging bot issues
22) Update Discord bot
• Pulls latest bot code from GitHub
• Updates bot.py and voice_handler.py
• Installs/updates Python dependencies
• Automatically restarts the bot
• Use when new features are added
OTHER:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
23) Install/Setup P.R.I.S.M
• Runs the full P.R.I.S.M installation script
• Use for first-time setup
• Use to reinstall if P.R.I.S.M is broken
• Downloads AI model (takes 5-10 minutes)
24) Open shell in /opt/ptero
• Opens a bash shell in the scripts directory
• For advanced users who want to run custom commands
• Type 'exit' to return to menu
• Be careful - you can break things here!
25) Help - What does each option do?
• Shows this help screen
• Use arrow keys or Page Up/Down to scroll
• Press 'q' to exit help
0) Exit
• Closes the menu interface
• Returns to normal terminal
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
TIP: Use arrow keys or Page Up/Down to scroll. Press 'q' to exit help.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
HELPEOF
}
# Main loop
while true; do
show_banner
show_menu
read -e -p "Select option: " choice
echo ""
case $choice in
1) update_scripts ;;
2) clean_install ;;
3) check_status ;;
4) view_logs ;;
5) chatbot -enable; read -e -p "Press Enter to continue..." ;;
6) chatbot -disable; read -e -p "Press Enter to continue..." ;;
7) chatbot status; read -e -p "Press Enter to continue..." ;;
8) chatbot detect ;;
9) ask_prism ;;
10) systemctl start pterodactyl-web-console; echo "Web console started"; read -e -p "Press Enter to continue..." ;;
11) systemctl stop pterodactyl-web-console; echo "Web console stopped"; read -e -p "Press Enter to continue..." ;;
12) systemctl restart pterodactyl-web-console; echo "Web console restarted"; read -e -p "Press Enter to continue..." ;;
13) journalctl -u pterodactyl-web-console -f ;;
14) systemctl start cloudflared; echo "Tunnel started"; read -e -p "Press Enter to continue..." ;;
15) systemctl stop cloudflared; echo "Tunnel stopped"; read -e -p "Press Enter to continue..." ;;
16) systemctl restart cloudflared; echo "Tunnel restarted"; read -e -p "Press Enter to continue..." ;;
17) journalctl -u cloudflared -f ;;
18) systemctl start pterodactyl-bot; echo "Discord bot started"; read -e -p "Press Enter to continue..." ;;
19) systemctl stop pterodactyl-bot; echo "Discord bot stopped"; read -e -p "Press Enter to continue..." ;;
20) systemctl restart pterodactyl-bot; echo "Discord bot restarted"; read -e -p "Press Enter to continue..." ;;
21) journalctl -u pterodactyl-bot -f ;;
22) update_discord_bot ;;
23) cd /opt/ptero && ./ai-assistant-setup.sh ;;
24) cd /opt/ptero && bash ;;
25) show_help ;;
0) echo "Goodbye!"; exit 0 ;;
*) echo -e "${RED}Invalid option${NC}"; sleep 1 ;;
esac
clear
done