-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-assisted-install.sh
More file actions
295 lines (246 loc) · 8.83 KB
/
Copy pathai-assisted-install.sh
File metadata and controls
295 lines (246 loc) · 8.83 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
#!/bin/bash
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
NC='\033[0m'
BOLD='\033[1m'
AI_URL=""
INSTALL_LOG="/var/log/ai-assisted-install.log"
show_ai_assistant_intro() {
dialog --clear --backtitle "AI-Assisted Installation" \
--title "🤖 Welcome to AI-Assisted Installation!" \
--msgbox "This mode will:\n\n\
1. Install Ollama AI Server (5 minutes)\n\
2. Install Open WebUI (3 minutes)\n\
3. Download a helpful AI model (10-15 minutes)\n\
4. Give you access to an AI assistant at ai.yourdomain.com\n\n\
The AI can then help you with:\n\
• Understanding installation steps\n\
• Troubleshooting errors\n\
• Explaining technical concepts\n\
• Choosing the right configuration\n\
• Writing custom scripts\n\n\
Total time: ~20 minutes\n\n\
After this, you can ask the AI for help with the rest of your installation!" 24 75
}
install_ollama_quick() {
echo "Installing Ollama..." | tee -a "$INSTALL_LOG"
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Start Ollama service
systemctl enable ollama
systemctl start ollama
# Wait for Ollama to be ready
sleep 5
echo "Ollama installed successfully!" | tee -a "$INSTALL_LOG"
}
install_openwebui_quick() {
echo "Installing Open WebUI..." | tee -a "$INSTALL_LOG"
# Install Docker if not present
if ! command -v docker &> /dev/null; then
curl -fsSL https://get.docker.com | sh
systemctl enable docker
systemctl start docker
fi
# Run Open WebUI container
docker run -d \
--name open-webui \
--restart always \
-p 3000:8080 \
-v open-webui:/app/backend/data \
-e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
--add-host=host.docker.internal:host-gateway \
ghcr.io/open-webui/open-webui:main
echo "Open WebUI installed successfully!" | tee -a "$INSTALL_LOG"
}
download_ai_model() {
local model=$1
dialog --clear --backtitle "AI-Assisted Installation" \
--title "Downloading AI Model" \
--infobox "Downloading $model...\n\nThis may take 10-15 minutes depending on your internet speed.\n\nModel size: ~4GB" 10 60
# Pull the model
ollama pull $model 2>&1 | tee -a "$INSTALL_LOG"
dialog --clear --backtitle "AI-Assisted Installation" \
--title "✅ Model Downloaded!" \
--msgbox "AI model '$model' is ready!\n\nYou can now chat with the AI assistant." 10 60
}
choose_ai_model() {
local model
model=$(dialog --clear --backtitle "AI-Assisted Installation" \
--title "Choose AI Model" \
--menu "Select which AI model to download:" 18 70 6 \
1 "Llama 3.2 (Recommended) - 2GB, Fast & Smart" \
2 "Mistral - 4GB, Very Capable" \
3 "Phi-3 - 2GB, Efficient" \
4 "CodeLlama - 4GB, Best for Code Help" \
5 "Gemma 2 - 3GB, Google's Model" \
6 "Skip for now (install model later)" \
3>&1 1>&2 2>&3)
case $model in
1) echo "llama3.2" ;;
2) echo "mistral" ;;
3) echo "phi3" ;;
4) echo "codellama" ;;
5) echo "gemma2" ;;
6) echo "" ;;
*) echo "llama3.2" ;;
esac
}
setup_ai_domain() {
if dialog --yesno "Would you like to set up a domain for your AI assistant?\n\nThis will make it accessible at ai.yourdomain.com" 10 60; then
bash /opt/ptero/setup-domain-wizard.sh --component "AI Assistant" "ai"
if [ $? -eq 0 ]; then
source /etc/automatic-system/domains.conf
AI_URL="https://$AI_DOMAIN"
# Setup Nginx reverse proxy
setup_nginx_proxy "$AI_DOMAIN"
fi
else
# Use localhost
AI_URL="http://localhost:3000"
fi
}
setup_nginx_proxy() {
local domain=$1
# Install Nginx if not present
if ! command -v nginx &> /dev/null; then
apt-get update
apt-get install -y nginx
fi
# Create Nginx config
cat > /etc/nginx/sites-available/open-webui << EOF
server {
listen 80;
server_name $domain;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
}
EOF
# Enable site
ln -sf /etc/nginx/sites-available/open-webui /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
# Install SSL with Certbot
if command -v certbot &> /dev/null; then
certbot --nginx -d $domain --non-interactive --agree-tos --email admin@$domain
fi
}
create_installation_assistant_prompt() {
local prompt_file="/opt/ptero/ai-install-assistant.txt"
cat > "$prompt_file" << 'EOF'
You are an expert Linux system administrator and Pterodactyl installation assistant. You are helping a user install and configure Pterodactyl Panel and Wings on their server.
Your role:
- Explain technical concepts in simple terms
- Help troubleshoot installation errors
- Suggest best practices for server configuration
- Answer questions about domains, DNS, SSL, and networking
- Provide step-by-step guidance when needed
- Write scripts and commands when requested
Current installation context:
- OS: Ubuntu 22.04 LTS
- Pterodactyl Panel version: 1.11.5
- Pterodactyl Wings version: 1.11.5
- Installation method: Automatic installation script
Available components to install:
1. Pterodactyl Panel (web interface)
2. Pterodactyl Wings (game server daemon)
3. FileBrowser (file management)
4. Pingvin Share (file sharing)
5. Nextcloud (cloud storage)
6. Admin Panel (unified control panel)
7. SSH Terminal (web-based terminal)
Common tasks you can help with:
- Domain and DNS setup
- Cloudflare configuration
- SSL certificate installation
- Firewall configuration
- Database setup
- Troubleshooting connection issues
- Performance optimization
Be friendly, patient, and thorough in your explanations. If you don't know something, say so and suggest where to find the information.
EOF
echo "$prompt_file"
}
show_ai_access_info() {
local access_url=$1
local model=$2
dialog --clear --backtitle "AI-Assisted Installation" \
--title "🎉 AI Assistant Ready!" \
--msgbox "Your AI assistant is now running!\n\n\
Access URL: $access_url\n\
AI Model: $model\n\n\
First-time setup:\n\
1. Open $access_url in your browser\n\
2. Create an admin account\n\
3. Start chatting with the AI!\n\n\
Example questions to ask:\n\
• 'How do I set up a domain for Pterodactyl Panel?'\n\
• 'What's the difference between Panel and Wings?'\n\
• 'Help me troubleshoot a DNS issue'\n\
• 'Explain how to configure SSL certificates'\n\
• 'Write a script to backup my database'\n\n\
The AI has been configured to help with your installation!" 24 75
}
offer_continue_installation() {
if dialog --yesno "Would you like to continue with the main installation now?\n\nYou can:\n• Keep the AI assistant open in another tab\n• Ask it questions as you go\n• Get help if you encounter errors\n\nContinue to main installer?" 14 65; then
return 0
else
dialog --clear --backtitle "AI-Assisted Installation" \
--title "Installation Paused" \
--msgbox "Installation paused.\n\nYour AI assistant is running at:\n$AI_URL\n\nTo continue installation later, run:\nbash install-interactive.sh\n\nThe AI will still be available to help!" 14 65
return 1
fi
}
main() {
# Show intro
show_ai_assistant_intro
# Install Ollama
(
echo "10"
install_ollama_quick
echo "30"
sleep 1
) | dialog --clear --backtitle "AI-Assisted Installation" \
--title "Installing Ollama" \
--gauge "Installing Ollama AI Server..." 10 70 0
# Install Open WebUI
(
echo "40"
install_openwebui_quick
echo "60"
sleep 1
) | dialog --clear --backtitle "AI-Assisted Installation" \
--title "Installing Open WebUI" \
--gauge "Installing Open WebUI interface..." 10 70 0
# Setup domain (optional)
setup_ai_domain
# Choose and download model
local model=$(choose_ai_model)
if [ -n "$model" ]; then
download_ai_model "$model"
else
model="(none - install later)"
fi
# Create assistant prompt
create_installation_assistant_prompt
# Show access info
show_ai_access_info "$AI_URL" "$model"
# Offer to continue
if offer_continue_installation; then
# Return to main installer
exec bash /opt/ptero/install-interactive.sh
fi
}
main "$@"