1
|
authoritativeMN="urn:node:mnDemo8"
|
2
|
MN_base_URL="https://mn-demo-8.test.dataone.org/knb/d1/mn/v1"
|
3
|
CN_base_URL="https://cn-dev.test.dataone.org/cn/v1"
|
4
|
cert_path="/var/metacat/certs/urn_node_mnDemo8.pem"
|
5
|
xml_path="replicapolicy.xml"
|
6
|
|
7
|
|
8
|
identifiers=$(curl -o - -E $cert_path "$MN_base_URL/object?count=7000&replicaStatus=false" | xmlstarlet sel -t -m "//objectInfo" -v "identifier" -n)
|
9
|
|
10
|
for id in ${identifiers};
|
11
|
do
|
12
|
metadata=$(curl -o - -E $cert_path "$CN_base_URL/meta/${id}" | xmlstarlet sel -t -v "concat(//serialVersion,';',//authoritativeMemberNode)" -n)
|
13
|
|
14
|
OIFS=$IFS
|
15
|
IFS=";"
|
16
|
arr=($metadata)
|
17
|
if [ ${arr[1]} = $authoritativeMN ]; then
|
18
|
echo "---- Updating replica policy for id: $id ----"
|
19
|
curl -o - -X PUT -E $cert_path --capath "/etc/ssl/certs" -F "serialVersion=${arr[0]}" -F "policy=@$xml_path" "$CN_base_URL/replicaPolicies/${id}"
|
20
|
else
|
21
|
echo "$authoritativeMN is not the authoritative member node for id: $id. (is ${arr[1]})"
|
22
|
fi
|
23
|
done
|
24
|
|
25
|
|