diff --git a/README.markdown b/README.markdown index e0b7c69..bfcdcab 100644 --- a/README.markdown +++ b/README.markdown @@ -20,7 +20,7 @@ Clients authenticate by sending an ext parameter `authentication` containing the ## Configuration and running ## -Install an init script (for debian-based systems) using `initscripts/install.sh`. +Install an init script (for debian-based systems) using `initscripts/install.sh [port]`. The port defaults to 8080. To run the server manually, do `mvn -Dfi.helsinki.cs.tmc.comet.configFile=/path/to/file.properties jetty:start`. The configuration file should not be world-readable and must have the following definitions. diff --git a/initscripts/install.sh b/initscripts/install.sh index 633e604..e6d4cb5 100755 --- a/initscripts/install.sh +++ b/initscripts/install.sh @@ -5,15 +5,17 @@ TEMPLATE="$THISDIR/template.txt" SCRIPT_NAME=tmc-comet TARGET="/etc/init.d/$SCRIPT_NAME" RUN_AS=`stat -c '%U' "$BASEDIR"` +PORT=${1:-8080} which nc > /dev/null || (echo "Error: 'nc' command missing! Please install netcat."; exit 1) -echo "Installing into $TARGET." +echo "Installing into $TARGET with port $PORT." echo "Configuring it to run as $RUN_AS (the current owner of the directory)." cat "$TEMPLATE" | sed "s@__BASEDIR__@$BASEDIR@" | sed "s@__NAME__@$SCRIPT_NAME@" | - sed "s@__USER__@$RUN_AS@" > $TARGET + sed "s@__USER__@$RUN_AS@" | + sed "s@__PORT__@$PORT@" > $TARGET chmod a+x "$TARGET" echo "Setting to start/stop by default" diff --git a/initscripts/template.txt b/initscripts/template.txt index 79f6e87..e67b97b 100644 --- a/initscripts/template.txt +++ b/initscripts/template.txt @@ -11,7 +11,7 @@ BASEDIR=__BASEDIR__ LOG_FILE="$BASEDIR/daemon.log" -HTTP_PORT=8080 +HTTP_PORT=__PORT__ RUN_AS=__USER__ cd "$BASEDIR" @@ -31,7 +31,7 @@ start() { fi echo -n "Starting jetty" - su -c 'mvn jetty:start >> '"$LOG_FILE"' 2>&1 &' "$RUN_AS" + su -c 'mvn -Djetty.port='"$HTTP_PORT"' jetty:start >> '"$LOG_FILE"' 2>&1 &' "$RUN_AS" # Wait until started for i in `seq 1 15`; do @@ -42,13 +42,13 @@ start() { echo echo "Failed to start in 15 seconds. Check $LOG_FILE" - echo "If this is the first startup, it might take a while to download dependencies." + echo "If this is the first startup, the server may start after dependencies have been downloaded." exit 1 } stop() { echo "Stopping jetty" - su -c 'mvn jetty:stop >> '"$LOG_FILE"' 2>&1' "$RUN_AS" + su -c 'mvn -Djetty.port='"$HTTP_PORT"' jetty:stop >> '"$LOG_FILE"' 2>&1' "$RUN_AS" } case "$1" in