aboutsummaryrefslogtreecommitdiffstats
path: root/testing/csync2/csync2.post-install
blob: ab02fa0c82a18889c1d75d5fcdb34a5d04fc96e8 (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
#!/bin/sh

OPENSSL=${OPENSSL:-openssl}
OPENSSL_CONF=${OPENSSL_CONF:-/etc/csync2/csync2-openssl.cnf}

CRTFILE=/etc/csync2/csync2_ssl_cert.pem
CSRFILE=/etc/csync2/csync2_ssl_cert.csr
KEYFILE=/etc/csync2/csync2_ssl_key.pem

if [ -f $CRTFILE ]; then
  echo "$CRTFILE already exists, won't overwrite"
  exit 0
fi

if [ -f $KEYFILE ]; then
  echo "$KEYFILE already exists, won't overwrite"
  exit 0
fi

$OPENSSL genrsa -out $KEYFILE 1024 || exit 2
$OPENSSL req -config $OPENSSL_CONF -new -key $KEYFILE -out $CSRFILE || exit 2
$OPENSSL x509 -req -days 365 -in $CSRFILE -signkey $KEYFILE -out $CRTFILE || exit 2

chmod 0600 $KEYFILE
rm $CSRFILE