home
·
contact
·
privacy
projects
/
config
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4459e67
)
Improve friendliness of opendkim setup script.
author
Christian Heller
<c.heller@plomlompom.de>
Fri, 9 Oct 2015 13:18:37 +0000
(15:18 +0200)
committer
Christian Heller
<c.heller@plomlompom.de>
Fri, 9 Oct 2015 13:18:37 +0000
(15:18 +0200)
setup_opendkim.sh
patch
|
blob
|
history
diff --git
a/setup_opendkim.sh
b/setup_opendkim.sh
index fba3b5af932a4cfd79ea13fe2e6482c9a42d9bf9..b8058e5d380f747553651930232249029f06248a 100755
(executable)
--- a/
setup_opendkim.sh
+++ b/
setup_opendkim.sh
@@
-1,17
+1,30
@@
#!/bin/sh
#!/bin/sh
-set -x
set -e
selector=$1
file=$2
set -e
selector=$1
file=$2
+if [ ! -n "$selector" ]; then
+ cat << EOF
+Usage: $0 SELECTOR [KEYFILE] - set up DKIM system and configuration
+
+If existing KEYFILE is given, set up DKIM to use SELECTOR and apply key from
+KEYFILE.
+
+If existing KEYFILE is not given, generate KEYFILE and DNS TXT file for
+SELECTOR.
+EOF
+ exit
+fi
+
if [ ! "$(id -u)" -eq "0" ]; then
echo "Must be run as root."
if [ ! "$(id -u)" -eq "0" ]; then
echo "Must be run as root."
- exit
+ exit
1
fi
fi
+set -x
apt-get -y install opendkim
apt-get -y install opendkim
-if [ ! -n "$file" ]
|| [ ! -f "$file" ]
; then
+if [ ! -n "$file" ]; then
apt-get -y install opendkim-tools
opendkim-genkey -d plomlompom.com -s $selector
apt-get -y --purge autoremove opendkim-tools
apt-get -y install opendkim-tools
opendkim-genkey -d plomlompom.com -s $selector
apt-get -y --purge autoremove opendkim-tools
@@
-24,6
+37,12
@@
if [ ! -n "$file" ] || [ ! -f "$file" ]; then
echo
cat $selector.txt
else
echo
cat $selector.txt
else
+ if [ ! -f "$file" ]; then
+ set +x
+ echo
+ echo "Keyfile $file does not exist."
+ exit 1
+ fi
cp ~/config/systemfiles/opendkim.conf /etc/opendkim.conf
sed -r -i 's/^#Selector .*$/Selector '$selector'/' /etc/opendkim.conf
mkdir -p /etc/opendkim
cp ~/config/systemfiles/opendkim.conf /etc/opendkim.conf
sed -r -i 's/^#Selector .*$/Selector '$selector'/' /etc/opendkim.conf
mkdir -p /etc/opendkim