#!/bin/bash
. /home/ROULETTE/common.config #here is configuration of ROULETTE and FC5 locations

#if another instance of this iscrpt is already running, exit
#for pid in $(pidof -x $0); do
#    if [ $pid != $$ ]; then
#        echo "[$(date)] : $0 : Process is already running with PID $pid"
#        exit 1
#    fi
#done

ROULETTE=/home/ROULETTE

echo > /var/IGP/fast_reboot_disabled

#popravek za huerfanos
echo "UPDATE OR INSERT INTO LANG_MESSAGES (LANG_MSG_ID, LANG_MSG_SUB_ID, LANG_ID, LANG_MESSAGE) VALUES (690, 0, 23, 'Huerfanos a pleno');"|/home/ROULETTE/sqlexec.sh
echo "UPDATE OR INSERT INTO LANG_MESSAGES (LANG_MSG_ID, LANG_MSG_SUB_ID, LANG_ID, LANG_MESSAGE) VALUES (691, 0, 23, 'Huerfanos');"|/home/ROULETTE/sqlexec.sh
echo "UPDATE OR INSERT INTO LANG_MESSAGES (LANG_MSG_ID, LANG_MSG_SUB_ID, LANG_ID, LANG_MESSAGE) VALUES (726, 0, 23, 'Licencia valida hasta:');"|/home/ROULETTE/sqlexec.sh


echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'PLAYBACK_VOLUME', '', '', 11, NULL, '75');"|/home/ROULETTE/sqlexec.sh
echo "select RESULT from SET_PARAM('PLATFORM', 'UPDATE_ALL.sh', 'MUSIC_VOLUME', '', '', 11, NULL, '20');"|/home/ROULETTE/sqlexec.sh

echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'IGPV6_ILLUMINATION_MAX_PWM', '', '', 11, NULL, '128');"|/home/ROULETTE/sqlexec.sh
echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'IGPV6_SEMAPHORE_MAX_PWM', '', '', 11, NULL, '230');"|/home/ROULETTE/sqlexec.sh
echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'IGPV6_BUTTON_LIGHTS_MAX_PWM', '', '', 11, NULL, '179');"|/home/ROULETTE/sqlexec.sh
echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'SEMAPHORE_TYPE', '', '', 11, NULL, 'TrafficLight');"|/home/ROULETTE/sqlexec.sh

echo "select * from SET_PARAM('PLATFORM', 'UPDATE_ALL.sh', 'TOP_BACKGROUND_SHADER', NULL, NULL, 11, NULL, 'Animation/shader_godrays.json')" | /home/ROULETTE/sqlexec.sh
echo "select * from SET_PARAM('PLATFORM', 'UPDATE_ALL.sh', 'BACKGROUND_SHADER', NULL, NULL, 11, NULL, 'Animation/shader_bubbles.json')" | /home/ROULETTE/sqlexec.sh

echo "select * from SET_PARAM('PLATFORM', 'UPDATE_ALL.sh', 'FONT_SZ_CHIP', NULL, NULL, 11, NULL, '28')" | /home/ROULETTE/sqlexec.sh

#DOOR Switches on terminals
#echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'LOCK_IF_BIG_DOOR_OPEN', '', '', 11, NULL, '0');"|/home/ROULETTE/sqlexec.sh
#echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'LOCK_IF_SMALL_DOOR_OPEN', '', '', 11, NULL, '0');"|/home/ROULETTE/sqlexec.sh
#echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'LOCK_IF_LOGIC_DOOR_OPEN', '', '', 11, NULL, '0');"|/home/ROULETTE/sqlexec.sh
#echo "select RESULT from SET_PARAM('GLOBAL', 'UPDATE_ALL.sh', 'LOCK_IF_DEPOSIT_BOX_DOOR_OPEN', '', '', 11, NULL, '0');"|/home/ROULETTE/sqlexec.sh


#KEY_RIGHTS - for AGRO default
#1056768 -NO UID, over other hardware
echo "select RESULT from SET_PARAM('PLATFORM', 'UPDATE_ALL.sh', 'CLOSE_ADMIN_MENU_ON_KEY_OUT', '', '', 11, NULL, '1');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'ADMIN_KEY_TYPE', '', '', 11, NULL, '0');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_1_DESC', '', '', 11, NULL, 'Master Key');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_1_CODE', '', '', 11, NULL, '85-85-33-141-230-60');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_1_RIGHTS', '', '', 11, NULL, 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_1_COUNTER_ID', '', '', 11, 2, '2');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_2_DESC', '', '', 11, NULL, 'Audit');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_2_CODE', '', '', 11, NULL, '142-227-192-8-239-125');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_2_RIGHTS', '', '', 11, NULL, 'nnyyyyynyynynnyynyyynnnnnnnynnnnnnyynnnnnnnnnnnnn');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_2_COUNTER_ID', '', '', 11, 2, '2');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_3_DESC', '', '', 11, NULL, 'Attendant');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_3_CODE', '', '', 11, NULL, '199-113-96-132-247-190');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_3_RIGHTS', '', '', 11, NULL, 'nyyyynnnyynynnyynynnnnnnnnnynnnnnnyynnnnnnnnnnnnn');"|/home/ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'INSTALLER', 'KEY_3_COUNTER_ID', '', '', 11, 2, '2');"|/home/ROULETTE/sqlexec.sh


