create_json_files.sh

#!/bin/bash #mongoexport -d zone7 -c data -o crop-data.json --jsonArray # File locations JSON_DIR_SIDEBAR="/var/www/covercrop.tools/covercrops/src/shared/json/sidebar" JSON_DIR_ZONE7="/var/www/covercrop.tools/covercrops/src/shared/json/zone7" JSON_DIR_ZONE6="/var/www/covercrop.tools/covercrops/src/shared/json/zone6" JSON_DIR_ZONE5="/var/www/covercrop.tools/covercrops/src/shared/json/zone5" JSON_DIR_ZONE4="/var/www/covercrop.tools/covercrops/src/shared/json/zone4" Z4CROPDATA_FILE="/root/.mongo-airtable__Z4CropData.yaml" Z5CROPDATA_FILE="/root/.mongo-airtable__Z5CropData.yaml" Z6CROPDATA_FILE="/root/.mongo-airtable__Z6CropData.yaml" Z7CROPDATA_FILE="/root/.mongo-airtable__Z7CropData.yaml" SIDEBARDATA_FILE="/root/.mongo-airtable__SidebarData.yaml" ## Pull zone data individually.. # Zone 4 Crop Data Sync printf "\nStarting Zone 4 Sync\n" if test -f "/root/.mongo-airtable.yaml"; then printf ".mongo-airtable.yaml exists.. Deleting.." rm "/root/.mongo-airtable.yaml" fi cp "$Z4CROPDATA_FILE" "/root/.mongo-airtable.yaml" cd "/root/mongo-airtable/" printf "\n\n" npm run pull printf "\nZone 4 Sync Complete\n" # Zone 5 Crop Data Sync printf "\nStarting Zone 5 Sync\n" if test -f "/root/.mongo-airtable.yaml"; then printf ".mongo-airtable.yaml exists.. Deleting.." rm "/root/.mongo-airtable.yaml" fi cp "$Z5CROPDATA_FILE" "/root/.mongo-airtable.yaml" cd "/root/mongo-airtable/" printf "\n\n" npm run pull printf "\nZone 5 Sync Complete\n" # Zone 6 Crop Data Sync printf "\nStarting Zone 6 Sync\n" if test -f "/root/.mongo-airtable.yaml"; then printf ".mongo-airtable.yaml exists.. Deleting.." rm "/root/.mongo-airtable.yaml" fi cp "$Z6CROPDATA_FILE" "/root/.mongo-airtable.yaml" cd "/root/mongo-airtable/" printf "\n\n" npm run pull printf "\nZone 6 Sync Complete\n" # Zone 7 Crop Data Sync printf "\nStarting Zone 7 Sync\n" if test -f "/root/.mongo-airtable.yaml"; then printf ".mongo-airtable.yaml exists.. Deleting.." rm "/root/.mongo-airtable.yaml" fi cp "$Z7CROPDATA_FILE" "/root/.mongo-airtable.yaml" cd "/root/mongo-airtable/" printf "\n\n" npm run pull printf "\nZone 7 Sync Complete\n" # Sidebar Crop Data Sync printf "\nStarting Sidebar Sync\n" if test -f "/root/.mongo-airtable.yaml"; then printf ".mongo-airtable.yaml exists.. Deleting.." rm "/root/.mongo-airtable.yaml" fi cp "$SIDEBARDATA_FILE" "/root/.mongo-airtable.yaml" cd "/root/mongo-airtable/" printf "\n\n" npm run pull printf "\nZone Sidebar Sync Complete\n" ## Next steps.... # Export and dump json to relevant folders printf "\n\nDumping JSON for sidebar\n\n" cd "$JSON_DIR_SIDEBAR" mongoexport -d data -c sidebar-categories -o sidebar-categories.json --jsonArray mongoexport -d data -c sidebar-filters -o sidebar-filters.json --jsonArray printf "\n\nDumping JSON for zone 7\n\n" cd "$JSON_DIR_ZONE7" mongoexport -d data -c zone7 -o crop-data.json --jsonArray mongoexport -d data -c zone7-data-dictionary -o data-dictionary.json --jsonArray printf "\nDumping JSON for zone 6\n" cd "$JSON_DIR_ZONE6" mongoexport -d data -c zone6 -o crop-data.json --jsonArray mongoexport -d data -c zone6-data-dictionary -o data-dictionary.json --jsonArray printf "\nDumping JSON for zone 5\n" cd "$JSON_DIR_ZONE5" mongoexport -d data -c zone5 -o crop-data.json --jsonArray mongoexport -d data -c zone5-data-dictionary -o data-dictionary.json --jsonArray printf "\nDumping JSON for zone 4\n" cd "$JSON_DIR_ZONE4" mongoexport -d data -c zone4 -o crop-data.json --jsonArray mongoexport -d data -c zone4-data-dictionary -o data-dictionary.json --jsonArray