fetch_google_json.sh 842 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. # ** NOTICE **
  3. # This script deletes the "./_google_api_json_tmp" directory
  4. # (if it exists) before attempting to download new definitions.
  5. SCRIPT_DIR="$(dirname "$0")"
  6. JSON_DIR="$SCRIPT_DIR/_google_api_json_tmp"
  7. TIMESTAMP=$(date +%F@%H%M) #format: 2006-09-15@1228
  8. LOG_FILE="$JSON_DIR/${TIMESTAMP}-$(basename "$0").txt" #log file with same name as script
  9. rm -r "$JSON_DIR" &> /dev/null
  10. mkdir "$JSON_DIR" &> /dev/null
  11. {
  12. echo "Run Timestamp: $TIMESTAMP"
  13. echo "Using Google API Converter: " $("$SCRIPT_DIR/googleapiconv" --version)
  14. echo
  15. echo "# googleapiconv --verbose --all --onlydownload --keepjson --output=$JSON_DIR/"
  16. echo
  17. "$SCRIPT_DIR/googleapiconv" --verbose --all --onlydownload --keepjson --output="$JSON_DIR/"
  18. } |& tee "$LOG_FILE" #output both stdout and stderr to logfile and terminal