mact-cli 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mact_cli-1.0.0/.docs/ADMIN_CLI_GUIDE.md +612 -0
- mact_cli-1.0.0/.docs/ARCHITECTURE_NOTES.md +304 -0
- mact_cli-1.0.0/.docs/CLIENT_INSTALLATION_GUIDE.md +659 -0
- mact_cli-1.0.0/.docs/CLI_COMPARISON.md +356 -0
- mact_cli-1.0.0/.docs/CLI_QUICKREF.md +215 -0
- mact_cli-1.0.0/.docs/CLI_SYNTAX_UPDATE.md +149 -0
- mact_cli-1.0.0/.docs/DEMONSTRATION_GUIDE.md +597 -0
- mact_cli-1.0.0/.docs/DEPLOYMENT.md +609 -0
- mact_cli-1.0.0/.docs/DEPLOYMENT_NEXT_STEPS.md +447 -0
- mact_cli-1.0.0/.docs/DEPLOYMENT_ROADMAP.md +519 -0
- mact_cli-1.0.0/.docs/DOCUMENTATION_CLEANUP.md +109 -0
- mact_cli-1.0.0/.docs/DOCUMENTATION_INDEX.md +423 -0
- mact_cli-1.0.0/.docs/E2E_TEST_REPORT.md +342 -0
- mact_cli-1.0.0/.docs/FIXES_COMPLETE.md +152 -0
- mact_cli-1.0.0/.docs/FRP_AUTOMATION.md +300 -0
- mact_cli-1.0.0/.docs/GITHUB_SETUP_GUIDE.md +618 -0
- mact_cli-1.0.0/.docs/INSTALL.md +341 -0
- mact_cli-1.0.0/.docs/PRODUCTION_DEPLOYMENT_GUIDE.md +972 -0
- mact_cli-1.0.0/.docs/PROGRESS_LOG.md +613 -0
- mact_cli-1.0.0/.docs/PROJECT_COMPLETION_REPORT.md +889 -0
- mact_cli-1.0.0/.docs/PROJECT_CONTEXT.md +250 -0
- mact_cli-1.0.0/.docs/QUICK_START.md +292 -0
- mact_cli-1.0.0/.docs/SECURITY_DIAGRAM.md +243 -0
- mact_cli-1.0.0/.docs/SECURITY_IMPLEMENTATION_PLAN.md +127 -0
- mact_cli-1.0.0/.docs/SECURITY_MODEL.md +492 -0
- mact_cli-1.0.0/.docs/SECURITY_THREAT_MODEL.md +592 -0
- mact_cli-1.0.0/.docs/TUNNEL_FIXES_SUMMARY.md +188 -0
- mact_cli-1.0.0/.docs/UI_REDESIGN_SUMMARY.md +123 -0
- mact_cli-1.0.0/.docs/VALIDATION_REPORT.md +349 -0
- mact_cli-1.0.0/.docs/WEBSOCKET_DESIGN.md +402 -0
- mact_cli-1.0.0/.docs/WORK_COMPLETION_SUMMARY.md +708 -0
- mact_cli-1.0.0/INSTALL.md +239 -0
- mact_cli-1.0.0/MANIFEST.in +21 -0
- mact_cli-1.0.0/PKG-INFO +324 -0
- mact_cli-1.0.0/README.md +294 -0
- mact_cli-1.0.0/cli/__init__.py +1 -0
- mact_cli-1.0.0/cli/cli.py +380 -0
- mact_cli-1.0.0/cli/frpc_manager.py +132 -0
- mact_cli-1.0.0/cli/hook.py +45 -0
- mact_cli-1.0.0/cli/room_config.py +90 -0
- mact_cli-1.0.0/deployment/mact-backend.env.template +21 -0
- mact_cli-1.0.0/deployment/mact-frps.env.template +8 -0
- mact_cli-1.0.0/deployment/mact-proxy.env.template +17 -0
- mact_cli-1.0.0/mact_cli.egg-info/PKG-INFO +324 -0
- mact_cli-1.0.0/mact_cli.egg-info/SOURCES.txt +62 -0
- mact_cli-1.0.0/mact_cli.egg-info/dependency_links.txt +1 -0
- mact_cli-1.0.0/mact_cli.egg-info/entry_points.txt +2 -0
- mact_cli-1.0.0/mact_cli.egg-info/not-zip-safe +1 -0
- mact_cli-1.0.0/mact_cli.egg-info/requires.txt +1 -0
- mact_cli-1.0.0/mact_cli.egg-info/top_level.txt +1 -0
- mact_cli-1.0.0/pyproject.toml +44 -0
- mact_cli-1.0.0/setup.cfg +4 -0
- mact_cli-1.0.0/setup.py +67 -0
- mact_cli-1.0.0/third_party/frp/.pytest_cache/.gitignore +2 -0
- mact_cli-1.0.0/third_party/frp/.pytest_cache/CACHEDIR.TAG +4 -0
- mact_cli-1.0.0/third_party/frp/.pytest_cache/README.md +8 -0
- mact_cli-1.0.0/third_party/frp/.pytest_cache/v/cache/nodeids +1 -0
- mact_cli-1.0.0/third_party/frp/LICENSE +202 -0
- mact_cli-1.0.0/third_party/frp/frpc +0 -0
- mact_cli-1.0.0/third_party/frp/frpc.toml +9 -0
- mact_cli-1.0.0/third_party/frp/frps +0 -0
- mact_cli-1.0.0/third_party/frp/frps.toml +1 -0
- mact_cli-1.0.0/third_party/frp/mact.frpc.toml +10 -0
- mact_cli-1.0.0/third_party/frp/mact.frps.toml +7 -0
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
# MACT Admin CLI Guide
|
|
2
|
+
|
|
3
|
+
**Last Updated:** November 8, 2025
|
|
4
|
+
**Version:** 1.0
|
|
5
|
+
**Target Audience:** Server administrators managing the DigitalOcean droplet
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The **MACT Admin CLI** (`mact-admin`) is a server-side administration tool for managing rooms, users, and system health on the production server. It provides commands that should only be run by administrators with SSH access to the DigitalOcean droplet.
|
|
12
|
+
|
|
13
|
+
### Key Differences from Client CLI
|
|
14
|
+
|
|
15
|
+
| Feature | Client CLI (`mact`) | Admin CLI (`mact-admin`) |
|
|
16
|
+
|---------|---------------------|--------------------------|
|
|
17
|
+
| **Users** | Developers creating rooms | Server administrators |
|
|
18
|
+
| **Installation** | `pip install` from GitHub | Pre-installed on server |
|
|
19
|
+
| **Access** | Public (anyone can use) | Requires SSH + admin token |
|
|
20
|
+
| **Purpose** | Create/join rooms | Delete rooms, view stats, manage system |
|
|
21
|
+
| **Location** | Developer's laptop | DigitalOcean droplet only |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation on Server
|
|
26
|
+
|
|
27
|
+
The admin CLI is automatically installed when you set up the MACT server:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# During initial deployment
|
|
31
|
+
cd /opt/mact
|
|
32
|
+
source venv/bin/activate
|
|
33
|
+
pip install -e .
|
|
34
|
+
|
|
35
|
+
# Verify installation
|
|
36
|
+
mact-admin --help
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Setting Admin Authentication Token
|
|
40
|
+
|
|
41
|
+
The admin CLI requires an authentication token to access protected endpoints:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Edit the backend environment file
|
|
45
|
+
sudo nano /opt/mact/deployment/mact-backend.env
|
|
46
|
+
|
|
47
|
+
# Add this line (generate a secure random token)
|
|
48
|
+
ADMIN_AUTH_TOKEN=your-secure-random-token-here
|
|
49
|
+
|
|
50
|
+
# Restart backend to apply changes
|
|
51
|
+
sudo systemctl restart mact-backend
|
|
52
|
+
|
|
53
|
+
# Set the token for CLI usage
|
|
54
|
+
export ADMIN_AUTH_TOKEN=your-secure-random-token-here
|
|
55
|
+
|
|
56
|
+
# Add to your ~/.bashrc for persistence
|
|
57
|
+
echo 'export ADMIN_AUTH_TOKEN=your-secure-random-token-here' >> ~/.bashrc
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Generating a secure token:**
|
|
61
|
+
```bash
|
|
62
|
+
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Command Reference
|
|
68
|
+
|
|
69
|
+
### Rooms Management
|
|
70
|
+
|
|
71
|
+
#### `mact-admin rooms list`
|
|
72
|
+
List all rooms in the system with participant count and commit history.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
mact-admin rooms list
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Output:**
|
|
79
|
+
```
|
|
80
|
+
📊 Total Rooms: 3
|
|
81
|
+
|
|
82
|
+
Room Code Participants Commits Active Developer
|
|
83
|
+
===========================================================================
|
|
84
|
+
telegram-bot 2 15 alice
|
|
85
|
+
weather-app 1 8 bob
|
|
86
|
+
chat-server 0 3 None
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
#### `mact-admin rooms info <room-code>`
|
|
92
|
+
Show detailed information about a specific room.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
mact-admin rooms info telegram-bot
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Output:**
|
|
99
|
+
```
|
|
100
|
+
📦 Room: telegram-bot
|
|
101
|
+
============================================================
|
|
102
|
+
Active Developer: alice
|
|
103
|
+
Latest Commit: abc123def456
|
|
104
|
+
Total Commits: 15
|
|
105
|
+
|
|
106
|
+
Participants (2):
|
|
107
|
+
🟢 alice
|
|
108
|
+
⚪ bob
|
|
109
|
+
|
|
110
|
+
Recent Commits (last 10):
|
|
111
|
+
Time Developer Hash Message
|
|
112
|
+
-------------------------------------------------------------------------------
|
|
113
|
+
2025-11-08 14:30:15 alice abc123de Add webhook handler
|
|
114
|
+
2025-11-08 14:15:42 bob def456ab Fix message parsing
|
|
115
|
+
...
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
#### `mact-admin rooms delete <room-code>`
|
|
121
|
+
Delete a specific room (with confirmation prompt).
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
mact-admin rooms delete chat-server
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Confirmation:**
|
|
128
|
+
```
|
|
129
|
+
⚠️ Are you sure you want to delete room 'chat-server'?
|
|
130
|
+
This will remove all participants and commit history.
|
|
131
|
+
Type 'yes' to confirm: yes
|
|
132
|
+
✅ Room 'chat-server' deleted successfully.
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Skip confirmation (use with caution):**
|
|
136
|
+
```bash
|
|
137
|
+
mact-admin rooms delete chat-server --force
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
#### `mact-admin rooms cleanup`
|
|
143
|
+
Delete all empty rooms (rooms with no participants).
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
mact-admin rooms cleanup
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Output:**
|
|
150
|
+
```
|
|
151
|
+
🧹 Found 2 empty room(s) to clean up:
|
|
152
|
+
- old-project
|
|
153
|
+
- test-room
|
|
154
|
+
|
|
155
|
+
Proceed with cleanup? (yes/no): yes
|
|
156
|
+
✅ Deleted: old-project
|
|
157
|
+
✅ Deleted: test-room
|
|
158
|
+
|
|
159
|
+
✅ Cleanup complete. Deleted 2/2 rooms.
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Auto-confirm:**
|
|
163
|
+
```bash
|
|
164
|
+
mact-admin rooms cleanup --force
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### Users Management
|
|
170
|
+
|
|
171
|
+
#### `mact-admin users list`
|
|
172
|
+
List all active users across all rooms.
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
mact-admin users list
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Output:**
|
|
179
|
+
```
|
|
180
|
+
👥 Total Active Users: 5
|
|
181
|
+
|
|
182
|
+
Developer ID Rooms Room Codes
|
|
183
|
+
===========================================================================
|
|
184
|
+
alice 3 telegram-bot, weather-app, api-server
|
|
185
|
+
bob 2 telegram-bot, chat-server
|
|
186
|
+
charlie 1 weather-app
|
|
187
|
+
dave 1 api-server
|
|
188
|
+
eve 1 chat-server
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
#### `mact-admin users kick <developer-id> <room-code>`
|
|
194
|
+
Remove a specific user from a room.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
mact-admin users kick bob telegram-bot
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Use cases:**
|
|
201
|
+
- User is causing issues (committing spam, etc.)
|
|
202
|
+
- User requested to be removed but can't access their machine
|
|
203
|
+
- Emergency room cleanup
|
|
204
|
+
|
|
205
|
+
**With force flag:**
|
|
206
|
+
```bash
|
|
207
|
+
mact-admin users kick bob telegram-bot --force
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### System Management
|
|
213
|
+
|
|
214
|
+
#### `mact-admin system health`
|
|
215
|
+
Check the health of all MACT services.
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
mact-admin system health
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Output:**
|
|
222
|
+
```
|
|
223
|
+
🏥 MACT System Health Check
|
|
224
|
+
|
|
225
|
+
============================================================
|
|
226
|
+
|
|
227
|
+
1. Backend API (Port 5000)
|
|
228
|
+
✅ Status: healthy
|
|
229
|
+
📊 Rooms: 5
|
|
230
|
+
|
|
231
|
+
2. Routing Proxy (Port 9000)
|
|
232
|
+
✅ Status: Healthy
|
|
233
|
+
|
|
234
|
+
3. Systemd Services
|
|
235
|
+
✅ mact-backend: Running
|
|
236
|
+
✅ mact-proxy: Running
|
|
237
|
+
✅ mact-frps: Running
|
|
238
|
+
|
|
239
|
+
4. Nginx
|
|
240
|
+
✅ nginx: Running
|
|
241
|
+
|
|
242
|
+
============================================================
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**What it checks:**
|
|
246
|
+
- Backend API connectivity and room count
|
|
247
|
+
- Proxy routing service
|
|
248
|
+
- All systemd services (backend, proxy, frps)
|
|
249
|
+
- Nginx reverse proxy
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
#### `mact-admin system stats`
|
|
254
|
+
Show usage statistics and metrics.
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
mact-admin system stats
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Output:**
|
|
261
|
+
```
|
|
262
|
+
📊 MACT System Statistics
|
|
263
|
+
|
|
264
|
+
============================================================
|
|
265
|
+
Total Rooms: 8
|
|
266
|
+
Active: 6
|
|
267
|
+
Empty: 2
|
|
268
|
+
|
|
269
|
+
Total Participants: 12
|
|
270
|
+
Total Commits: 143
|
|
271
|
+
|
|
272
|
+
Average per room:
|
|
273
|
+
Participants: 1.5
|
|
274
|
+
Commits: 17.9
|
|
275
|
+
|
|
276
|
+
============================================================
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Use cases:**
|
|
280
|
+
- Monthly reports
|
|
281
|
+
- Resource planning
|
|
282
|
+
- Monitoring system growth
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
#### `mact-admin system logs <service>`
|
|
287
|
+
View logs for a specific service using journalctl.
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
# View last 50 lines (default)
|
|
291
|
+
mact-admin system logs backend
|
|
292
|
+
|
|
293
|
+
# View last 100 lines
|
|
294
|
+
mact-admin system logs backend -n 100
|
|
295
|
+
|
|
296
|
+
# Follow logs in real-time (like tail -f)
|
|
297
|
+
mact-admin system logs proxy -f
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Available services:**
|
|
301
|
+
- `backend` - Coordination backend (Flask)
|
|
302
|
+
- `proxy` - Routing proxy (Starlette)
|
|
303
|
+
- `frps` - FRP server
|
|
304
|
+
|
|
305
|
+
**Output example:**
|
|
306
|
+
```
|
|
307
|
+
📋 Showing logs for mact-backend (last 50 lines)
|
|
308
|
+
|
|
309
|
+
Nov 08 14:30:15 mact systemd[1]: Started MACT Backend Service.
|
|
310
|
+
Nov 08 14:30:16 mact python[1234]: INFO: Backend started on port 5000
|
|
311
|
+
Nov 08 14:35:20 mact python[1234]: POST /rooms/create - 201
|
|
312
|
+
Nov 08 14:36:45 mact python[1234]: POST /report-commit - 200
|
|
313
|
+
...
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Stop following logs:**
|
|
317
|
+
Press `Ctrl+C`
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Common Administrative Tasks
|
|
322
|
+
|
|
323
|
+
### 1. Clean Up Empty Rooms (Weekly)
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Check for empty rooms
|
|
327
|
+
mact-admin rooms list | grep "0 "
|
|
328
|
+
|
|
329
|
+
# Clean them up
|
|
330
|
+
mact-admin rooms cleanup --force
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### 2. Monitor System Health (Daily)
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
# Quick health check
|
|
339
|
+
mact-admin system health
|
|
340
|
+
|
|
341
|
+
# Check detailed stats
|
|
342
|
+
mact-admin system stats
|
|
343
|
+
|
|
344
|
+
# If issues found, view logs
|
|
345
|
+
mact-admin system logs backend -n 200
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
### 3. Remove Inactive Room
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# Get room details
|
|
354
|
+
mact-admin rooms info old-project
|
|
355
|
+
|
|
356
|
+
# Confirm it's inactive (no recent commits)
|
|
357
|
+
# Delete it
|
|
358
|
+
mact-admin rooms delete old-project
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
### 4. Handle User Issues
|
|
364
|
+
|
|
365
|
+
**Scenario: User reports they can't access a room**
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
# Check room exists
|
|
369
|
+
mact-admin rooms info problematic-room
|
|
370
|
+
|
|
371
|
+
# Check if user is in the room
|
|
372
|
+
mact-admin users list | grep username
|
|
373
|
+
|
|
374
|
+
# View recent logs for clues
|
|
375
|
+
mact-admin system logs backend -n 100 | grep problematic-room
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
### 5. Emergency Room Deletion
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# If a room is causing issues (infinite redirects, etc.)
|
|
384
|
+
mact-admin rooms delete problem-room --force
|
|
385
|
+
|
|
386
|
+
# Restart services if needed
|
|
387
|
+
sudo systemctl restart mact-proxy
|
|
388
|
+
sudo systemctl restart mact-backend
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Security Best Practices
|
|
394
|
+
|
|
395
|
+
### 1. Protect the Admin Token
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
# Store token securely
|
|
399
|
+
chmod 600 ~/.bashrc # Ensure only you can read it
|
|
400
|
+
|
|
401
|
+
# Never commit token to git
|
|
402
|
+
# Never share token in chat/email
|
|
403
|
+
# Rotate token every 90 days
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
### 2. Limit SSH Access
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# Only allow key-based authentication
|
|
412
|
+
sudo nano /etc/ssh/sshd_config
|
|
413
|
+
# Set: PasswordAuthentication no
|
|
414
|
+
|
|
415
|
+
# Restart SSH
|
|
416
|
+
sudo systemctl restart sshd
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
### 3. Regular Audits
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
# Weekly: Check who's using the system
|
|
425
|
+
mact-admin users list
|
|
426
|
+
|
|
427
|
+
# Monthly: Review room activity
|
|
428
|
+
mact-admin system stats
|
|
429
|
+
|
|
430
|
+
# Quarterly: Clean up old rooms
|
|
431
|
+
mact-admin rooms cleanup
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Troubleshooting
|
|
437
|
+
|
|
438
|
+
### Error: "Authentication failed. Check ADMIN_AUTH_TOKEN"
|
|
439
|
+
|
|
440
|
+
**Problem:** The token is not set or incorrect.
|
|
441
|
+
|
|
442
|
+
**Solution:**
|
|
443
|
+
```bash
|
|
444
|
+
# Check if token is set
|
|
445
|
+
echo $ADMIN_AUTH_TOKEN
|
|
446
|
+
|
|
447
|
+
# If empty, set it
|
|
448
|
+
export ADMIN_AUTH_TOKEN=your-token-here
|
|
449
|
+
|
|
450
|
+
# Verify backend has the same token
|
|
451
|
+
sudo cat /opt/mact/deployment/mact-backend.env | grep ADMIN_AUTH_TOKEN
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
### Error: "Failed to fetch rooms: Connection refused"
|
|
457
|
+
|
|
458
|
+
**Problem:** Backend is not running.
|
|
459
|
+
|
|
460
|
+
**Solution:**
|
|
461
|
+
```bash
|
|
462
|
+
# Check backend status
|
|
463
|
+
sudo systemctl status mact-backend
|
|
464
|
+
|
|
465
|
+
# If inactive, start it
|
|
466
|
+
sudo systemctl start mact-backend
|
|
467
|
+
|
|
468
|
+
# View logs for errors
|
|
469
|
+
mact-admin system logs backend -n 100
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
### Command Not Found: `mact-admin`
|
|
475
|
+
|
|
476
|
+
**Problem:** Admin CLI not installed or not in PATH.
|
|
477
|
+
|
|
478
|
+
**Solution:**
|
|
479
|
+
```bash
|
|
480
|
+
# Reinstall from source
|
|
481
|
+
cd /opt/mact
|
|
482
|
+
source venv/bin/activate
|
|
483
|
+
pip install -e .
|
|
484
|
+
|
|
485
|
+
# Verify
|
|
486
|
+
which mact-admin
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
### Logs Show "Permission Denied"
|
|
492
|
+
|
|
493
|
+
**Problem:** Journalctl requires sudo for some services.
|
|
494
|
+
|
|
495
|
+
**Solution:**
|
|
496
|
+
```bash
|
|
497
|
+
# Add your user to systemd-journal group
|
|
498
|
+
sudo usermod -aG systemd-journal $USER
|
|
499
|
+
|
|
500
|
+
# Log out and back in
|
|
501
|
+
exit
|
|
502
|
+
# SSH back in
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## Integration with Monitoring
|
|
508
|
+
|
|
509
|
+
### Cron Jobs for Automated Maintenance
|
|
510
|
+
|
|
511
|
+
```bash
|
|
512
|
+
# Edit crontab
|
|
513
|
+
crontab -e
|
|
514
|
+
|
|
515
|
+
# Add weekly cleanup (Sundays at 3 AM)
|
|
516
|
+
0 3 * * 0 /opt/mact/venv/bin/mact-admin rooms cleanup --force >> /var/log/mact-cleanup.log 2>&1
|
|
517
|
+
|
|
518
|
+
# Add daily health check (every day at midnight)
|
|
519
|
+
0 0 * * * /opt/mact/venv/bin/mact-admin system health >> /var/log/mact-health.log 2>&1
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
### Simple Monitoring Script
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
#!/bin/bash
|
|
528
|
+
# /opt/mact/scripts/monitor.sh
|
|
529
|
+
|
|
530
|
+
source /opt/mact/venv/bin/activate
|
|
531
|
+
export ADMIN_AUTH_TOKEN=your-token-here
|
|
532
|
+
|
|
533
|
+
# Check health
|
|
534
|
+
if ! mact-admin system health | grep -q "✅"; then
|
|
535
|
+
echo "ALERT: MACT system unhealthy!" | mail -s "MACT Alert" admin@yourdomain.com
|
|
536
|
+
fi
|
|
537
|
+
|
|
538
|
+
# Check disk space
|
|
539
|
+
DISK_USAGE=$(df -h / | tail -1 | awk '{print $5}' | sed 's/%//')
|
|
540
|
+
if [ $DISK_USAGE -gt 80 ]; then
|
|
541
|
+
echo "ALERT: Disk usage at ${DISK_USAGE}%" | mail -s "MACT Disk Alert" admin@yourdomain.com
|
|
542
|
+
fi
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
**Make it executable:**
|
|
546
|
+
```bash
|
|
547
|
+
chmod +x /opt/mact/scripts/monitor.sh
|
|
548
|
+
|
|
549
|
+
# Run every hour
|
|
550
|
+
crontab -e
|
|
551
|
+
# Add: 0 * * * * /opt/mact/scripts/monitor.sh
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
---
|
|
555
|
+
|
|
556
|
+
## FAQ
|
|
557
|
+
|
|
558
|
+
### Q: Can I use `mact-admin` from my laptop?
|
|
559
|
+
**A:** No. The admin CLI must run on the DigitalOcean droplet where the backend is running. It connects to `localhost:5000` by default.
|
|
560
|
+
|
|
561
|
+
### Q: What happens when I delete a room?
|
|
562
|
+
**A:** All room data is immediately deleted from memory:
|
|
563
|
+
- Participant list removed
|
|
564
|
+
- Commit history deleted
|
|
565
|
+
- Public URL becomes inactive
|
|
566
|
+
- Users can create a new room with the same name
|
|
567
|
+
|
|
568
|
+
### Q: Can I recover a deleted room?
|
|
569
|
+
**A:** No. MACT uses in-memory storage for Unit 1 (PoC). Once deleted, data is gone forever. Be careful with the `delete` command.
|
|
570
|
+
|
|
571
|
+
### Q: How do I export room data before deletion?
|
|
572
|
+
**A:** Currently not supported in Unit 1. You can manually copy commit history:
|
|
573
|
+
```bash
|
|
574
|
+
curl "http://localhost:5000/rooms/my-room/commits" > room-backup.json
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### Q: Why use `mact-admin` instead of direct API calls?
|
|
578
|
+
**A:**
|
|
579
|
+
- Better UX (formatted output, colors, confirmations)
|
|
580
|
+
- Safer (prevents accidental deletions)
|
|
581
|
+
- Easier to remember commands
|
|
582
|
+
- Includes system checks beyond the API (journalctl, systemd)
|
|
583
|
+
|
|
584
|
+
### Q: Can multiple admins use the CLI simultaneously?
|
|
585
|
+
**A:** Yes, as long as they all have the same `ADMIN_AUTH_TOKEN` set.
|
|
586
|
+
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
## Related Documentation
|
|
590
|
+
|
|
591
|
+
- [PRODUCTION_DEPLOYMENT_GUIDE.md](.docs/PRODUCTION_DEPLOYMENT_GUIDE.md) - Initial server setup
|
|
592
|
+
- [CLIENT_INSTALLATION_GUIDE.md](.docs/CLIENT_INSTALLATION_GUIDE.md) - How developers install `mact`
|
|
593
|
+
- [TROUBLESHOOTING_GUIDE.md](.docs/TROUBLESHOOTING_GUIDE.md) - General debugging
|
|
594
|
+
- [QUICK_START.md](.docs/QUICK_START.md) - 30-second overview
|
|
595
|
+
|
|
596
|
+
---
|
|
597
|
+
|
|
598
|
+
## Support
|
|
599
|
+
|
|
600
|
+
For issues with the admin CLI:
|
|
601
|
+
1. Check `/var/log/mact-*.log` files
|
|
602
|
+
2. Run `mact-admin system health` to diagnose
|
|
603
|
+
3. View service logs with `mact-admin system logs backend`
|
|
604
|
+
4. Consult [TROUBLESHOOTING_GUIDE.md](.docs/TROUBLESHOOTING_GUIDE.md)
|
|
605
|
+
|
|
606
|
+
For code changes or feature requests:
|
|
607
|
+
- GitHub Repository: https://github.com/YOUR_USERNAME/M-ACT
|
|
608
|
+
- Issues: https://github.com/YOUR_USERNAME/M-ACT/issues
|
|
609
|
+
|
|
610
|
+
---
|
|
611
|
+
|
|
612
|
+
**Remember:** With great power comes great responsibility. The admin CLI can delete rooms and kick users instantly. Always double-check before confirming destructive operations.
|