Automating removal of all demo layers from GeoServer?

  • If using the Web Archive:

download the war file and deploy it, then login and make all customizations (remove layers, adjust defaults, etc) until it suits you.

Now shutdown the servlet container, zip the geoserver directory and rename the resulting geoserver.zip as .war and you're done. A .war file in fact is just a .zip file in disguise.

IMPORTANT: when zipping the geoserver directory do it from inside the directory itself, not from the parent (which would be webapps if using tomcat). To check that you have done everything all right open the zip file: it should not have a lonely geoserver directory in the root folder.

  • If using the binary (OS independent) installer:

it works pretty much as above since the standalone installer is just an archive of geoserver deployed in a self-contained servlet container: unzip, start, customize, shutdown and zip again.

  • If you are using the os installers and want to keep using them, I'm afraid you will have to prep a custom build.

UPDATED AFTER USER COMMENT

Geoserver stores all its configuration in xml files in the data_dir directory. For the meaning of each folder and/or xml file see the official documentation.

After reading teh docs it seems clear that removing everything under the following directories will get you an empty geoserver:

  1. data_dir/workspaces : wipe the dir rm -rf data_dir/workspaces && mkdir data_dir/workspaces
  2. data_dir/layergroups : wipe the dir rm -rf data_dir/layergroups/*
  3. while not stritcly necessary, wipe the data directory too: rm -rf data_dir/data/*

Bootnote: The directions given at top still hold true, the above is just another way of clearing layer configuration data. I recommend that the the user also sets other important params like username/passwords, security and memory settings, logging, etc before going into production.