OGG revised this gist . Go to revision
1 file changed, 31 insertions
uploadStyleToGeoserver.sh(file created)
| @@ -0,0 +1,31 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | ||
| 3 | + | GEOSERVER_URL="http://your.geoserver.com/geoserver" | |
| 4 | + | USERNAME="user_name" | |
| 5 | + | PASSWORD="your_password" | |
| 6 | + | WORKSPACE="your_workspace" | |
| 7 | + | ||
| 8 | + | # 현재 폴더 내의 모든 sld 파일 업로드 | |
| 9 | + | for FILE in *.sld; do | |
| 10 | + | if [[ -f "$FILE" ]]; then | |
| 11 | + | STYLE_NAME="${FILE%.*}" | |
| 12 | + | ||
| 13 | + | echo "Uploading style: $STYLE_NAME" | |
| 14 | + | ||
| 15 | + | # 1단계: 스타일 메타 등록 | |
| 16 | + | curl -u "$USERNAME:$PASSWORD" -X POST \ | |
| 17 | + | -H "Content-Type: application/xml" \ | |
| 18 | + | -d "<style><name>$STYLE_NAME</name><filename>$STYLE_NAME.sld</filename></style>" \ | |
| 19 | + | "$GEOSERVER_URL/rest/workspaces/$WORKSPACE/styles" | |
| 20 | + | ||
| 21 | + | # 2단계: 실제 SLD 업로드 | |
| 22 | + | curl -u "$USERNAME:$PASSWORD" -X PUT \ | |
| 23 | + | -H "Content-Type: application/vnd.ogc.se+xml" \ | |
| 24 | + | -T "$FILE" \ | |
| 25 | + | "$GEOSERVER_URL/rest/workspaces/$WORKSPACE/styles/$STYLE_NAME" | |
| 26 | + | ||
| 27 | + | echo "Done: $STYLE_NAME" | |
| 28 | + | echo | |
| 29 | + | fi | |
| 30 | + | done | |
| 31 | + | ||
Newer
Older