From 096e019273f27c51a745ac4c3373bfbab9f795f7 Mon Sep 17 00:00:00 2001 From: iSergio Date: Wed, 19 Sep 2018 14:10:23 +0300 Subject: [PATCH] Add undeploy command --- jboss/bin/undeploy-cluster | 58 ++++++++++++++++++++++++++++++++------ jboss/configure.sh | 1 + 2 files changed, 50 insertions(+), 9 deletions(-) mode change 100644 => 100755 jboss/bin/undeploy-cluster diff --git a/jboss/bin/undeploy-cluster b/jboss/bin/undeploy-cluster old mode 100644 new mode 100755 index 5adcefc..32e57dd --- a/jboss/bin/undeploy-cluster +++ b/jboss/bin/undeploy-cluster @@ -1,19 +1,59 @@ -#!/bin/sh +#!/bin/bash CONTROLLER=__CONTROLLER__:9999 -VERBOSE=false +color_violet="\e[1;35m"; +color_red="\e[0;31m"; +color_normal="\e[0m"; +color_green="\e[32m"; +color_blue="\e[0;34m"; -DOTSTRING="..............................................................................." +DONE="[ ${color_green}done${color_normal} ]" +FAIL="[ ${color_red}fail${color_normal} ]" + +DOTSTRING="" +cols=`tput cols` +#cols=$((cols / 4)) +cols=$((cols - 10)) +for i in `seq 1 $cols`; do + DOTSTRING=$DOTSTRING"." +done function align_left() { local chars="$1" local str="${@:2}" echo -n ${str}${chars:${#str}} } -if [[ $VERBOSE == false ]]; then - result=`jboss-cli.sh --controller=$CONTROLLER --connect --commands="undeploy "\""$1"\"" --all-relevant-server-groups" 2>&1` -else - jboss-cli.sh --controller=$CONTROLLER --connect --commands="deploy "\""$1"\"" --all-relevant-server-groups" +function align_echo() { + if [[ "$1" != 0 ]]; then + echo -e $FAIL + echo "$2" + else + echo -e $DONE + fi +} + +INFO=false + +usage="$(basename "$0") [-l] module_name + where: + -l list all modules +" +while getopts ':l' option; do + case "$option" in + l) INFO=true + ;; + \?) printf "illegal option: -%s\n" "$OPTARG" >&2 + echo "$usage" >&2 + exit 1 + ;; + esac +done + +if [[ $INFO == true ]]; then + jboss-cli.sh --controller=$CONTROLLER --connect --commands="deployment-info --server-group=main-server-group" + exit 0 fi -exit_code=$? -align_left "$DOTSTRING" "$1" + +align_left "$DOTSTRING" "Undeploy module $1" +result=`jboss-cli.sh --controller=$CONTROLLER --connect --commands="undeploy $1 --all-relevant-server-groups"` &>/dev/null +align_echo $? "$result" diff --git a/jboss/configure.sh b/jboss/configure.sh index bba8c00..6cc7b5d 100755 --- a/jboss/configure.sh +++ b/jboss/configure.sh @@ -146,6 +146,7 @@ ln -sf ${JBOSS_HOME}"/bin/jboss-cli.sh" ${JBOSS_HOME}"/bin/jboss-cli" cp -rf bin/dodeploy* /usr/local/bin/ chmod +x /usr/local/bin/dodeploy* sed -i 's/__CONTROLLER__/'$HOST'/g' /usr/local/bin/dodeploy +sed -i 's/__CONTROLLER__/'$HOST'/g' /usr/local/bin/undeploy-cluster ENCRYPT_CLASS_PATH=${JBOSS_HOME}"/modules/system/layers/base/org/picketbox/main/*" ENCRYPT_CLASS_PATH=${ENCRYPT_CLASS_PATH}:"${JBOSS_DIR}/modules/system/layers/base/org/jboss/logging/main/*" -- GitLab