Project

General

Profile

Download (1.01 KB) Statistics
| Branch: | Tag: | Revision:

root / u-auth.postinst @ d597367f

1
#! /bin/sh
2

    
3
set -e
4

    
5
NAME="u-auth"
6
USER=$NAME
7
GROUP=$NAME
8
CONFIG_DIR="/etc/$NAME"
9

    
10
case "$1" in
11
  configure)
12

    
13
    # make sure the administrative user exists
14
    if ! getent passwd $USER >/dev/null; then
15
      adduser --disabled-password  --quiet --system \
16
        --no-create-home --home /var/lib/$NAME \
17
        --gecos "$NAME user" --group $USER
18
    fi
19
    # ensure dirs ownership
20
    chown $USER:$GROUP /var/log/$NAME
21
    chown $USER:$GROUP /var/lib/$NAME/collectstatic
22
    chown $USER:$GROUP /var/lib/$NAME/static
23
    chown $USER:$GROUP /var/lib/$NAME/media
24
    # create a secret file
25
    SECRET_FILE=$CONFIG_DIR/secret
26
    if [ ! -f $SECRET_FILE ]; then
27
        echo -n "Generating Django secret..." >&2
28
        cat /dev/urandom | tr -dc [:alnum:]-_\!\%\^:\; | head -c70 > $SECRET_FILE
29
        chown root:$GROUP $SECRET_FILE
30
        chmod 0440 $SECRET_FILE
31
    fi
32
  ;;
33

    
34
  abort-upgrade|abort-remove|abort-deconfigure)
35
  ;;
36

    
37
  *)
38
    echo "postinst called with unknown argument \`$1'" >&2
39
    exit 1
40
  ;;
41
esac
42

    
43
#DEBHELPER#
44

    
45
exit 0
(16-16/16)