Skip to content

Instantly share code, notes, and snippets.

@uniomni
uniomni / gist:779194
Created January 14, 2011 04:56
Geoserver REST command examples

REST commands, generated by Risk-in-a-Box and known to work

Upload shapefile + associated style. Then activate style and make it default.

PUT -H "Content-type: application/zip" "http://localhost:8080/geoserver/rest/workspaces/exposure/datastores/AIBEP_schools/file.shp" --data-binary "@AIBEP_schools.zip"
POST -H "Content-type: text/xml" "http://localhost:8080/geoserver/rest/styles" --data-ascii "<style>AIBEP_schoolsAIBEP_schools.sld</style>"
PUT -H "Content-type: application/vnd.ogc.sld+xml" "http://localhost:8080/geoserver/rest/styles/AIBEP_schools" --data-binary "@AIBEP_schools.sld"
PUT -H "Content-type: text/xml" "http://localhost:8080/geoserver/rest/layers/AIBEP_schools" --data-ascii "AIBEP_schoolstrue"

#!/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" ]
user = "admin"
pass = "geoserver"
gs_url = "localhost:8080/geoserver"
workspace = "floods"
system( "curl -u #{user}:#{pass} -v -XPOST -H 'Content-type: text/xml' -d '<workspace><name>#{workspace}</name></workspace>' #{gs_url}/rest/workspaces")
system("mkdir -p tmp_expanded")
system("mkdir -p geotiffs")
Dir.glob('*.zip').each{ |z| system( "unzip -n #{z} -d ./tmp_expanded")}
@dwins
dwins / start_clean_gs.sh
Created March 17, 2010 20:19
Shell commands to start up GeoServer with a fresh datadir every time
# run in the geoserver webapp dir:
cd geoserver/src/web/app/
# If you use SVN
rm -rf /tmp/release
svn export ../../../data/release/ /tmp/release/
mvn jetty:run -DGEOSERVER_DATA_DIR=/tmp/release/
# if you use git-svn
git clean -xdf -- ../../../data/release/