Created
September 28, 2010 15:41
-
-
Save ingenieroariel/601216 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#s3togs.sh | |
# This script takes a list of zipfiles on a plain text file, downloads them and pushes | |
# them to geoserver. | |
LINKSFILE=whitelist.txt | |
BUCKET_URL=https://s3.amazonaws.com/haitidata/ | |
GEOSERVER_CREDENTIALS=adminuser:supersecretpass | |
GEOSERVER_BASE_URL=http://geonode.mycompany.com/geoserver/ | |
DEFAULT_WORKSPACE=base | |
if [ -f "$LINKSFILE" ] | |
exec<$LINKSFILE | |
while read line | |
do | |
url=$BUCKET_URL$line | |
echo "Fetching file from:" | |
echo $url | |
echo "\n" | |
# Find the filename without extension | |
fullname=$(basename $url) | |
extension=${fullname££*.} | |
storename=${fullname%.*} | |
# Download the data from S3 | |
curl $url --O $fullname | |
# Put the data in GeoServer | |
filepath=rest/workspaces/$DEFAULT_WORKSPACE/datastores/$storename/file.shp | |
echo "\n" | |
echo "Uploading $fullname to:" | |
puturl=$GEOSERVER_BASE_URL$filepath | |
echo $puturl | |
curl -u $GEOSERVER_CREDENTIALS -XPUT -H 'Content-type: application/zip' --data-binary @$fullname $puturl | |
# Clean after yourself | |
echo "Deleting $fullname from local disk" | |
rm $fullname | |
done | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CARTO/211_Physical/2111_Rivers/hti_hydroname_TNC_pt.zip | |
CARTO/211_Physical/2111_Rivers/hti_riv_Topo50_pl.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment