#!/bin/bash

# 載入 gamerc
source ~/.gamerc

$HOME/bin/parser_lua_text $TRANSLATED_INI_UPLOAD_DIR_EN/en_textindexquery.lua --vals-only > /tmp/en_textindex.csv

# 對應 CSV 同步到 Ctrl 機, 並更新到 en_textindex
rsync -avz /tmp/en_textindex.csv ctrl:/tmp

ssh ctrl "psql -U postgres WebTool -c \"CREATE TABLE IF NOT EXISTS en_textindex (id integer primary key, val text);\""
ssh ctrl "psql -U postgres WebTool -c \"TRUNCATE en_textindex;\""
ssh ctrl "psql -U postgres WebTool -c \"COPY en_textindex (id,val) FROM '/tmp/en_textindex.csv' csv\""
