summaryrefslogtreecommitdiffstats
path: root/debian/freeradius-config.postinst
blob: b230778149c370227700d288ba85bb4aab4f5999 (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
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
# vim:ts=2:sw=2:et

set -e

case "$1" in
  configure)
    if [ -z "$2" ]; then
      # Create snakeoil certificates on initial install
      if grep -q -r 'etc/ssl/\(certs\|private\)/ssl-cert-snakeoil' /etc/freeradius; then
        if test ! -e /etc/ssl/certs/ssl-cert-snakeoil.pem || \
           test ! -e /etc/ssl/private/ssl-cert-snakeoil.key; then
          make-ssl-cert generate-default-snakeoil
        fi
        if getent group ssl-cert >/dev/null; then
          # freeradius-common dependency also provides us with adduser
          adduser --quiet freerad ssl-cert
        fi
      fi

      if grep -q -r 'dh_file = \${certdir}/dh' /etc/freeradius && \
         test ! -f /etc/freeradius/3.0/certs/dh; then
        RANDFILE=/dev/urandom openssl dhparam -out /etc/freeradius/3.0/certs/dh 1024
      fi
    fi

    # Create links for default sites, but only if this is an initial
    # install or an upgrade from before there were links; users may
    # want to remove them...
    if [ -z "$2" ]; then
      for site in default inner-tunnel; do
        if test ! -h /etc/freeradius/3.0/sites-enabled/$site && \
           test ! -e /etc/freeradius/3.0/sites-enabled/$site; then
          ln -s ../sites-available/$site /etc/freeradius/3.0/sites-enabled/$site
        fi
      done
      for module in always attr_filter chap detail detail.log \
        digest dynamic_clients eap echo exec expiration expr files \
        linelog logintime mschap ntlm_auth pap passwd preprocess \
        radutmp realm replicate soh sradutmp unix unpack utf8; do
        if test ! -h /etc/freeradius/3.0/mods-enabled/$module && \
           test ! -e /etc/freeradius/3.0/mods-enabled/$module; then
          ln -s ../mods-available/$module /etc/freeradius/3.0/mods-enabled/$module
        fi
      done
    fi
    ;;
esac

#DEBHELPER#

exit 0