From a3409267f4f78f1ba23bf7d5d5e5b3da6584a0b4 Mon Sep 17 00:00:00 2001
From: John Locke <john@freelock.com>
Date: Thu, 19 Nov 2015 11:58:47 -0800
Subject: [PATCH] Patch from dcg: detect /etc/ssmtp.conf changes inside update
 script, instead of touching a /tmp file

---
 start.sh        | 7 +------
 update_ssmtp.sh | 6 ++++++
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/start.sh b/start.sh
index 793fd31..0c408d4 100755
--- a/start.sh
+++ b/start.sh
@@ -1,11 +1,6 @@
 #!/bin/bash
 
-if [[ -e /tmp/smtpconfig ]]; then
-  echo "smtp configured."
-else
-  update_ssmtp.sh
-  touch /tmp/smtpconfig
-fi
+update_ssmtp.sh
 
 
 if [[ ! -f ledgersmb.conf ]]; then
diff --git a/update_ssmtp.sh b/update_ssmtp.sh
index 518ba87..28ea885 100644
--- a/update_ssmtp.sh
+++ b/update_ssmtp.sh
@@ -1,4 +1,9 @@
 #!/bin/bash
+ConfiguredComment='# install script update_ssmtp.sh has configured ssmtp'
+grep -nc "$ConfiguredComment" /etc/ssmtp.conf && {
+    echo "smtp configured."
+    exit
+}
 
 sed -i \
     -e "s/\(root=\).*\$/\1$SSMTP_ROOT/g" \
@@ -10,3 +15,4 @@ sed -i \
 [ -z "$SSMTP_AUTH_PASS" ] || echo "AuthPass=$SSMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
 [ -z "$SSMTP_AUTH_METHOD" ] || echo "AuthMethod=$SSMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
 [ -z "$SSMTP_FROMLINE_OVERRIDE" ] || echo "FromLineOverride=$SSMTP_FROMLINE_OVERRIDE" >> /etc/ssmtp/ssmtp.conf
+echo "$ConfiguredComment" >> /etc/ssmtp/ssmtp.conf