A community based topic aggregation platform built on atproto
1#!/bin/bash
2# Setup adb reverse port forwarding for mobile testing
3# This allows the mobile app to access localhost services on the dev machine
4
5set -e
6
7# Colors
8GREEN='\033[0;32m'
9CYAN='\033[0;36m'
10YELLOW='\033[1;33m'
11RED='\033[0;31m'
12NC='\033[0m' # No Color
13
14echo -e "${CYAN}📱 Setting up Android port forwarding for Coves mobile testing...${NC}"
15echo ""
16
17# Check if adb is available
18if ! command -v adb &> /dev/null; then
19 echo -e "${RED}✗ adb not found${NC}"
20 echo "Install Android SDK Platform Tools: https://developer.android.com/studio/releases/platform-tools"
21 exit 1
22fi
23
24# Check if device is connected
25DEVICES=$(adb devices | grep -v "List" | grep "device$" | wc -l)
26if [ "$DEVICES" -eq 0 ]; then
27 echo -e "${RED}✗ No Android devices connected${NC}"
28 echo "Connect a device via USB or start an emulator"
29 exit 1
30fi
31
32echo -e "${YELLOW}Setting up port forwarding...${NC}"
33
34# Forward ports from Android device to localhost
35adb reverse tcp:3000 tcp:3001 # PDS (internal port in DID document)
36adb reverse tcp:3001 tcp:3001 # PDS (external port)
37adb reverse tcp:3002 tcp:3002 # PLC Directory
38adb reverse tcp:8080 tcp:8080 # Caddy proxy (OAuth callbacks route through here)
39adb reverse tcp:8081 tcp:8081 # AppView
40
41echo ""
42echo -e "${GREEN}✅ Port forwarding configured successfully!${NC}"
43echo ""
44echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
45echo -e "${CYAN} PORT FORWARDING ${NC}"
46echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
47echo ""
48echo -e "${GREEN}PDS (3000):${NC} localhost:3001 → device:3000 ${YELLOW}(DID document port)${NC}"
49echo -e "${GREEN}PDS (3001):${NC} localhost:3001 → device:3001"
50echo -e "${GREEN}PLC (3002):${NC} localhost:3002 → device:3002"
51echo -e "${GREEN}Caddy (8080):${NC} localhost:8080 → device:8080 ${YELLOW}(OAuth callbacks)${NC}"
52echo -e "${GREEN}AppView (8081):${NC} localhost:8081 → device:8081"
53echo ""
54echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
55echo ""
56echo -e "${CYAN}📱 Next Steps:${NC}"
57echo ""
58echo -e "1. Mobile app is already configured for localhost (environment_config.dart)"
59echo ""
60echo -e "2. Run mobile app:"
61echo -e " ${YELLOW}cd /home/bretton/Code/coves-mobile${NC}"
62echo -e " ${YELLOW}flutter run --dart-define=ENVIRONMENT=local${NC}"
63echo ""
64echo -e "3. Login with:"
65echo -e " Handle: ${CYAN}charlie.local.coves.dev${NC}"
66echo -e " Password: ${CYAN}charliepass123${NC}"
67echo ""
68echo -e "${YELLOW}💡 Note: Port forwarding persists until device disconnects or you run:${NC}"
69echo -e "${YELLOW} adb reverse --remove-all${NC}"
70echo ""