summaryrefslogtreecommitdiffstats
path: root/debian/freeradius.postinst
blob: b1f853fe5af5efa8748e060bc1877b36b36d22cc (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
# vim:ts=2:sw=2:et

set -e

case "$1" in
  configure)
    if [ -z "$2" ]; then
      # Changed in 1.1.5-1 for new installs (we used to start at S50
      # and stop at K50)  We now start at S50 and stop at K19 so we
      # start after services which may be used and stop before them.
      update-rc.d freeradius start 50 2 3 4 5 . stop 19 0 1 6 . >/dev/null

      for file in radius.log radwtmp; do
        [ ! -f "/var/log/freeradius/${file}" ] && install -o freerad -g freerad -m 644 /dev/null /var/log/freeradius/${file}
      done

      action="start"
    else
      action="restart"
    fi

    if [ -z "$2" ]; then
      # Set up initial permissions on all the freeradius directories
      chown -R freerad:adm /var/log/freeradius
      chown -R freerad:freerad /etc/freeradius
      chmod 2750 /etc/freeradius
      find /etc/freeradius -type f -exec chmod 640 '{}' \;
    fi

    if dpkg --compare-versions "$2" lt 3.0.16+dfsg-3; then
      chmod 2750 /etc/freeradius
    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
    fi

    invoke-rc.d freeradius $action || true
    ;;

  abort-upgrade)
    invoke-rc.d freeradius restart || true
    ;;

  abort-remove)
    invoke-rc.d freeradius start || true
    ;;
esac

#DEBHELPER#

case "$1" in
  configure)
    # After removing conffiles (in the DEBHELPER part above), delete all
    # directories underneath /etc/freeradius which are now empty.
    find /etc/freeradius -type d -empty -delete
    ;;
esac

exit 0