diff --git a/README.md b/README.md index e375f447..f0f85aa6 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,36 @@ Domain hc dc (on master) /host=master:reload ``` +### Alternative Setup +* Has removed security realm +* Using `source` to set `JBOSS_HOME` from SERVER_ZIP + +Standalone +``` +source ./prepare.sh standalone +``` +Domain +``` +source ./prepare.sh domain +``` +Domain hc dc (on master) +``` +source ./prepare.sh domain-hc-dc +``` +#### To stop server started by `prepare.sh` +Standalone +``` +./shutdown.sh standalone +``` +Domain +``` +./shutdown.sh domain +``` +Domain hc dc (on master) +``` +./shutdown.sh domain-hc-dc +``` + ### Run all tests: To run the tests you need to set the ``JBOSS_HOME`` property pointing to the WildFly directory. If have run the ``start-wildfly`` script, you can see the WildFly directory printed out in the console. diff --git a/prepare.sh b/prepare.sh new file mode 100755 index 00000000..5c1f1b10 --- /dev/null +++ b/prepare.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +SERVER_ZIP=$1 +MODE=$2 + +# Check if unzip is successful +if unzip -q "${SERVER_ZIP}"; then + echo "Server unzip successful" +else + echo "Error: Failed to unzip ${SERVER_ZIP}" + exit 1 +fi + +# Locate server directory +SERVER_DIR="$(jar tf ${SERVER_ZIP} | head -1 | cut -d '/' -f 1)" +echo "Server directory: $SERVER_DIR" + +# Set JBOSS_HOME +export JBOSS_HOME=$SERVER_DIR + +# Check if the server has "master" or "primary" configuration +if find $SERVER_DIR -name "host-primary.xml" -print -quit | grep -q .; then + HOST="primary" + HOST_CONFIG_FILE="host-primary.xml" +else + HOST="master" + HOST_CONFIG_FILE="host-master.xml" +fi +echo "Host: $HOST" +echo "Host configuration file: $HOST_CONFIG_FILE" + +if [ "$MODE" == "domain" ]; then + $SERVER_DIR/bin/domain.sh --host-config=$HOST_CONFIG_FILE & + $SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST/core-service=management/management-interface=http-interface + :undefine-attribute(name=security-realm) + :reload" + sleep 40 +elif [ "$MODE" == "domain-hc-dc" ]; then + # Setup dc, please setup hc manually + cp -r $SERVER_DIR/domain/ $SERVER_DIR/dc/ + $SERVER_DIR/bin/domain.sh --host-config=$HOST_CONFIG_FILE -Djboss.domain.base.dir=$SERVER_DIR/dc & + $SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST/core-service=management/management-interface=http-interface + :undefine-attribute(name=security-realm) + /host=$HOST:reload" + sleep 40 +elif [ "$MODE" == "standalone" ]; then + $SERVER_DIR/bin/standalone.sh -c standalone-full-ha.xml & + $SERVER_DIR/bin/jboss-cli.sh -c "/core-service=management/management-interface=http-interface + :undefine-attribute(name=security-realm) + :reload" + sleep 40 +else + echo "Error: Unknown mode. Specify either domain, domain-hc-dc or standalone" +fi \ No newline at end of file diff --git a/shutdown.sh b/shutdown.sh new file mode 100755 index 00000000..e99acb89 --- /dev/null +++ b/shutdown.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +SERVER_ZIP=$1 +MODE=$2 + +# Locate server directory +SERVER_DIR="$(jar tf ${SERVER_ZIP} | head -1 | cut -d '/' -f 1)" + +# Check if the server has "master" or "primary" configuration +if find $SERVER_DIR -name "host-primary.xml" -print -quit | grep -q .; then + HOST="primary" +else + HOST="master" +fi + +if [ "$MODE" == "domain" ]; then + $SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST:shutdown" +elif [ "$MODE" == "domain-hc-dc" ]; then + $SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST:shutdown" + # Clean dc, please clean hc manually + rm -r -d $SERVER_DIR/dc/* +elif [ "$MODE" == "standalone" ]; then + $SERVER_DIR/bin/jboss-cli.sh -c ":shutdown" +else + echo "Error: Unknown mode. Specify either domain, domain-hc-dc or standalone" +fi \ No newline at end of file