File: coturn.postinst

package info (click to toggle)
coturn 4.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,240 kB
  • sloc: ansic: 38,387; sh: 1,857; cpp: 778; makefile: 315; sql: 76; perl: 57
file content (78 lines) | stat: -rw-r--r-- 2,407 bytes parent folder | download | duplicates (3)
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
70
71
72
73
74
75
76
77
78
#!/bin/sh

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

# $1 = version of the package being upgraded.
install() {

    TURNSERVER_GROUP=turnserver
    if ! getent group "$TURNSERVER_GROUP" >/dev/null; then
        addgroup --system "$TURNSERVER_GROUP" || exit 1
    fi

    TURNSERVER_USER=turnserver
    if ! getent passwd "$TURNSERVER_USER" >/dev/null; then
        adduser --system \
           --home / \
           --shell /bin/false \
           --no-create-home \
           --ingroup "$TURNSERVER_GROUP" \
           --disabled-password \
           --disabled-login \
           --gecos "turnserver daemon" \
               "$TURNSERVER_USER" || exit 1
    fi

    # Don't ship the empty database; generate it on-demand. (#929269)
    TURNDB_DIR=/var/lib/turn
    TURNDB_SQLITE=$TURNDB_DIR/turndb
    TURNDB_SCHEMA=/usr/share/coturn/schema.sql

    if [ ! -e "$TURNDB_SQLITE" ] && [ -e "$TURNDB_SCHEMA" ]; then
        echo "I: Creating $TURNDB_SQLITE from $TURNDB_SCHEMA" >&2
        ( umask 007 && sqlite3 "$TURNDB_SQLITE" < "$TURNDB_SCHEMA" )
        chown "$TURNSERVER_USER":"$TURNSERVER_GROUP" "$TURNDB_SQLITE"
    fi
    if ! dpkg-statoverride --list "$TURNDB_DIR" >/dev/null 2>&1; then
        dpkg-statoverride --update --add "$TURNSERVER_USER" "$TURNSERVER_GROUP" 775 "$TURNDB_DIR"
    fi

    TURNSERVER_CONFIG=/etc/turnserver.conf
    if ! dpkg-statoverride --list "$TURNSERVER_CONFIG" >/dev/null 2>&1; then
        dpkg-statoverride --update --add root "$TURNSERVER_GROUP" 640 "$TURNSERVER_CONFIG"
    fi
}

case "$1" in
    configure)
        install "$2"
        ;;

    abort-upgrade|abort-remove|abort-deconfigure)
        ;;

    *)
        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#

exit 0