|
34 | 34 | KILL_MODE=false |
35 | 35 | fi |
36 | 36 |
|
37 | | -# Ask about GitHub authentication method first |
38 | | -print_info "GitHub authentication options:" |
39 | | -echo "1. SSH key (recommended if already set up on server)" |
40 | | -echo "2. Personal Access Token (will prompt when needed)" |
41 | | -echo "3. Skip repository update (use existing code on server)" |
42 | | -read -p "Choose option [1-3]: " AUTH_OPTION |
43 | | - |
44 | | -if [ "$AUTH_OPTION" = "2" ]; then |
45 | | - echo |
46 | | - print_warning "GitHub now requires Personal Access Tokens instead of passwords." |
47 | | - print_info "Create one at: https://github.com/settings/tokens" |
48 | | - print_info "Grant 'repo' scope for private repository access." |
49 | | - echo |
50 | | - read -p "Enter your GitHub username: " GH_USER |
51 | | - read -s -p "Enter your GitHub Personal Access Token: " GH_TOKEN |
52 | | - echo |
53 | | - export GH_USER GH_TOKEN |
54 | | -fi |
55 | | - |
56 | | -# Now get server details |
57 | | -echo |
| 37 | +# Get server details |
58 | 38 | read -p "Enter GPU server address (hostname or IP): " SERVER_ADDRESS |
59 | 39 | if [ -z "$SERVER_ADDRESS" ]; then |
60 | 40 | print_error "Server address cannot be empty" |
|
77 | 57 | echo |
78 | 58 |
|
79 | 59 | # Execute the remote script via SSH |
80 | | -# Pass variables as arguments to the remote bash |
81 | | -ssh -t "$USERNAME@$SERVER_ADDRESS" "AUTH_OPTION='$AUTH_OPTION' GH_USER='$GH_USER' GH_TOKEN='$GH_TOKEN' KILL_MODE='$KILL_MODE' bash -s" << 'ENDSSH' |
| 60 | +ssh -t "$USERNAME@$SERVER_ADDRESS" "KILL_MODE='$KILL_MODE' bash -s" << 'ENDSSH' |
82 | 61 | #!/bin/bash |
83 | 62 | set -e |
84 | 63 |
|
@@ -110,96 +89,19 @@ if [ "$KILL_MODE" = "true" ]; then |
110 | 89 | echo "" |
111 | 90 | fi |
112 | 91 |
|
113 | | -# Handle different authentication options |
114 | | -if [ "$AUTH_OPTION" = "3" ]; then |
115 | | - echo "Skipping all repository operations as requested..." |
116 | | - if [ ! -d ~/llm-stylometry ]; then |
117 | | - echo "Error: Repository not found at ~/llm-stylometry" |
118 | | - echo "Please choose option 1 or 2 to clone the repository first." |
119 | | - exit 1 |
120 | | - fi |
| 92 | +# Check if repository exists |
| 93 | +if [ -d ~/llm-stylometry ]; then |
| 94 | + echo "Repository exists. Updating..." |
121 | 95 | cd ~/llm-stylometry |
122 | | - echo "Using existing repository without updates" |
123 | | -else |
124 | | - # Configure Git to use credential caching to avoid repeated auth prompts |
125 | | - git config --global credential.helper cache |
126 | | - git config --global credential.helper 'cache --timeout=3600' |
127 | | -
|
128 | | - # Set up GitHub token authentication if provided (only for option 2) |
129 | | - if [ "$AUTH_OPTION" = "2" ] && [ -n "$GH_TOKEN" ] && [ -n "$GH_USER" ]; then |
130 | | - echo "Setting up GitHub token authentication..." |
131 | | - git config --global url."https://${GH_USER}:${GH_TOKEN}@github.com/".insteadOf "https://github.com/" |
132 | | - fi |
133 | | -
|
134 | | - # Check if repo exists |
135 | | - if [ -d ~/llm-stylometry ]; then |
136 | | - echo "Repository exists. Updating to latest version..." |
137 | | - cd ~/llm-stylometry |
138 | | -
|
139 | | - # Stash any local changes |
140 | | - if ! git diff --quiet || ! git diff --cached --quiet; then |
141 | | - echo "Stashing local changes..." |
142 | | - git stash |
143 | | - fi |
144 | | -
|
145 | | - # Determine authentication method |
146 | | - if [ "$AUTH_OPTION" = "1" ]; then |
147 | | - # Try SSH first for option 1 |
148 | | - if ssh -o BatchMode=yes -o ConnectTimeout=5 [email protected] 2>&1 | grep -q "successfully authenticated"; then |
149 | | - echo "Using SSH authentication..." |
150 | | - git remote set-url origin [email protected]:ContextLab/llm-stylometry.git |
151 | | - else |
152 | | - echo "SSH key not found or not authorized." |
153 | | - echo "Please ensure your SSH key is added to GitHub and try again." |
154 | | - exit 1 |
155 | | - fi |
156 | | - elif [ "$AUTH_OPTION" = "2" ]; then |
157 | | - # Use HTTPS with token for option 2 |
158 | | - echo "Using HTTPS with Personal Access Token..." |
159 | | - git remote set-url origin https://github.com/ContextLab/llm-stylometry.git |
160 | | -
|
161 | | - if [ -z "$GH_TOKEN" ] || [ -z "$GH_USER" ]; then |
162 | | - echo "GitHub credentials not provided. You'll be prompted during git operations." |
163 | | - echo "Note: Use your Personal Access Token as the password." |
164 | | - fi |
165 | | - fi |
166 | | -
|
167 | | - # Update repository |
168 | | - git fetch origin |
169 | | - git checkout main |
170 | | - git pull origin main |
| 96 | + git pull |
171 | 97 | echo "Repository updated successfully" |
172 | 98 | else |
173 | 99 | echo "Repository not found. Cloning..." |
174 | | -
|
175 | | - if [ "$AUTH_OPTION" = "1" ]; then |
176 | | - # Check if SSH key is available |
177 | | - if ssh -o BatchMode=yes -o ConnectTimeout=5 [email protected] 2>&1 | grep -q "successfully authenticated"; then |
178 | | - echo "Using SSH to clone repository..." |
179 | | - cd ~ |
180 | | - git clone [email protected]:ContextLab/llm-stylometry.git |
181 | | - else |
182 | | - echo "SSH key not found or not authorized." |
183 | | - echo "Please ensure your SSH key is added to GitHub and try again." |
184 | | - exit 1 |
185 | | - fi |
186 | | - elif [ "$AUTH_OPTION" = "2" ]; then |
187 | | - echo "Using HTTPS to clone repository..." |
188 | | - if [ -z "$GH_TOKEN" ] || [ -z "$GH_USER" ]; then |
189 | | - echo "GitHub credentials not configured. You'll be prompted." |
190 | | - echo "Username: Your GitHub username" |
191 | | - echo "Password: Your Personal Access Token (NOT your GitHub password)" |
192 | | - echo "Create a token at: https://github.com/settings/tokens" |
193 | | - echo "" |
194 | | - fi |
195 | | - cd ~ |
196 | | - git clone https://github.com/ContextLab/llm-stylometry.git |
197 | | - fi |
198 | | -
|
| 100 | + cd ~ |
| 101 | + git clone https://github.com/ContextLab/llm-stylometry.git |
199 | 102 | cd ~/llm-stylometry |
200 | 103 | echo "Repository cloned successfully" |
201 | | - fi |
202 | | -fi # End of AUTH_OPTION check |
| 104 | +fi |
203 | 105 |
|
204 | 106 | # Check for screen |
205 | 107 | if ! command -v screen &> /dev/null; then |
|
0 commit comments