summaryrefslogtreecommitdiffstats
path: root/debian/postinst
blob: a1a0b39e3f0432719bbc11312c62fbf3cc7e3e60 (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
#!/bin/sh

set -eu

copy_js_font_files()
{
  # Rspamd web interface doesn't support symlinks and directory traversal
  # copy javascript files from original Debian packages
  RSPAMD_CSS_DIR=/usr/share/rspamd/www/css
  RSPAMD_JS_LIB_DIR=/usr/share/rspamd/www/js/lib
  cp --remove-destination /usr/share/javascript/bootstrap4/js/bootstrap.bundle.min.js $RSPAMD_JS_LIB_DIR/bootstrap.bundle.min.js
  cp --remove-destination /usr/share/javascript/bootstrap4/css/bootstrap.min.css $RSPAMD_CSS_DIR/bootstrap.min.css
  cp --remove-destination /usr/share/javascript/jquery/jquery.min.js $RSPAMD_JS_LIB_DIR/jquery.min.js
  cp --remove-destination /usr/share/javascript/requirejs/require.js $RSPAMD_JS_LIB_DIR/require.min.js

  # remove path of previous versions, if existent
  if [ -f $RSPAMD_JS_LIB_DIR/jquery-3.3.1.min.js ]; then
    rm $RSPAMD_JS_LIB_DIR/jquery-3.3.1.min.js
  fi
  if [ -f $RSPAMD_JS_LIB_DIR/bootstrap.min.js ]; then
    rm $RSPAMD_JS_LIB_DIR/bootstrap.min.js
  fi

  # copy font files from original Debian package
  RSPAMD_FONT_DIR=/usr/share/rspamd/www/fonts
  cp --remove-destination /usr/share/fonts-glyphicons/glyphicons-halflings-regular.ttf $RSPAMD_FONT_DIR/glyphicons-halflings-regular.ttf
  cp --remove-destination /usr/share/fonts-glyphicons/glyphicons-halflings-regular.woff $RSPAMD_FONT_DIR/glyphicons-halflings-regular.woff
  cp --remove-destination /usr/share/fonts-glyphicons/glyphicons-halflings-regular.woff2 $RSPAMD_FONT_DIR/glyphicons-halflings-regular.woff2
}

case "$1" in
    configure)
      SERVER_HOME=/var/lib/rspamd
      SERVER_LOG=/var/log/rspamd
      SERVER_USER=_rspamd

      adduser --quiet \
              --system \
              --group \
              --home $SERVER_HOME \
              --no-create-home \
              --disabled-login \
              --gecos "rspamd spam filtering system" \
              --force-badname \
              $SERVER_USER

      chown $SERVER_USER: $SERVER_HOME $SERVER_LOG

      copy_js_font_files
    ;;

    triggered)
      copy_js_font_files
    ;;

    abort-*)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#