aboutsummaryrefslogtreecommitdiffstats
path: root/community/postsrsd/postsrsd.initd
blob: 4256c3942dd0f8dd5d4db5a8d47698840772f286 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/sbin/openrc-run

description="Postfix SRS Daemon"
pidfile="/run/postsrsd.pid"
command="/usr/sbin/postsrsd"
command_args="-D
              -d \"${SRS_DOMAIN}\"
              -s ${SRS_SECRET-/etc/postsrsd/postsrsd.secret}
              -f ${SRS_FORWARD_PORT-10001}
              -r ${SRS_REVERSE_PORT-10002}
              -p \"${pidfile}\"
              -u \"${RUN_AS-postsrsd}\"
              -c \"${CHROOT-/usr/lib/postsrsd}\"
              -a \"${SRS_SEPARATOR-=}\""

stopsig="SIGTERM"

start_pre() {
        if [ -z "${SRS_DOMAIN}" ]
        then
                eerror "SRS_DOMAIN is not set"
                return 1
        fi

        if [ ! -s /etc/postsrsd/postsrsd.secret ]
        then
                ebegin "Generating secret"
                dd if=/dev/urandom bs=18 count=1 status=none \
                    | base64 >${SRS_SECRET}

                chmod 0600 ${SRS_SECRET}
                chown postsrsd ${SRS_SECRET}
                eend $?
        fi
}