# https://selivan.github.io/2017/12/30/systemd-serice-always-restart.html
-f=/etc/systemd/system/openvpn-client-mail@.service
-if [[ ! -s $f || $(stat -c%s $f) != 1709 ]]; then
- cat >$f <<'EOF'
+tmpdir=$(mktemp -d)
+cat >$tmpdir/openvpn-client-mail@.service <<'EOF'
[Unit]
Description=OpenVPN tunnel for %I
After=syslog.target network-online.target
[Install]
WantedBy=multi-user.target
EOF
+tmp=$(install -vC $tmpdir/* /etc/systemd/system)
+rm -rf $tmpdir
+if [[ $tmp ]]; then
m systemctl daemon-reload
fi
case $HOSTNAME in
$MAIL_HOST|bk)
reload=false
+ tmpdir=$(mktemp -d)
for unit in exim4 spamassassin; do
- f=/etc/systemd/system/$unit.service.d/nn.conf
- if [[ ! -s $f || $(stat -c%s $f) != 244 ]]; then
- reload=true
- echo creating $f
- mkdir -p ${f%/*}
- cat >$f <<'EOF'
+ dir=/etc/systemd/system/$unit.service.d
+ mkdir -p $dir
+ cat >$tmpdir/nn.conf <<'EOF'
[Unit]
After=network.target
Requires=openvpn-client-mail@mail.service
# time to sleep before restarting a service
RestartSec=1
EOF
+ tmp=$(install -vC $tmpdir/* $dir)
+ if [[ $tmp ]]; then
+ reload=true
fi
done
+ rm -rf $tmpdir
if $reload; then
m systemctl daemon-reload
fi
case $HOSTNAME in
$MAIL_HOST|bk)
- # just noticed this in the config file, seems like a good idea.
+ # Just noticed this in the config file, seems like a good idea.
sed -i '/^\s*NICE\s*=/d' /etc/default/spamassassin
e 'NICE="--nicelevel 15"' >>/etc/default/spamassassin
m systemctl start spamassassin
;;
esac
-
##### end spamassassin config
m /a/exe/vpn-mk-client-cert -b mailclient -n mail -s /b/ds/mail-route li.iankelling.org
fi
-
-
m rsync -aiSAX --chown=root:root --chmod=g-s /a/bin/ds/mail-cert-cron /usr/local/bin
-
-cat >/etc/systemd/system/mailcert.service <<'EOF'
+### begin install timer
+tmpdir=$(mktemp -d)
+cat >$tmpdir/mailcert.service <<'EOF'
[Unit]
Description=Mail cert rsync
After=multi-user.target
Type=oneshot
ExecStart=/a/bin/log-quiet/sysd-mail-once mailcert /usr/local/bin/mail-cert-cron
EOF
-
-cat >/etc/systemd/system/mailcert.timer <<'EOF'
+cat >$tmpdir/mailcert.timer <<'EOF'
[Unit]
Description=Run mail-cert once a day
[Install]
WantedBy=timers.target
EOF
-m systemctl daemon-reload
+tmp=$(install -vC $tmpdir/* /etc/systemd/system)
+if [[ $tmp ]]; then
+ m systemctl daemon-reload
+fi
+rm -rf $tmpdir
+### end install timer
+
+
m systemctl start mailcert
m systemctl restart mailcert.timer
m systemctl enable mailcert.timer
echo "/nocow/exim4 /var/spool/exim4 none bind 0 0" >>/etc/fstab
fi
reload=false
- f=/etc/systemd/system/exim4.service.d/override.conf
- if [[ ! -s $f || $(stat -c%s $f) != 220 ]]; then
- reload=true
- mkdir -p ${f%/*}
- cat >$f <<'EOF'
+ tmpdir=$(mktemp -d)
+ cat >$tmpdir/override.conf <<'EOF'
[Unit]
# without this on exim, we get these kind of errors in paniclog on shutdown:
# Failed to create spool file /var/spool/exim4//input//1jCLxz-0008V4-V9-D: Permission denied
After=local-fs.target
After=network.target
EOF
+ dir=/etc/systemd/system/exim4.service.d
+ mkdir -p $dir
+ tmp=$(install -vC $tmpdir/* $dir)
+ rm -rf $tmpdir
+ if [[ $tmp ]]; then
m systemctl daemon-reload
fi
if ! mountpoint -q $sdir; then