#wget -q http://igpupdates.4knh.com/PACKAGES_IGP/DEFAULT/V7.1/monitors.xml.ARGO_3X -O /home/user/.config/monitors.xml
#TODO wget -q http://igpupdates.4knh.com/PACKAGES_IGP/DEFAULT/V7.1/monitors.xml.ARGO_3X -O /home/user/.config/monitors.xml
#chown user:user /home/user/.config/monitors.xml
#chmod 664 /home/user/.config/monitors.xml


#sem premaknil v jurisdictional
#echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'IS_DOUBLE_ZERO', '', '', 11, 1, '1');" | $ROULETTE/sqlexec.sh
#echo "select result from SET_PARAM('GLOBAL', 'UPDATE', 'ZERO_NUMBER_OFFSET', '', '', 11, 18, '18');" | $ROULETTE/sqlexec.sh

#short GAME_DURATION
echo "select result from SET_PARAM('192.168.0.254','UPDATE','GAME_TIME',NULL,NULL,11,20,'15');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','GAME_TIME_RANDOM',NULL,NULL,11,10,'5');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','BET_PLACED_TIME',NULL,NULL,11,0,'0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','BET_PLACED_TIME_RANDOM',NULL,NULL,11,0,'0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','WARN_BEFORE_GAME_TIME_ELAPSES',NULL,NULL,11,4,'4');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','BETS_OPEN_MODE',NULL,NULL,11,1,'1');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','BALL_OUT_TIME',NULL,NULL,11,15,'15');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.254','UPDATE','SEARCH_FOR_BALL_IGNORES',NULL,NULL,11,0,'0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','STOP_GAME_IF_BALL_LAPS_COUNT_ERROR',NULL,NULL,11,1,'1');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','STOP_GAME_IF_WIN_KNOWN_WHILE_BETS_OPEN',NULL,NULL,11,1,'1');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254','UPDATE','MCNT_CENTRAL_ENABLE',NULL,NULL,11,0,'0');" | $ROULETTE/sqlexec.sh


echo "select result from SET_PARAM('WHEEL', 'CABINET', 'DONGLE_PORT', '', '', 11, 0, 'AUTO');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('WHEEL_1', 'CABINET', 'DONGLE_PORT', '', '', 11, 0, 'AUTO');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.254', 'UPDATE', 'STOP_GAME_IF_COUPOLA_OPEN', '', '', 11, 1, '1');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254', 'UPDATE', 'STOP_GAME_IF_BIG_DOOR_OPEN', '', '', 11, 0, '0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254', 'UPDATE', 'STOP_GAME_IF_SMALL_DOOR_OPEN', '', '', 11, 0, '0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254', 'UPDATE', 'STOP_GAME_IF_LOGIC_DOOR_OPEN', '', '', 11, 0, '0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.254', 'UPDATE', 'STOP_GAME_IF_DEPOSIT_BOX_DOOR_OPEN', '', '', 11, 0, '0');" | $ROULETTE/sqlexec.sh


#hardware config
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'ADMIN_KEY_TYPE', '', '', 11, 1052672, '1056768');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'ADMIN_KEY_PORT', '', '', 11, 0, '/dev/ttyUSB1');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'COIN_SYS_TYPE', '', '', 11, 0, '0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'COIN_SYS_PORT', '', '', 11, 0, 'AUTO');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'IOBOARD_TYPE', '', '', 11, 0, '8396800');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'IOBOARD_PORT', '', '', 11, 0, 'AUTO');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'TOUCH_TYPE', '', '', 11, 69632, '69632');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'TOUCH_PORT', '', '', 11, 0, '/dev/ttyS0');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'BILL_ACC_TYPE', '', '', 11, 278528, '278528');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'BILL_ACC_PORT', '', '', 11, 0, '/dev/ttyS0');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'TICKET_TYPE', '', '', 11, 0, '0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'TICKET_PORT', '', '', 11, 0, 'AUTO');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'KEYBOARD_TYPE', '', '', 11, 0, '0');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'KEYBOARD_PORT', '', '', 11, 0, 'AUTO');" | $ROULETTE/sqlexec.sh

echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'ONLINE_SYSTEM_TYPE', '', '', 11, 2101248, '2101248');" | $ROULETTE/sqlexec.sh
echo "select result from SET_PARAM('192.168.0.0', 'UPDATE', 'ONLINE_SYSTEM_PORT', '', '', 11, 0, 'IGPLATFORMV6');" | $ROULETTE/sqlexec.sh
