#!/bin/bash

# 載入 gamerc
source ~/.gamerc

$HOME/bin/parser_lua_text $TRANSLATED_INI_UPLOAD_DIR_CN/cn_textindexquery.lua --vals-only > /tmp/cn_textindex.csv

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

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