From: Christian Heller <c.heller@plomlompom.de>
Date: Fri, 9 Oct 2015 04:18:57 +0000 (+0200)
Subject: Fix issues with OpenDKIM script.
X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7B%20web_path%20%7D%7D/process?a=commitdiff_plain;h=258962e9d3b4f113ea5ba69379c7aeca30875842;p=config

Fix issues with OpenDKIM script.
---

diff --git a/setup_opendkim.sh b/setup_opendkim.sh
index 6d9749b..cee5ce8 100755
--- a/setup_opendkim.sh
+++ b/setup_opendkim.sh
@@ -4,7 +4,7 @@ set -e
 selector=$1
 file=$2
 
-if [ "$(id -u)" -eq "0" ]; then
+if [ ! "$(id -u)" -eq "0" ]; then
     echo "Must be run as root."
     exit
 fi
@@ -18,7 +18,8 @@ fi
 
 sed -r -i 's/^#Selector .*$/Selector '$selector'/' /etc/opendkim.conf
 
-if [ ! -f $file ]; then
+mkdir -p /etc/opendkim
+if [ -n $file ] || [ ! -f $file ]; then
     opendkim-genkey -d plomlompom.com -s $selector
     mv "$selector".private /etc/opendkim/dkim.key
 else
@@ -26,7 +27,7 @@ else
 fi
 
 cp ~/config/systemfiles/main.cf /etc/postfix/main.cf
-echo >> /etc/postfix/main.cf << EOF
+cat >> /etc/postfix/main.cf << EOF
 
 # Use opendkim at given port as mail filter.
 non_smtpd_milters = inet:localhost:12301