#!/bin/bash
source $HOME/.gamerc

PORT="17777"
PASS="0KjaM85BjfqjA"

for machine in $(print_hosts GAMEDB); do
    SET_ID="10"
    IP="10.10.30.2"
    PORT="17777"
    CHAR_IDS=$(ssh -o StrictHostKeyChecking=no TEST "psql -U postgres ${GAME_DB_NAME}${SET_ID} -qAt -c \"SELECT id FROM player_characters WHERE (last_login_time > 0 AND logout_time IS NULL) OR (last_login_time > 0 AND logout_time < last_login_time);\"")
    for char_id in ${CHAR_IDS}; do
        echo "curl http://127.0.0.1/cgi-bin/CGIAgent.fcgi?$IP,$PORT,$PASS,ban+$char_id+5+n1tw_first_maintenance"
        curl http://127.0.0.1/cgi-bin/CGIAgent.fcgi?$IP,$PORT,$PASS,ban+$char_id+5+n1tw_first_maintenance
        sleep 0.5
    done
done
