feat: add inspect-shz-logs skill for log inspection and monitoring
- Implemented a new skill to inspect and follow SHZ backend logs with bounded read-only commands. - Added scripts for viewing local and production logs, including options for following logs. - Created references for log locations and usage guidelines. feat: add query-shz-highgo skill for database querying - Introduced a skill to query the SHZ HighGo database through an SSH gateway using a read-only psql workflow. - Included scripts for executing SQL queries and schema discovery. - Added connection details and usage instructions. feat: add OutdoorFairBooth domain and mapper - Created OutdoorFairBooth domain model with relevant fields and annotations. - Implemented a mapper interface for physical deletion of records based on fair ID. feat: create SQL scripts for cms_outdoor_fair_booth - Added SQL script to create the cms_outdoor_fair_booth table and its associated sequence. - Included comments for clarity and compatibility with historical data. - Added a script to drop the cms_venue_booth table after migration confirmation.
This commit is contained in:
43
.codex/skills/query-shz-highgo/scripts/query.sh
Executable file
43
.codex/skills/query-shz-highgo/scripts/query.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
skill_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
password_file="${HIGHGO_PASSWORD_FILE:-$skill_dir/.password}"
|
||||
|
||||
ssh_host="root@124.243.245.42"
|
||||
psql_path="/opt/HighGo4.5.7-see/bin/psql"
|
||||
db_host="39.98.44.136"
|
||||
db_port="6023"
|
||||
db_name="highgo"
|
||||
db_user="sysdba"
|
||||
|
||||
if [[ ! -r "$password_file" ]]; then
|
||||
echo "HighGo password file is missing or unreadable: $password_file" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: $0 'SELECT ...'" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
sql="$*"
|
||||
if [[ ! "$sql" =~ ^[[:space:]]*(SELECT|select|WITH|with|SHOW|show|EXPLAIN|explain)([[:space:]]|$) ]]; then
|
||||
echo "Rejected: only SELECT, WITH, SHOW, and EXPLAIN queries are allowed." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
sql_without_final_semicolon="${sql%;}"
|
||||
if [[ "$sql_without_final_semicolon" == *';'* ]]; then
|
||||
echo "Rejected: multiple SQL statements are not allowed." >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
password="$(<"$password_file")"
|
||||
sql_base64="$(printf '%s' "$sql" | base64 | tr -d '\n')"
|
||||
|
||||
{
|
||||
printf '%s\n' "$password"
|
||||
printf '%s\n' "$sql_base64"
|
||||
} | ssh -o BatchMode=yes -o ConnectTimeout=10 "$ssh_host" \
|
||||
"read -r PGPASSWORD; read -r SQL_BASE64; export PGPASSWORD; export PGOPTIONS='-c default_transaction_read_only=on -c search_path=shz,public -c statement_timeout=30000'; SQL=\$(printf '%s' \"\$SQL_BASE64\" | base64 -d); exec '$psql_path' -X --no-psqlrc -h '$db_host' -p '$db_port' -U '$db_user' -d '$db_name' -v ON_ERROR_STOP=1 -P pager=off -c \"\$SQL\""
|
||||
Reference in New Issue
Block a user