ruscomap/script/inserisci_ricicla.sh
2024-11-02 13:16:21 +01:00

33 lines
No EOL
1.3 KiB
Bash
Executable file

#!/bin/bash
#set -x
# Prendi credenziali db e tabella
DB_USER=$(jq -r '.db.user' ../server/config/default.json)
DB_PASS=$(jq -r '.db.password' ../server/config/default.json)
DB_NAME=$(jq -r '.db.database' ../server/config/default.json)
TABLE_NAME=$(jq -r '.db.table' ../server/config/default.json)
# Valori coords market ricicla
coordinates=(
"POINT(11.386956274509432 44.47601517125007)"
"POINT(11.373899281024935 44.484269124276224)"
"POINT(11.366094052791597 44.498236752697885)"
"POINT(11.352428197860718 44.51198490203542)"
"POINT(11.329773100000000 44.51429310000000)"
)
# Loop inserirmento ricicla
for i in "${coordinates[@]}"; do
# Genera dati riciclaq
NAME='Ricicla'
DESCRIPTION='Alimenti ancora buoni buttati vicino ai cassoneti dei supermercati da subito dopo chiusura. Maggiori info su: riciclabologna.vado.li'
FILENAME='riciclaimg'
COORDINATE="$i"
TS='2016-01-10 21:42:42'
# SQL command per inserire i dati
SQL_COMMAND="INSERT INTO $TABLE_NAME (name, description, filename, coordinate, ts) VALUES ('$NAME', '$DESCRIPTION', '$FILENAME', ST_GeomFromText('$COORDINATE'), '$TS');"
# Esegue inserimento
mysql -u "$DB_USER" -p"$DB_PASS" -D "$DB_NAME" -e "$SQL_COMMAND"
done