Skip to content

Commit

Permalink
Merge pull request #473 from dhardy92/fix_EtcDefaultAsShell
Browse files Browse the repository at this point in the history
[fix #472] /etc/default/<package-name> should be shell script setting envars
  • Loading branch information
muuki88 committed Feb 4, 2015
2 parents 53c0c46 + 3659743 commit 0e957d1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,6 @@ run() {
exit $exit_code
}

# Loads a configuration file full of default command line options for this script.
loadConfigFile() {
cat "$1" | sed '/^\#/d'
}

# Now check to see if it's a good enough version
# TODO - Check to see if we have a configured default java version, otherwise use 1.6
java_version_check() {
Expand Down Expand Up @@ -367,7 +362,8 @@ ${{template_declares}}
# java_cmd is overrode in process_args when -java-home is used
declare java_cmd=$(get_java_cmd)

# if configuration files exist, prepend their contents to $@ so it can be processed by this runner
[[ -f "$script_conf_file" ]] && set -- $(loadConfigFile "$script_conf_file") "$@"

# use JAVA_OPTS to prepend its contents to $@
set -- "$JAVA_OPTS" "$@"

run "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ${{daemon_user}} daemon user
# -------------------------------------------------

# Using $JAVA_OPTS envars
# Setting -Xmx and -Xms in Megabyte
# -mem 1024

Expand All @@ -31,4 +32,8 @@
# -jvm-debug <port>

# Don't run the java version check
# -no-version-check
# -no-version-check

# Example
# JAVA_OPTS=" -Dpidfile.path=/var/run/${{app_name}}/play.pid $JAVA_OPTS"
# JAVA_OPTS=" -mem 1024 -Dkey=val -jvm-debug $JAVA_OPTS"
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
source /lib/init/vars.sh
source /lib/lsb/init-functions

# if configuration files exist, source it and use JAVA_OPTS to prepend their contents to $@
[[ -f /etc/default/${{app_name}} ]] && . /etc/default/${{app_name}}
# $JAVA_OPTS used in $RUN_CMD wrapper
export JAVA_OPTS

PIDFILE=/var/run/${{app_name}}/running.pid

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
# Source function library.
. /etc/rc.d/init.d/functions

# if configuration files exist, source it and use JAVA_OPTS to prepend their contents to $@
[[ -f /etc/default/${{app_name}} ]] && . /etc/default/${{app_name}}
# $JAVA_OPTS used in $RUN_CMD wrapper
export JAVA_OPTS

prog="${{exec}}"

# FIXME The pid file should be handled by the executed script
Expand Down
8 changes: 8 additions & 0 deletions src/sphinx/archetypes/java_server/customize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Create ``src/templates/etc-default`` with the following template
# ${{daemon_user}} daemon user
# -------------------------------------------------
# Using $JAVA_OPTS envars
# Setting -Xmx and -Xms in Megabyte
# -mem 1024
Expand All @@ -58,9 +59,16 @@ Create ``src/templates/etc-default`` with the following template
# using a reserved parameter. See #184
# -d -- -d
# Example:
# JAVA_OPTS=" -Dpidfile.path=/var/run/${{app_name}}/play.pid $JAVA_OPTS"
# JAVA_OPTS=" -mem 1024 -Dkey=val -jvm-debug $JAVA_OPTS"
The file will be installed to ``/etc/default/<normalizedName>`` and read from there
by the startscript.

*Warning: the format changed, from java option list only, to a shell script setting environment variables.
A project using previous version should adapts its configuration file.*

Environment variables
~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 0e957d1

Please sign in to comment.