-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-github.sh
More file actions
322 lines (272 loc) · 11.4 KB
/
Copy pathsetup-github.sh
File metadata and controls
322 lines (272 loc) · 11.4 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
#!/bin/bash
# GitHub Setup Script for pteroanyinstall
# This script helps you quickly set up your GitHub repository
set -e
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ GITHUB REPOSITORY SETUP FOR PTEROANYINSTALL ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════════════╝${NC}"
echo ""
# Check if git is installed
if ! command -v git &> /dev/null; then
echo -e "${RED}✗ Git is not installed!${NC}"
echo ""
echo "Please install Git first:"
echo " Windows: https://git-scm.com/download/win"
echo " Linux: sudo apt install git"
echo " macOS: brew install git"
exit 1
fi
echo -e "${GREEN}✓ Git is installed${NC}"
echo ""
# Check if we're in the right directory
if [ ! -f "pteroanyinstall.sh" ]; then
echo -e "${RED}✗ Error: pteroanyinstall.sh not found!${NC}"
echo "Please run this script from the pteroanyinstall directory"
exit 1
fi
echo -e "${GREEN}✓ In correct directory${NC}"
echo ""
# Git configuration
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW} STEP 1: GIT CONFIGURATION${NC}"
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# Check if git is already configured
GIT_NAME=$(git config --global user.name 2>/dev/null || echo "")
GIT_EMAIL=$(git config --global user.email 2>/dev/null || echo "")
if [ -n "$GIT_NAME" ] && [ -n "$GIT_EMAIL" ]; then
echo -e "${GREEN}✓ Git is already configured:${NC}"
echo " Name: $GIT_NAME"
echo " Email: $GIT_EMAIL"
echo ""
read -p "Do you want to change these settings? (y/n): " change_config
if [[ ! "$change_config" =~ ^[Yy]$ ]]; then
echo "Keeping existing configuration"
else
GIT_NAME=""
GIT_EMAIL=""
fi
fi
if [ -z "$GIT_NAME" ]; then
echo "Enter your name (for Git commits):"
read -p "Name: " GIT_NAME
git config --global user.name "$GIT_NAME"
fi
if [ -z "$GIT_EMAIL" ]; then
echo "Enter your email (use your GitHub email):"
read -p "Email: " GIT_EMAIL
git config --global user.email "$GIT_EMAIL"
fi
echo ""
echo -e "${GREEN}✓ Git configured successfully${NC}"
echo ""
# GitHub username
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW} STEP 2: GITHUB REPOSITORY${NC}"
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo "Enter your GitHub username:"
read -p "Username: " GITHUB_USERNAME
if [ -z "$GITHUB_USERNAME" ]; then
echo -e "${RED}✗ GitHub username is required!${NC}"
exit 1
fi
echo ""
echo "Repository name (default: pteroanyinstall):"
read -p "Name [pteroanyinstall]: " REPO_NAME
REPO_NAME=${REPO_NAME:-pteroanyinstall}
echo ""
echo -e "${BLUE}Next steps:${NC}"
echo "1. Go to https://github.com/new"
echo "2. Repository name: $REPO_NAME"
echo "3. Description: Automated Pterodactyl installation with P.R.I.S.M AI"
echo "4. Choose Public or Private"
echo "5. DO NOT initialize with README (we have one)"
echo "6. Click 'Create repository'"
echo ""
read -p "Press Enter when you've created the repository on GitHub..."
# Initialize git if not already done
if [ ! -d ".git" ]; then
echo ""
echo "Initializing Git repository..."
git init
echo -e "${GREEN}✓ Git repository initialized${NC}"
else
echo -e "${GREEN}✓ Git repository already initialized${NC}"
fi
# Create .gitignore if it doesn't exist
if [ ! -f ".gitignore" ]; then
echo ""
echo "Creating .gitignore..."
cat > .gitignore <<'EOF'
# Logs
*.log
logs/
# OS files
.DS_Store
Thumbs.db
# Editor files
.vscode/
.idea/
*.swp
*.swo
*~
# Temporary files
*.tmp
*.bak
.cache/
# Sensitive data
*.key
*.pem
config.local.json
EOF
echo -e "${GREEN}✓ .gitignore created${NC}"
fi
# Add all files
echo ""
echo "Adding files to Git..."
git add .
echo -e "${GREEN}✓ Files added${NC}"
# Create initial commit
echo ""
echo "Creating initial commit..."
git commit -m "Initial commit: Complete Pterodactyl automation suite with P.R.I.S.M AI
Features:
- Automated Pterodactyl Panel & Wings installation
- P.R.I.S.M AI assistant with Discord notifications
- Panel customization tools
- Pre-installation checks
- Automated backups and monitoring
- Quick setup scripts
- Comprehensive documentation"
echo -e "${GREEN}✓ Initial commit created${NC}"
# Add remote
echo ""
echo "Adding GitHub remote..."
git remote add origin "https://github.com/$GITHUB_USERNAME/$REPO_NAME.git" 2>/dev/null || \
git remote set-url origin "https://github.com/$GITHUB_USERNAME/$REPO_NAME.git"
echo -e "${GREEN}✓ Remote added${NC}"
# Set main branch
echo ""
echo "Setting main branch..."
git branch -M main
echo -e "${GREEN}✓ Branch set to main${NC}"
# Update install.sh with correct URL
echo ""
echo "Updating install.sh with your repository URL..."
sed -i.bak "s|yourusername|$GITHUB_USERNAME|g" install.sh
sed -i.bak "s|YOUR_USERNAME|$GITHUB_USERNAME|g" install.sh
rm -f install.sh.bak
# Update pteroanyinstall.sh with correct URL
sed -i.bak "s|yourusername|$GITHUB_USERNAME|g" pteroanyinstall.sh
sed -i.bak "s|YOUR_USERNAME|$GITHUB_USERNAME|g" pteroanyinstall.sh
rm -f pteroanyinstall.sh.bak
git add install.sh pteroanyinstall.sh
git commit -m "Update repository URLs with GitHub username" 2>/dev/null || true
echo -e "${GREEN}✓ Repository URLs updated${NC}"
# Authentication
echo ""
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW} STEP 3: GITHUB AUTHENTICATION${NC}"
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo "Choose authentication method:"
echo " 1) Personal Access Token (Recommended)"
echo " 2) SSH Key"
echo ""
read -p "Choice [1]: " AUTH_CHOICE
AUTH_CHOICE=${AUTH_CHOICE:-1}
if [ "$AUTH_CHOICE" == "2" ]; then
# SSH Key setup
echo ""
echo "Setting up SSH key..."
if [ ! -f "$HOME/.ssh/id_ed25519.pub" ] && [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then
echo "Generating new SSH key..."
ssh-keygen -t ed25519 -C "$GIT_EMAIL" -f "$HOME/.ssh/id_ed25519" -N ""
echo -e "${GREEN}✓ SSH key generated${NC}"
else
echo -e "${GREEN}✓ SSH key already exists${NC}"
fi
echo ""
echo "Your public SSH key:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
cat "$HOME/.ssh/id_ed25519.pub" 2>/dev/null || cat "$HOME/.ssh/id_rsa.pub"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Add this key to GitHub:"
echo "1. Go to https://github.com/settings/keys"
echo "2. Click 'New SSH key'"
echo "3. Title: pteroanyinstall"
echo "4. Paste the key above"
echo "5. Click 'Add SSH key'"
echo ""
read -p "Press Enter when you've added the SSH key to GitHub..."
# Change remote to SSH
git remote set-url origin "git@github.com:$GITHUB_USERNAME/$REPO_NAME.git"
echo -e "${GREEN}✓ Remote changed to SSH${NC}"
else
# Personal Access Token
echo ""
echo "Create a Personal Access Token:"
echo "1. Go to https://github.com/settings/tokens"
echo "2. Click 'Generate new token (classic)'"
echo "3. Note: pteroanyinstall access"
echo "4. Select scopes: repo (all), workflow"
echo "5. Click 'Generate token'"
echo "6. COPY THE TOKEN (you won't see it again!)"
echo ""
echo "You'll be asked for your token when pushing to GitHub"
echo "Use the token as your password"
echo ""
fi
# Push to GitHub
echo ""
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW} STEP 4: PUSH TO GITHUB${NC}"
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo "Pushing to GitHub..."
if git push -u origin main; then
echo ""
echo -e "${GREEN}✓ Successfully pushed to GitHub!${NC}"
else
echo ""
echo -e "${RED}✗ Push failed${NC}"
echo ""
echo "If using Personal Access Token:"
echo " Username: $GITHUB_USERNAME"
echo " Password: <your token>"
echo ""
echo "Try pushing manually:"
echo " git push -u origin main"
exit 1
fi
# Success!
echo ""
echo -e "${GREEN}╔════════════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ SETUP COMPLETE! ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo "Your repository is now on GitHub:"
echo -e "${BLUE}https://github.com/$GITHUB_USERNAME/$REPO_NAME${NC}"
echo ""
echo "One-line installation command:"
echo -e "${BLUE}bash <(curl -s https://raw.githubusercontent.com/$GITHUB_USERNAME/$REPO_NAME/main/install.sh)${NC}"
echo ""
echo "Next steps:"
echo " 1. Test the one-line installer on a fresh server"
echo " 2. Add repository topics on GitHub (pterodactyl, automation, ai, monitoring)"
echo " 3. Enable GitHub Pages for documentation (optional)"
echo " 4. Create a release (optional)"
echo ""
echo "To update your repository in the future:"
echo " git add ."
echo " git commit -m \"Your commit message\""
echo " git push"
echo ""
echo -e "${GREEN}Happy hosting! 🚀${NC}"