forked from goldmann/wildfly-copr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wildfly-cp.sh
executable file
·76 lines (60 loc) · 2.06 KB
/
wildfly-cp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
usage()
{
cat << EOF
usage: $0 options
Makes possible to run WildFly AS in different directory by creating the structure and copying required configuration files.
OPTIONS:
-h Show this message
-c WildFly configuration xml file (see \$JBOSS_HOME/docs/examples/configs/), default: standalone-web.xml
-l Location where the directory structure should be created (required)
-p Port offset, see https://community.jboss.org/docs/DOC-16705
EOF
}
STANDALONE_XML="standalone.xml"
while getopts “hc:l:p:” OPTION
do
case $OPTION in
h)
usage
exit 1
;;
c)
STANDALONE_XML=$OPTARG
;;
l)
LOCATION=$OPTARG
;;
p)
PORT_OFFSET=$OPTARG
;;
?)
usage
exit
;;
esac
done
if [[ -z $LOCATION ]]
then
usage
exit 1
fi
if [ "x$JBOSS_HOME" = "x" ]; then
JBOSS_HOME="/usr/share/jboss-as"
fi
mkdir -p ${LOCATION}/{bin,data,deployments,log,tmp,configuration}
cp $JBOSS_HOME/docs/examples/configs/$STANDALONE_XML ${LOCATION}/configuration/
cp $JBOSS_HOME/docs/examples/properties/logging.properties ${LOCATION}/configuration/
cp $JBOSS_HOME/docs/examples/properties/mgmt-users.properties ${LOCATION}/configuration/
# Create the standalone script
echo "#!/bin/sh
JBOSS_BASE_DIR=${LOCATION} ${JBOSS_HOME}/bin/standalone.sh -c ${STANDALONE_XML}" > ${LOCATION}/bin/standalone.sh
# Make sure the mgmt-users.properties file has correct permissions!
chmod 600 ${LOCATION}/configuration/mgmt-users.properties
# Set the executable permissions correctly
chmod 755 ${LOCATION}/bin/standalone.sh
# Set the port offset (if specified)
if [ "x$PORT_OFFSET" != "x" ]; then
sed -i s/'\(socket-binding-group name="standard-sockets" default-interface="public"\).*'/"\1 port-offset=\"${PORT_OFFSET}\">"/ ${LOCATION}/configuration/${STANDALONE_XML}
fi
echo -e "Directory ${LOCATION} is prepared to launch WildFly AS!\n\nYou can now boot your instance: ${LOCATION}/bin/standalone.sh"