我正在编写一个bash脚本,按照Install Instructions中列出的步骤安装Geoserver。我正在尝试使用CURL发布一个自定义的数据存储配置文件。但是我遇到了一个身份验证错误。
* upload completely sent off: 42out of 42 bytes
< HTTP/1.1 401 Unauthorized
< Server: Apache-Coyote/1.1
< Set-Cookie: SPRING_SECURITY_REMEMBER_ME_COOKIE=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/geoserver
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="GeoServer Realm"
< Content-Type: text/html;charset=utf-8
< Content-Length: 1299
< Date: Thu, 31 Jan 2013 05:16:17 GMT我相信这是因为我还没有设置Geoserver的用户名和密码。我唯一能找到的方法就是通过网络管理界面来实现。我想通过我的bash脚本设置它。
有没有办法做到这一点?
此处的Bash脚本部分
echo 'Downdloading geoserver'
wget http://downloads.sourceforge.net/project/geoserver/GeoServer/2.2.4/geoserver-2.2.4-war.zip
unzip geoserver-2.2.4-war.zip
sudo cp geoserver.war /var/lib/tomcat7/webapps/
sleep 120
echo 'setting up geoserver'
curl -u $U_NAME:$PASSWORD -v -XPOST -H 'Content-type: text/xml' \
-d '<workspace><name>catami</name></workspace>' \
http://localhost:8080/geoserver/rest/workspaces ;
curl -u $U_NAME:$PASSWORD -XPOST -T datastore-config.xml -H 'Content-type: text/xml' \
http://localhost:8080/geoserver/rest/workspaces/catami/datastores ;
curl -u $U_NAME:$PASSWORD -XPOST -H 'Content-type: text/xml' \
-d '<featureType><name>Force_image</name></featureType>' \
http://localhost:8080/geoserver/rest/workspaces/catami/datastores/CatamiImagePoints/featuretypes ;
curl -u $U_NAME:$PASSWORD -XPOST -H 'Content-type: application/vnd.ogc.sld+xml' \
-d @catami-colour-by-depth.sld http://localhost:8080/geoserver/rest/styles ;
curl -u $U_NAME:$PASSWORD -XPUT -H 'Content-type: text/xml' \
-d '<layer><defaultStyle><name>catami-colour-by-depth</name></defaultStyle><enabled>true</enabled></layer>' \
http://localhost:8080/geoserver/rest/layers/catami:Force_image发布于 2013-01-31 14:15:22
显然,您可以在GeoServer数据目录中编辑用户名和密码。你可以阅读更多关于它的here。
在找到要更改的文件之后,您只需根据自己的喜好对数据执行sed操作。
https://stackoverflow.com/questions/14619238
复制相似问题