scalperBot / monitor_ip_production.sh
nexusbert's picture
Upload 47 files
5116a2e verified
#!/bin/bash
# Production IP monitoring script
SPACE_URL='nexusbert-scalperbot.hf.space'
LOG_FILE='logs/ip_monitor.log'
# Get current IP
CURRENT_IP=$(ping -c 1 $SPACE_URL 2>/dev/null | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | head -1)
if [ -z "$CURRENT_IP" ]; then
echo "$(date): ERROR - Could not resolve $SPACE_URL" >> $LOG_FILE
exit 1
fi
# Check if IP changed
PREVIOUS_IP=$(tail -1 $LOG_FILE 2>/dev/null | grep -oE 'IP: ([0-9]{1,3}\.){3}[0-9]{1,3}' | cut -d' ' -f2 || echo 'none')
if [ "$CURRENT_IP" != "$PREVIOUS_IP" ]; then
echo "$(date): 🚨 IP CHANGED from $PREVIOUS_IP to $CURRENT_IP" >> $LOG_FILE
echo "$(date): πŸ“ UPDATE BYBIT WHITELIST: $CURRENT_IP" >> $LOG_FILE
# Send Telegram alert (uncomment and configure)
# curl -s "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \
# -d "chat_id=$TELEGRAM_CHAT_ID" \
# -d "text=🚨 HF Space IP Changed: $CURRENT_IP - Update Bybit whitelist" 2>/dev/null || true
# Email alert (if configured)
# echo "HF Space IP changed to: $CURRENT_IP" | mail -s "IP Change Alert" your@email.com 2>/dev/null || true
else
echo "$(date): βœ… IP stable: $CURRENT_IP" >> $LOG_FILE
fi