#
# set_node_id.sh
#
# Sets the node id for the first installation of a WildFly server.
#

cd ${HOME}/server/wildfly-9.0.2.Final
cp -rp standalone/configuration/standalone.xml standalone/configuration/standalone.xml.`date +%Y-%m-%d`
cat > set_node_id.txt << EOF
*** standalone/configuration/standalone.xml.cp.1    1969-12-31 16:00:00.000000000 -0800
--- standalone/configuration/standalone.xml         1969-12-31 16:00:00.000000000 -0800
***************
*** 335,341 ****
              </security-domains>
          </subsystem>
          <subsystem xmlns="urn:jboss:domain:transactions:3.0">
!             <core-environment>
                  <process-id>
                      <uuid/>
                  </process-id>
--- 335,341 ----
              </security-domains>
          </subsystem>
          <subsystem xmlns="urn:jboss:domain:transactions:3.0">
!             <core-environment node-identifier="node.1">
                  <process-id>
                      <uuid/>
                  </process-id>
***************
*** 404,407 ****
              <remote-destination host="localhost" port="25"/>
          </outbound-socket-binding>
      </socket-binding-group>
! </server>
\ No newline at end of file
--- 404,407 ----
              <remote-destination host="localhost" port="25"/>
          </outbound-socket-binding>
      </socket-binding-group>
! </server>
EOF
patch standalone/configuration/standalone.xml set_node_id.txt
rm set_node_id.txt
cd -
