summaryrefslogtreecommitdiff
path: root/package/sslenv
blob: 67cd6018c326673f874dc01847a918d21947a2ad (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
36
37
38
39
40
41
42
#!/bin/sh

shout() { echo "${0}: $@" >&2; }
barf() { shout "fatal: $@"; exit 111; }
safe() { "$@" || barf "cannot $@"; }

safe umask 022
here=`env - PATH=$PATH pwd`
mypwd=${here%package}
mypwd=${mypwd%/}
home=`head -1 $mypwd/conf-home`

nofiles=`grep auxiliar $mypwd/conf-ids | awk -F: '{print $2}'`
sqmtls=`grep TLS $mypwd/conf-ids | awk -F: '{print $2}'`

safe mkdir -p $home/ssl
safe chown $sqmtls:$nofiles $home/ssl

ucspi=`head -1 $mypwd/conf-ucspissl`

if [ -d $ucspi/etc ] 
then
  for i in `ls $ucspi/etc`
  do 
    shout "Copying ucspi-ssl file '$i' to $home/ssl"
    safe cp "$ucspi/etc/$i" "$home/ssl/$i"
    safe chown $sqmtls:$nofiles "$home/ssl/$i"
  done
else
  barf "Can't find ucspi-ssl dir. Check 'conf-ucspissl'."
fi 

[ -f $mypwd/service/ssl.env ] && \
safe cat $mypwd/service/ssl.env \
     | eval sed -e 's}QMAIL}$home}g' \
                -e 's}SQMTLS}$sqmtls}g' \
                -e 's}NOFILES}$nofiles}g' \
     > $home/ssl/ssl.env

shout "Environment for s/qmail TLS defined in $home/ssl/ssl.env"

exit 0