Hi,
Im have a xml config file called solrconfig.xml, it has this section in the middle of it:
<!--############ BEGIN replication settings DO NOT EDIT ################################-->
<requestHandler name="/replication" class="solr.ReplicationHandler" >
<lst name="master">
<str name="replicateAfter">commit</str>
<str name="replicateAfter">startup</str>
<str name="confFiles">schema.xml,stopwords.txt</str>
</lst>
</requestHandler>
<!--############ END replication settings DO NOT EDIT ################################-->
I have a shell script that I want to use to replace this section in the case I am configuring the server as a slave. I have it working, except it puts the new section at the end of the file instead of the same place as the old one, can you help me tweak this to replace it in the same spot.
if [ -n "$1" ] && [ $1 == "slave" ]
then
rm solrconfig2.xml
echo "setting up slave"
cat solrconfig.xml | awk '
/^<!--############ BEGIN replication/ { skip = 1 }
/^<!--############ END replication/ { skip = 0; next; }
{ if (skip == 0) print $0; }
END {
print "<!--############ BEGIN replication settings DO NOT EDIT ################################-->"
print "<requestHandler name=\"/replication\" class=\"solr.ReplicationHandler\" >"
print "<lst name=\"slave\">"
print "<str name=\"masterUrl\">http://solr-master:8983/solr/replication</str>"
print "<str name=\"pollInterval\">00:00:60</str>"
print "</lst>"
print "</requestHandler>"
print "<!--############ END replication settings DO NOT EDIT ################################-->"
}
' > solrconfig2.xml
fi