summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHorus32015-06-25 14:39:30 +0200
committerHorus32015-06-25 14:39:30 +0200
commit05557f567380e44326d0822de450642c2b74e6c8 (patch)
tree1a229b8f09ba89da77e4a74bc426a4a7b2d2b350
parentf8a4da578bc8f58924ef060b60c472ade8390d55 (diff)
downloadfreemail-05557f567380e44326d0822de450642c2b74e6c8.tar.gz
Chang start script to better integrate with start-stop-daemon.
-rw-r--r--Makefile16
1 files changed, 12 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 6f76677..123e1f6 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,9 @@
# Modify env.sh and uncomment to change config.
include env.sh
+IMPORT_FILE:=./import.go
+APP:=mailer
+
# Start the race detector with "RACE=1 make test" on the command line.
ifdef RACE
RACE:=-race
@@ -22,9 +25,10 @@ else
EXTERNAL:=
endif
+ifndef LOGDIR
+ LOGDIR := /home/horus/logs/$(APP)
+endif
-IMPORT_FILE:=./import.go
-APP:=mailer
# Include the sqlit3 database in archiv.
ifeq ($(FREEMAIL_DB_DRIVER), sqlite3)
@@ -89,8 +93,11 @@ database_all: sqlite3 mysql postgresql
@echo "Created import file for all databases."
pack: gen_config
- echo "#!/bin/sh" > start.sh && \
- echo ". ./_env.sh && ./$(APP)" >> start.sh && \
+ echo "#!/bin/bash" > start.sh && \
+ echo 'DIR=$$( cd "$$( dirname "$${BASH_SOURCE[0]}" )" && pwd )' >> start.sh && \
+ echo 'cd "$$DIR"' >> start.sh && \
+ echo 'source "$$DIR/_env.sh"' >> start.sh && \
+ echo 'exec "$$DIR/mailer" >> "$$LOGDIR/$(APP).log" 2 >> "$$LOGDIR/$(APP).err"' >> start.sh && \
chmod +x start.sh && \
if [ ! -d $(FREEMAIL_DB_DIR) ]; then \
mkdir $(FREEMAIL_DB_DIR); \
@@ -155,6 +162,7 @@ gen_config: _test_build
echo "export FREEMAIL_SMTP_MAILER_MX=$(FREEMAIL_SMTP_MAILER_MX)" >> _env.sh
echo "export FREEMAIL_SMTP_PASSWORD=$(FREEMAIL_SMTP_PASSWORD)" >> _env.sh
echo "export FREEMAIL_SMTP_ADRESS=$(FREEMAIL_SMTP_ADRESS)" >> _env.sh
+ echo "export LOGDIR=$(LOGDIR)" >> _env.sh
@chmod +x _env.sh
restart: kill build run