gpt4 book ai didi

bash - 如何在安装时以编程方式在 Geoserver 上设置用户名和密码

转载 作者:行者123 更新时间:2023-11-29 09:15:21 25 4
gpt4 key购买 nike

我正在编写一个 bash 脚本来按照此处概述的步骤安装 Geoserver Install Instructions .我正在尝试使用 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

最佳答案

显然,您可以在 GeoServer 数据目录中编辑用户名和密码。您可以阅读更多相关信息 here .

找到要更改的文件后,您只需根据自己的喜好sed该数据即可。

关于bash - 如何在安装时以编程方式在 Geoserver 上设置用户名和密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14619238/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com