From 752020e75f5c2877d72dc7cd3caa0cee42ef3958 Mon Sep 17 00:00:00 2001 From: mslovik Date: Thu, 16 Nov 2023 10:36:46 +0100 Subject: [PATCH 1/3] Add prepare and shutdown scripts --- README.md | 30 ++++++++++++++++++++++++++++++ prepare.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ shutdown.sh | 19 +++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100755 prepare.sh create mode 100755 shutdown.sh 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..0d45c81b --- /dev/null +++ b/prepare.sh @@ -0,0 +1,43 @@ +#!/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 + +if [ "$MODE" == "domain" ]; then + $SERVER_DIR/bin/domain.sh & + $SERVER_DIR/bin/jboss-cli.sh -c '/host=master/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-master.xml -Djboss.domain.base.dir=$SERVER_DIR/dc & + $SERVER_DIR/bin/jboss-cli.sh -c '/host=master/core-service=management/management-interface=http-interface + :undefine-attribute(name=security-realm) + /host=master: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..31f72c9e --- /dev/null +++ b/shutdown.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +SERVER_ZIP=$1 +MODE=$2 + +# Locate server directory +SERVER_DIR="$(jar tf ${SERVER_ZIP} | head -1 | cut -d '/' -f 1)" + +if [ "$MODE" == "domain" ]; then + $SERVER_DIR/bin/jboss-cli.sh -c '/host=master:shutdown' +elif [ "$MODE" == "domain-hc-dc" ]; then + $SERVER_DIR/bin/jboss-cli.sh -c '/host=master: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 From 16ec8573ff1b7f5490a515e559582bbda7a8dbd5 Mon Sep 17 00:00:00 2001 From: mslovik Date: Thu, 16 Nov 2023 12:28:39 +0100 Subject: [PATCH 2/3] Replace /host=master with /host=primary in domain mode --- prepare.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prepare.sh b/prepare.sh index 0d45c81b..19ef1be9 100755 --- a/prepare.sh +++ b/prepare.sh @@ -20,7 +20,7 @@ export JBOSS_HOME=$SERVER_DIR if [ "$MODE" == "domain" ]; then $SERVER_DIR/bin/domain.sh & - $SERVER_DIR/bin/jboss-cli.sh -c '/host=master/core-service=management/management-interface=http-interface + $SERVER_DIR/bin/jboss-cli.sh -c '/host=primary/core-service=management/management-interface=http-interface :undefine-attribute(name=security-realm) :reload' sleep 40 From ca5821321aab983c40517399d7ba4a55c9089d0e Mon Sep 17 00:00:00 2001 From: mslovik Date: Thu, 30 Nov 2023 10:45:38 +0100 Subject: [PATCH 3/3] Add server configuration check --- prepare.sh | 27 +++++++++++++++++++-------- shutdown.sh | 13 ++++++++++--- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/prepare.sh b/prepare.sh index 19ef1be9..5c1f1b10 100755 --- a/prepare.sh +++ b/prepare.sh @@ -18,25 +18,36 @@ 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 & - $SERVER_DIR/bin/jboss-cli.sh -c '/host=primary/core-service=management/management-interface=http-interface + $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' + :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-master.xml -Djboss.domain.base.dir=$SERVER_DIR/dc & - $SERVER_DIR/bin/jboss-cli.sh -c '/host=master/core-service=management/management-interface=http-interface + $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=master:reload' + /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 + $SERVER_DIR/bin/jboss-cli.sh -c "/core-service=management/management-interface=http-interface :undefine-attribute(name=security-realm) - :reload' + :reload" sleep 40 else echo "Error: Unknown mode. Specify either domain, domain-hc-dc or standalone" diff --git a/shutdown.sh b/shutdown.sh index 31f72c9e..e99acb89 100755 --- a/shutdown.sh +++ b/shutdown.sh @@ -6,14 +6,21 @@ 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=master:shutdown' + $SERVER_DIR/bin/jboss-cli.sh -c "/host=$HOST:shutdown" elif [ "$MODE" == "domain-hc-dc" ]; then - $SERVER_DIR/bin/jboss-cli.sh -c '/host=master:shutdown' + $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' + $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