From b7e6edf08ac04f713b25c50a2633ed8436c26b68 Mon Sep 17 00:00:00 2001
From: Jochen Schalanda <jochen.schalanda@detasad.com.sa>
Date: Sun, 13 Jun 2010 07:27:33 +0000
Subject: [PATCH] Fixes #312 - Change working directory to $FOREMAN_HOME before starting.

---
 extras/debian/foreman.init |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/extras/debian/foreman.init b/extras/debian/foreman.init
index 717c1ae..6e76c76 100755
--- a/extras/debian/foreman.init
+++ b/extras/debian/foreman.init
@@ -39,7 +39,8 @@ is_true() {
 do_start()
 {
     if is_true "$START" ; then
-        start-stop-daemon --start --quiet --chuid $FOREMAN_USER --pidfile $FOREMAN_PID --exec $DAEMON -- $DAEMON_OPTS
+        start-stop-daemon --start --quiet --chuid "${FOREMAN_USER}" --pidfile "${FOREMAN_PID}" \
+                          --chdir "${FOREMAN_HOME}" --exec "${DAEMON}" -- $DAEMON_OPTS
     else
         echo ""
         echo "${NAME} not configured to start. Please edit /etc/default/${NAME} to enable."
@@ -48,7 +49,7 @@ do_start()
 
 do_stop()
 {
-    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $FOREMAN_PID
+    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile "${FOREMAN_PID}"
     RETVAL="$?"
     [ "$RETVAL" = 2 ] && return 2
     [ "$RETVAL" = 0 ] && rm -f $FOREMAN_PID
-- 
1.7.0.4

