Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Generate unused port numbers for JBoss using Groovy script
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Sep 15, 2014
1 parent 1474faf commit 7e44226
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions build.sh
@@ -0,0 +1,16 @@
#!/bin/bash -e

eval $(etc/scripts/allocate-ports \
JBOSS_MANAGEMENT_NATIVE_PORT \
JBOSS_MANAGEMENT_HTTP_PORT \
JBOSS_MANAGEMENT_HTTPS_PORT \
JBOSS_AJP_PORT \
JBOSS_HTTP_PORT \
JBOSS_HTTPS_PORT \
JBOSS_OSGI_PORT \
JBOSS_REMOTING_PORT \
JBOSS_TXN_RECOVERY_PORT \
JBOSS_TXN_STATUS_PORT \
SMTP_PORT \
)
exec mvn "$@"
16 changes: 16 additions & 0 deletions etc/scripts/allocate-ports
@@ -0,0 +1,16 @@
#!/bin/env groovy

Map ports = [:]
List sockets = new ArrayList()
try {
for(String name: args) {
def s = new ServerSocket(0)
sockets.add(s)
ports[name] = s.localPort
}
} finally {
sockets*.close()
}

ports.each { println "export ${it.key}=${it.value};" }
return

0 comments on commit 7e44226

Please sign in to comment.