Skip to content

Commit 4f6c74f

Browse files
committed
Prevent empty double quotes in start daemon line.
The removal of the quotes should fix this if no `stdout_redirect` is set.
1 parent 2c3946a commit 4f6c74f

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

src/main/resources/com/typesafe/sbt/packager/archetypes/systemloader/systemv/start-debian-template

+24-26
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,45 @@ export JAVA_OPTS
2222
# If program manages its own PID file then it
2323
# should declare its location in PIDFILE
2424
if [ -z "$PIDFILE" ]; then
25-
create_pidfile=true
26-
PIDFILE=/var/run/${{app_name}}/running.pid
25+
create_pidfile=true
26+
PIDFILE=/var/run/${{app_name}}/running.pid
2727
fi
2828

2929
if [ -z "$DAEMON_USER" ]; then
30-
DAEMON_USER=${{daemon_user}}
30+
DAEMON_USER=${{daemon_user}}
3131
fi
3232

3333
if [ -z "$DAEMON_GROUP" ]; then
34-
DAEMON_GROUP=${{daemon_group}}
34+
DAEMON_GROUP=${{daemon_group}}
3535
fi
3636

37-
3837
RUN_CMD="${{chdir}}/bin/${{exec}}"
3938

40-
4139
start_daemon() {
42-
log_daemon_msg "Starting" "${{app_name}}"
43-
[ -d "/var/run/${{app_name}}" ] || install -d -o "$DAEMON_USER" -g "$DAEMON_GROUP" -m755 "/var/run/${{app_name}}"
44-
logfile="${{daemon_log_file}}"
45-
stdout_redirect=""
46-
if [ ! -z "${logfile:-}" ]; then
47-
stdout_redirect=" >> ${{logdir}}/${{app_name}}/$logfile 2>&1"
48-
fi
49-
50-
if [ "$create_pidfile" = true ]; then
51-
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS "$stdout_redirect"
52-
else
53-
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS "$stdout_redirect"
54-
fi
55-
log_end_msg $?
40+
log_daemon_msg "Starting" "${{app_name}}"
41+
[ -d "/var/run/${{app_name}}" ] || install -d -o "$DAEMON_USER" -g "$DAEMON_GROUP" -m755 "/var/run/${{app_name}}"
42+
logfile="${{daemon_log_file}}"
43+
stdout_redirect=""
44+
if [ ! -z "${logfile:-}" ]; then
45+
stdout_redirect=" >> ${{logdir}}/${{app_name}}/$logfile 2>&1"
46+
fi
47+
48+
if [ "$create_pidfile" = true ]; then
49+
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS ${stdout_redirect}
50+
else
51+
start-stop-daemon --background --chdir ${{chdir}} --chuid "$DAEMON_USER" --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS ${stdout_redirect}
52+
fi
53+
log_end_msg $?
5654
}
5755

5856

5957
stop_daemon() {
60-
log_daemon_msg "Stopping" "${{app_name}}"
61-
start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" --retry=TERM/${{term_timeout}}/KILL/${{kill_timeout}}
62-
log_end_msg $?
63-
if [ "$create_pidfile" = true ]; then
64-
rm -f "$PIDFILE"
65-
fi
58+
log_daemon_msg "Stopping" "${{app_name}}"
59+
start-stop-daemon --stop --quiet --oknodo --pidfile "$PIDFILE" --retry=TERM/${{term_timeout}}/KILL/${{kill_timeout}}
60+
log_end_msg $?
61+
if [ "$create_pidfile" = true ]; then
62+
rm -f "$PIDFILE"
63+
fi
6664
}
6765

6866
case "$1" in

src/sbt-test/debian/sysvinit-deb/build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TaskKey[Unit]("check-startup-script") <<= (target, streams) map { (target, out)
4949
)
5050
assert(
5151
script.contains(
52-
"""start-stop-daemon --background --chdir /usr/share/debian-test --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS "$stdout_redirect"""
52+
"""start-stop-daemon --background --chdir /usr/share/debian-test --chuid "$DAEMON_USER" --make-pidfile --pidfile "$PIDFILE" --startas "$RUN_CMD" --start -- $RUN_OPTS ${stdout_redirect}"""
5353
),
5454
"script has wrong startup line\n" + script
5555
)

0 commit comments

Comments
 (0)