Bash 如何始终以编程方式在Geoserver上设置用户名和密码
我正在编写一个bash脚本,按照这里概述的步骤安装Geoserver。我试图使用CURL发布一个自定义数据存储配置文件。但是我有一个身份验证错误Bash 如何始终以编程方式在Geoserver上设置用户名和密码,bash,geoserver,Bash,Geoserver,我正在编写一个bash脚本,按照这里概述的步骤安装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
* 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
*上传已完全发送:42字节中的42字节
我相信这是因为我没有为Geoserver设置用户名和密码。我能找到的唯一方法似乎是通过web管理界面来实现。我想通过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
echo“下载地理服务器”
wgethttp://downloads.sourceforge.net/project/geoserver/GeoServer/2.2.4/geoserver-2.2.4-war.zip
解压缩geoserver-2.2.4-war.zip
sudo cp geoserver.war/var/lib/tomcat7/webapps/
睡眠120
回显“设置地理服务器”
curl-u$u_NAME:$PASSWORD-v-XPOST-H'Content type:text/xml'\
-卡塔米\
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‘强制图像’\
http://localhost:8080/geoserver/rest/workspaces/catami/datastores/CatamiImagePoints/featuretypes ;
curl-u$u_NAME:$PASSWORD-XPOST-H'内容类型:application/vnd.ogc.sld+xml'\
-d@catami-color-by-depth.sldhttp://localhost:8080/geoserver/rest/styles ;
curl-u$u_NAME:$PASSWORD-XPUT-H'Content type:text/xml'\
-d'卡塔米颜色深度真实'\
http://localhost:8080/geoserver/rest/layers/catami:Force_image
显然,您可以在GeoServer数据目录中编辑用户名和密码。你可以阅读更多关于它的内容
在找到要更改的文件后,只需sed
根据自己的喜好更改数据