- Refactored the dashboard html into seperate pages and all the necessary components - Added login and secured api routes / debugged getting system working on a tailnet. - added some functionality to the debugging and health endpoints - added in a new phone contact import and debugged.
101 lines
3.5 KiB
Bash
Executable File
101 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Update Termux SMS API Server on Android Device
|
|
# This script updates the Termux API server with improved error handling and higher message limits
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${GREEN}📱 Updating Termux SMS API Server${NC}"
|
|
echo "======================================"
|
|
|
|
# Configuration
|
|
ANDROID_IP="10.0.0.193"
|
|
ANDROID_PORT="8022"
|
|
ANDROID_USER="android-dev"
|
|
REMOTE_PATH="~/projects/sms-campaign-manager"
|
|
|
|
echo -e "${BLUE}📋 Configuration:${NC}"
|
|
echo " Android IP: $ANDROID_IP"
|
|
echo " SSH Port: $ANDROID_PORT"
|
|
echo " User: $ANDROID_USER"
|
|
echo " Remote Path: $REMOTE_PATH"
|
|
echo
|
|
|
|
# Check if Android device is reachable
|
|
echo -e "${BLUE}🔍 Checking Android device connectivity...${NC}"
|
|
if ! ping -c 1 $ANDROID_IP >/dev/null 2>&1; then
|
|
echo -e "${RED}❌ Cannot reach Android device at $ANDROID_IP${NC}"
|
|
exit 1
|
|
fi
|
|
echo -e "${GREEN}✅ Android device is reachable${NC}"
|
|
|
|
# Stop existing API server
|
|
echo -e "${BLUE}🛑 Stopping existing Termux API server...${NC}"
|
|
ssh -p $ANDROID_PORT $ANDROID_USER@$ANDROID_IP "pkill -f termux-sms-api-server.py || true"
|
|
sleep 2
|
|
|
|
# Copy updated server file
|
|
echo -e "${BLUE}📤 Uploading updated Termux API server...${NC}"
|
|
scp -P $ANDROID_PORT android/termux-sms-api-server.py $ANDROID_USER@$ANDROID_IP:$REMOTE_PATH/
|
|
|
|
# Set permissions
|
|
echo -e "${BLUE}🔧 Setting permissions...${NC}"
|
|
ssh -p $ANDROID_PORT $ANDROID_USER@$ANDROID_IP "chmod +x $REMOTE_PATH/termux-sms-api-server.py"
|
|
|
|
# Create logs directory
|
|
ssh -p $ANDROID_PORT $ANDROID_USER@$ANDROID_IP "mkdir -p ~/logs"
|
|
|
|
# Start updated API server
|
|
echo -e "${BLUE}🚀 Starting updated Termux API server...${NC}"
|
|
ssh -p $ANDROID_PORT $ANDROID_USER@$ANDROID_IP "cd $REMOTE_PATH && nohup python termux-sms-api-server.py > ~/logs/sms-api-startup.log 2>&1 &"
|
|
|
|
# Wait a moment for startup
|
|
sleep 3
|
|
|
|
# Check if server is running
|
|
echo -e "${BLUE}🔍 Checking if API server is running...${NC}"
|
|
if ssh -p $ANDROID_PORT $ANDROID_USER@$ANDROID_IP "pgrep -f termux-sms-api-server.py" >/dev/null; then
|
|
echo -e "${GREEN}✅ Termux API server is running${NC}"
|
|
else
|
|
echo -e "${RED}❌ Failed to start Termux API server${NC}"
|
|
echo -e "${YELLOW}📋 Check startup log:${NC}"
|
|
ssh -p $ANDROID_PORT $ANDROID_USER@$ANDROID_IP "cat ~/logs/sms-api-startup.log"
|
|
exit 1
|
|
fi
|
|
|
|
# Test API endpoint
|
|
echo -e "${BLUE}🧪 Testing API endpoint...${NC}"
|
|
if curl -s -f http://$ANDROID_IP:5001/health >/dev/null; then
|
|
echo -e "${GREEN}✅ API endpoint is responding${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠️ API endpoint may still be starting up${NC}"
|
|
fi
|
|
|
|
echo
|
|
echo -e "${GREEN}🎉 Update Complete!${NC}"
|
|
echo
|
|
echo -e "${BLUE}📊 What was updated:${NC}"
|
|
echo " ✅ Increased max message length from 160 to 1600 characters"
|
|
echo " ✅ Reduced rate limit delay from 2.0 to 1.0 seconds"
|
|
echo " ✅ Added contact list endpoints (termux-contact-list)"
|
|
echo " ✅ Added /api/contacts/test for JSON structure analysis"
|
|
echo " ✅ Added /api/contacts/list for fetching all contacts"
|
|
echo " ✅ Added detailed error logging and validation"
|
|
echo " ✅ Improved phone number cleaning"
|
|
echo " ✅ Better debugging information"
|
|
echo
|
|
echo -e "${BLUE}📋 Next steps:${NC}"
|
|
echo " 1. Rebuild Docker container: docker compose build"
|
|
echo " 2. Restart Docker container: docker compose up"
|
|
echo " 3. Test campaign again"
|
|
echo
|
|
echo -e "${BLUE}🔍 Check logs:${NC}"
|
|
echo " Android API logs: ssh -p 8022 android-dev@10.0.0.193 'tail -f ~/logs/sms-api.log'"
|
|
echo " Docker logs: docker compose logs -f"
|