2018-02-06 07:11:57 +00:00
|
|
|
#!/usr/bin/env bash
|
2018-03-08 21:51:10 +00:00
|
|
|
# postsrsd-wrapper.sh, version 0.2.1
|
2018-02-06 07:11:57 +00:00
|
|
|
|
|
|
|
DOMAINNAME="$(hostname -d)"
|
|
|
|
sed -i -e "s/localdomain/$DOMAINNAME/g" /etc/default/postsrsd
|
|
|
|
|
2018-03-10 12:41:20 +00:00
|
|
|
postsrsd_secret_file='/etc/postsrsd.secret'
|
|
|
|
postsrsd_state_dir='/var/mail-state/etc-postsrsd'
|
|
|
|
postsrsd_state_secret_file="${postsrsd_state_dir}/postsrsd.secret"
|
|
|
|
|
|
|
|
generate_secret() {
|
|
|
|
( umask 0077
|
|
|
|
dd if=/dev/urandom bs=24 count=1 2>/dev/null | base64 -w0 > "$1" )
|
|
|
|
}
|
|
|
|
|
2018-03-08 21:51:10 +00:00
|
|
|
if [ -n "$SRS_SECRET" ]; then
|
2018-03-10 12:41:20 +00:00
|
|
|
( umask 0077
|
|
|
|
echo "$SRS_SECRET" | tr ',' '\n' > "$postsrsd_secret_file" )
|
|
|
|
else
|
|
|
|
if [ "$ONE_DIR" = 1 ]; then
|
|
|
|
if [ ! -f "$postsrsd_state_secret_file" ]; then
|
|
|
|
install -d -m 0775 "$postsrsd_state_dir"
|
|
|
|
generate_secret "$postsrsd_state_secret_file"
|
|
|
|
fi
|
|
|
|
install -m 0400 "$postsrsd_state_secret_file" "$postsrsd_secret_file"
|
|
|
|
elif [ ! -f "$postsrsd_secret_file" ]; then
|
|
|
|
generate_secret "$postsrsd_secret_file"
|
|
|
|
fi
|
2018-03-08 21:51:10 +00:00
|
|
|
fi
|
|
|
|
|
2018-02-18 19:53:13 +00:00
|
|
|
if [ -n "$SRS_EXCLUDE_DOMAINS" ]; then
|
|
|
|
sed -i -e "s/^#\?SRS_EXCLUDE_DOMAINS=.*$/SRS_EXCLUDE_DOMAINS=$SRS_EXCLUDE_DOMAINS/g" /etc/default/postsrsd
|
|
|
|
fi
|
|
|
|
|
2018-02-06 07:11:57 +00:00
|
|
|
/etc/init.d/postsrsd start
|