diff --git a/script/inserisci_ricicla.sh b/script/inserisci_ricicla.sh new file mode 100755 index 0000000..bc1ee5c --- /dev/null +++ b/script/inserisci_ricicla.sh @@ -0,0 +1,33 @@ +#!/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)" +) + +# Loop inserirmento ricicla +for i in "${coordinates[@]}"; do + # Genera dati ricicla + NAME='Ricicla' + DESCRIPTION='Alimenti quasi scaduti vicino ai cassoneti dei supermercati https://nel.computer/lefanze/book/153' + FILENAME='/var/www/html/leaflet/ruscomap/server/public/uploads/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 +