Fetching contributors…
Cannot retrieve contributors at this time
executable file 171 lines (140 sloc) 5.36 KB
### ----- FUNCTIONS -----
log ()
local ECHO_PREFIX="@@@@@@@@@@@@@@@@@@@@"
local COLOR_CYAN="\033[0;36m"
local COLOR_GREEN="\033[0;32m"
local COLOR_WHITE="\033[0;37m"
local COLOR_WHITE_BOLD="\033[1;37m"
local COLOR_RED='\033[0;31m'
local COLOR_YELLOW="\033[0;33m"
local COLOR_CLEAR="\033[00m"
local logStr="$1"
local error="$2"
local color=$COLOR_WHITE_BOLD
if [ "$error" = "1" ]; then
if [ "$error" = "2" ]; then
if [ "$error" = "3" ]; then
echo "$color$ECHO_PREFIX $logStr$COLOR_CLEAR" 1>&2
log_error ()
log "$1" 1
log_warn ()
log "$1" 2
log_success ()
log "$1" 3
quit_error ()
local logStr="$1"
if [ "$logStr" != "" ]; then
log_error "$logStr" 1
#do we need cleanup?
#rm -rf "$tmpDir"
kill -s TERM $TOP_PID
# trap ctrl-c and call ctrl_c()
trap ctrl_c INT
ctrl_c ()
quit_error "Caught CTRL-C, cleaning..."
# see
trap "exit 1" TERM
export TOP_PID=$$
### ----- MAIN -----
log "This script will bootstrap a demo Stralo installation to the current directory."
log "Hit ENTER to continue..."
read answer
log "Contacting GitHub to get the latest version number... "
VERSION=$(git ls-remote | grep -o '[0-9]*\.[0-9]*\.[0-9]*$' | sort -r | head -n1)
if [ "$VERSION" = "" ]; then
quit_error "Error while fetching version information."
LOCAL_CONFIG="./$(basename $CONFIG)"
log "Fetching a default config file from $CONFIG... "
wget --quiet --output-document "$LOCAL_CONFIG" "$CONFIG" || quit_error "Error while fetching default config file"
# Big note: this will only work starting from version 1.0.1 because of the pom.xml groupId change in that release (and on)
log "Generating pom.xml... "
echo "<project xmlns=\"\" xmlns:xsi=\"\" xsi:schemaLocation=\"\">
</project>" > pom.xml
# These extracts are highly experimental, but work, for now.
# Note 1: they're not really necessary, but handy to test availability of the port and log the link to open the browser.
# Note 2: first grep options don't always work, switched to using sed instead (see
#HOSTNAME=$(grep -oPm1 "(?<=<hostname>)[^<]+" "$LOCAL_CONFIG") || quit_error "Failed to extract hostname from config"
HOSTNAME=$(cat "$LOCAL_CONFIG" | sed -ne '/hostname/{s/.*<hostname>\(.*\)<\/hostname>.*/\1/p;q;}') || quit_error "Failed to extract hostname from config"
#PORT=$(grep -oPm1 "(?<=<port>)[^<]+" "$LOCAL_CONFIG") || quit_error "Failed to extract port from config"
PORT=$(cat "$LOCAL_CONFIG" | sed -ne '/port/{s/.*<port>\(.*\)<\/port>.*/\1/p;q;}') || quit_error "Failed to extract port from config"
#Test if the port is available (not: zero means busy!)
nc -z "$HOSTNAME" "$PORT"
if [ $? -eq 0 ]; then
quit_error "$HOSTNAME:$PORT seems to be busy, can't launch Stralo"
echo ""
log_success "Allright, I've got everything I need to launch Stralo"
echo ""
log "What to do next?"
log "- On first boot, this installation will download a lot of (small) extra packages, so please be patient."
log "- Wait for the output below to display the log-string 'INFO [o.e.j.s.Server] Started'"
log "- Initialize a new administrator user by surfing to http://$HOSTNAME:$PORT/users/init"
log "- Log in with username \"admin\" and password \"admin123\""
log "- Create your first page!"
log "- Head over to and read the docs"
log "- To bring the server down, hit ctrl-c"
echo ""
log_warn "Read the above? Then hit ENTER to boot the server"
read answer
mvn exec:java -Dexec.args="$LOCAL_CONFIG --base.core.context.local.root=$STORAGE"