- 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.
123 lines
3.5 KiB
Bash
Executable File
123 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Deploy updated Termux API server to Android device
|
|
# This script copies the updated server file and sets the API secret
|
|
|
|
set -e # Exit on error
|
|
|
|
echo "========================================================================"
|
|
echo "📱 Deploying Updated Termux API Server to Android"
|
|
echo "========================================================================"
|
|
echo ""
|
|
|
|
# Configuration
|
|
ANDROID_USER="android-dev"
|
|
ANDROID_IP="100.107.173.66"
|
|
ANDROID_PORT="8022"
|
|
TERMUX_API_SECRET="aee141babda29fb0e68b5eb462c7feb5885f29b12c735d29ea337c360b00d351"
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${YELLOW}Step 1: Copying updated Termux API server...${NC}"
|
|
scp -P ${ANDROID_PORT} \
|
|
android/termux-sms-api-server.py \
|
|
${ANDROID_USER}@${ANDROID_IP}:~/projects/sms-campaign-manager/
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo -e "${GREEN}✅ Server file copied successfully${NC}"
|
|
else
|
|
echo -e "${RED}❌ Failed to copy server file${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${YELLOW}Step 2: Setting Termux API secret on Android...${NC}"
|
|
ssh -p ${ANDROID_PORT} ${ANDROID_USER}@${ANDROID_IP} << 'EOF'
|
|
cd ~/projects/sms-campaign-manager/
|
|
|
|
# Create .env file if it doesn't exist
|
|
touch .env
|
|
|
|
# Remove old SMS_API_SECRET if exists
|
|
grep -v "^SMS_API_SECRET=" .env > .env.tmp || true
|
|
mv .env.tmp .env
|
|
|
|
# Add new API secret
|
|
echo "SMS_API_SECRET=aee141babda29fb0e68b5eb462c7feb5885f29b12c735d29ea337c360b00d351" >> .env
|
|
|
|
echo "✅ API secret configured"
|
|
EOF
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo -e "${GREEN}✅ API secret configured successfully${NC}"
|
|
else
|
|
echo -e "${RED}❌ Failed to configure API secret${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${YELLOW}Step 3: Restarting Termux SMS API service...${NC}"
|
|
ssh -p ${ANDROID_PORT} ${ANDROID_USER}@${ANDROID_IP} << 'EOF'
|
|
# Stop the service if running
|
|
pkill -f termux-sms-api-server.py || true
|
|
sleep 2
|
|
|
|
# Create necessary directories
|
|
cd ~/projects/sms-campaign-manager/
|
|
mkdir -p logs
|
|
mkdir -p /data/data/com.termux/files/home/logs
|
|
|
|
# Start the service
|
|
nohup python3 termux-sms-api-server.py > logs/sms-api.log 2>&1 &
|
|
|
|
sleep 3
|
|
|
|
# Check if it's running
|
|
if pgrep -f termux-sms-api-server.py > /dev/null; then
|
|
echo "✅ Termux SMS API service started successfully"
|
|
else
|
|
echo "❌ Failed to start service"
|
|
echo "Check logs: cat ~/projects/sms-campaign-manager/logs/sms-api.log"
|
|
exit 1
|
|
fi
|
|
EOF
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo -e "${GREEN}✅ Service restarted successfully${NC}"
|
|
else
|
|
echo -e "${RED}❌ Failed to restart service${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${YELLOW}Step 4: Testing Termux API health...${NC}"
|
|
sleep 2
|
|
response=$(curl -s http://${ANDROID_IP}:5001/health)
|
|
|
|
if echo "$response" | grep -q "healthy"; then
|
|
echo -e "${GREEN}✅ Termux API is healthy and responding${NC}"
|
|
echo "Response: $response"
|
|
else
|
|
echo -e "${RED}❌ Termux API health check failed${NC}"
|
|
echo "Response: $response"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "========================================================================"
|
|
echo -e "${GREEN}🎉 Deployment Complete!${NC}"
|
|
echo "========================================================================"
|
|
echo ""
|
|
echo "Termux API Server Status:"
|
|
echo " - Server: http://${ANDROID_IP}:5001"
|
|
echo " - Health: http://${ANDROID_IP}:5001/health"
|
|
echo " - API Secret: Configured and active"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Restart your Docker container: docker-compose restart"
|
|
echo " 2. Test the connection from your homelab server"
|
|
echo ""
|