Quick Start#

This guide will help you get started with GeoServer CLI in minutes.

Step 1: Initialize Configuration#

First, initialize your configuration:

1
./geoserver-cli config init

This creates configs/default.config.toml. Edit it with your GeoServer connection details:

1
2
3
4
5
[geoserver]
base_url = "http://your-geoserver:8080/geoserver/rest"
username = "admin"
password = "your-password"
timeout  = "30s"

Step 2: Verify Connection#

Test your connection by listing workspaces:

1
./geoserver-cli workspace list

If successful, you’ll see a list of workspaces.

Step 3: Get Default Workspace#

Find the default workspace:

1
./geoserver-cli workspace get --default

Set it as your default:

1
export GEOSRVCLI_DEFAULT_WORKSPACE=your_workspace_name

Step 4: Create a Workspace (Optional)#

If you need a new workspace:

1
./geoserver-cli workspace create my_new_workspace

Step 5: Create a Datastore#

Create a PostGIS datastore:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Create connection parameters file
cat > postgis_conn.json <<EOF
{
  "dbtype": "postgis",
  "host": "localhost",
  "port": 5432,
  "database": "gis",
  "user": "postgres",
  "passwd": "password",
  "schema": "public"
}
EOF

# Create the datastore
./geoserver-cli store create postgis_store -w my_workspace --params @postgis_conn.json

Step 6: Publish Layers#

From PostGIS#

1
2
3
4
5
# Publish all spatial tables
./geoserver-cli publish postgis --all -w my_workspace --store postgis_store

# Or publish specific tables
./geoserver-cli publish postgis --layers roads,buildings -w my_workspace --store postgis_store

From File (Requires Importer Extension)#

1
2
# Publish from Shapefile
./geoserver-cli publish file --file data.shp.zip -w my_workspace

Step 7: Manage Styles#

Create a style from an SLD file:

1
./geoserver-cli style create my_style --sld @style.sld

Apply it to a layer:

1
./geoserver-cli layer update my_layer --default-style my_style

Step 8: Export for QGIS#

Generate QGIS connection files:

1
2
3
4
5
# Export connections XML
./geoserver-cli qgis export connections -w my_workspace -o geoserver_connections.xml

# Export project file
./geoserver-cli qgis export project -w my_workspace -o geoserver_layers.qgs

Import these files into QGIS. See the QGIS Authentication Guide for setting up authentication.

Next Steps#

  • Explore Commands for detailed command reference
  • Read Guides for advanced workflows
  • Check Reference for configuration details