#!/bin/bash

export RESTAPI="http://localhost:8080/geoserver/rest"
export LOGIN="admin26:gm2711"  # Change YOUR_OWN_PASSWORD to your own preferred password.
export WORKSPACE="osm_tw_11b"
export STORE="OpenStreetMap_11b"
export SLD_DIR="$HOME/my_labs/lab_11c/osm_tw_11c_sld"
export LAYER="building"


# Long options (style: 11c_building)
curl --verbose --user $LOGIN --header "Content-type: text/xml" --data "<featureType><name>$LAYER</name></featureType>" $RESTAPI/workspaces/$WORKSPACE/datastores/$STORE/featuretypes?recalculate=nativebbox,latlonbbox
curl --verbose --user $LOGIN --header "Content-type: text/xml" --data "<style><name>11c_$LAYER</name><filename>11c_$LAYER.sld</filename></style>" $RESTAPI/workspaces/$WORKSPACE/styles
curl --verbose --user $LOGIN -XPUT --header "Content-type: application/vnd.ogc.sld+xml" --data @$SLD_DIR/11c_$LAYER.sld $RESTAPI/workspaces/$WORKSPACE/styles/11c_$LAYER
curl --verbose --user $LOGIN -XPUT --header "Content-type: text/xml" --data "<layer><enabled>true</enabled><defaultStyle><name>11c_$LAYER</name><workspace>$WORKSPACE</workspace></defaultStyle></layer>" $RESTAPI/layers/$WORKSPACE:$LAYER

