This file is indexed.

postinst is in lavapdu-daemon 0.0.5-1.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

 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
#!/bin/sh
set -e

LAVAPDU_USER="pdudaemon"
LAVAPDU_PASS="pdudaemon"
LAVAPDU_NAME="lavapdu"
LAVA_DB_PORT=5432

die() {
    echo "$1"
    exit 1
}

install_database()
{
    # Create database user, if it doesn't exist
    if ! su postgres -c "psql \"-c SELECT usename FROM pg_user WHERE usename='$LAVAPDU_USER'\"" | grep "$LAVAPDU_USER"; then
        su postgres -c "createuser --no-createdb --encrypted --login --no-superuser --no-createrole --no-password --port $LAVA_DB_PORT $LAVAPDU_USER"|| "Failed to create database user"
    fi

    # Set a password for our new user
    su postgres -c "psql --port $LAVA_DB_PORT --quiet --command=\"ALTER USER \"$LAVAPDU_USER\" WITH PASSWORD '$LAVAPDU_PASS'\"" || die "Failed to set database password"

    # Create a database for our new user, if it doesn't exist
    if ! su postgres -c "psql -c \"SELECT datname FROM pg_database WHERE datname='$LAVAPDU_NAME'\"" | grep "$LAVAPDU_NAME"; then
        su postgres -c "createdb --port $LAVA_DB_PORT --locale=C.UTF-8 --encoding=UTF-8 --owner=$LAVAPDU_USER --template=template0 --no-password $LAVAPDU_NAME" || die "Failed to create a database"
    fi
}


if [ -x "/etc/init.d/lavapdu-listen" ]; then
    update-rc.d lavapdu-listen defaults >/dev/null
    invoke-rc.d lavapdu-listen start || exit $?
fi

if [ -x "/etc/init.d/lavapdu-runner" ]; then
    update-rc.d lavapdu-runner defaults >/dev/null
    invoke-rc.d lavapdu-runner start || exit $?
fi

case "$1" in
    configure)
        install_database
    ;;
    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

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



# Automatically added by dhpython:
if which pycompile >/dev/null 2>&1; then
	pycompile -p lavapdu-daemon 
fi

# End automatically added section