Skip to content

Instantly share code, notes, and snippets.

@savannahostrowski
Last active April 24, 2018 15:25
Show Gist options
  • Save savannahostrowski/27f4474dc50c8936ba4128d43d957e6b to your computer and use it in GitHub Desktop.
Save savannahostrowski/27f4474dc50c8936ba4128d43d957e6b to your computer and use it in GitHub Desktop.
A Simple Bash Script to Setup and Run Atlas Checks

The following script will delete the build folder for your atlas-checks repo, set the ISO country code, and gradle run.

1. Create a file in your Atlas Checks directory called run_checks.sh either by using touch and vi, or manually.
2. Copy the following bash code into the new run_checks.sh file and replace the path_to_build to where you have your build folder located, and the path_to_gradle_props to where you have the gradle.properties file located. Make sure that there are no spaces around =.
 #!/bin/bash
 path_to_build=~/Documents/code/atlas-checks/build
 path_to_gradle_props=~/Documents/code/atlas-checks/gradle.properties
 path_to_data=~/Documents/code/atlas-checks/data

 echo "Are your .pbfs in individual directories within /data? Type y/n followed by Enter"
 read DATA_FOLDERS
 if [ ${DATA_FOLDERS} == "n" ]; then
     echo "You did not properly set up folders. Please do so and try running this script again."
     exit
 fi

 echo "Do you want to delete the Build folder and all previously generated geojson outputs? Type y/n followed by Enter."
 read SHOULD_DELETE
 if [ ${SHOULD_DELETE} == "y" ]; then
     echo "Deleting build folder"
     rm -r -f ${path_to_build}
 fi

 echo "Running Atlas Checks"
 for country_folder in ${path_to_data}/*; do
     country=${country_folder##*/}
     echo "Now running Atlas Checks on ${country}"
      path_to_pbf="file:\/\/@ROOTDIR@\/data\/$country"
      echo $path_to_pbf
      sed -i.bak "s/^\(checks.local.input=\).*/\1${path_to_pbf}/" ${path_to_gradle_props}
      for file in "$country_folder"/*.osm.pbf; do
         echo "Type the 3-letter ISO country codes for the .pbf listed above, followed by Enter."
         read COUNTRY
         sed -i.bak "s/^\(checks.local.countries=\).*/\1${country}/" ${path_to_gradle_props}
         gradle run
     done
 done
3. Move .pbfs into individual folders for each country. Label each folder in the /data directory with the 3-letter ISO code.
4. Modify the permissions of the run_checks.sh file by typing the following into the terminal in the atlas-checks repo directory.
 chmod u+x run_checks.sh
4. To run atlas-checks, type the following into the terminal. When prompted add the 3-letter ISO country code of your .pbf into the terminal (this will modify gradle.properties).
 ./run_checks.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment