This file is indexed.

postinst is in openacs 5.7.0+dfsg-2.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
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#! /bin/sh
# postinst script for openacs 
#
# see: dh_installdeb(1)
#
# 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>
#        * <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
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

set -e

# Care about the directories and their permissions
fixDirs() {
    # Care about the repository
    repository=/var/lib/openacs
    if [ -d $repository ]; then
        # set the owner and change rights accordingly
        chown www-data:www-data $repository $repository/content-repository-content-files/
        chmod 0755 $repository $repository/content-repository-content-files/
    fi

    # Care about the log directory
    logdir=/var/log/aolserver4/openacs
    if [ -d $logdir ]; then
        # set the owner and change rights accordingly
        chown www-data:www-data $logdir
        chmod 0755 $logdir
    fi

    # Care about the app dir
    appdir=/usr/share/openacs
    if [ -d $appdir ]; then
        # set the owner and change rights accordingly
        chown -R www-data:www-data $appdir
    fi
}


# Install plpgsql on database and enable compatibility options (pgsql < 9.1)
fixDB_pre_9_1() {
    sqlfile=$(mktemp)
    echo "CREATE OR REPLACE LANGUAGE plpgsql;
          ALTER DATABASE $dbc_dbname SET default_with_oids = on;
          " > $sqlfile
    dbc_pgsql_exec_file $sqlfile
    rm -f $sqlfile
}

# Install plpgsql on database and enable compatibility options (pgsql = 9.1)
fixDB_9_1() {
    sqlfile=$(mktemp)
    echo "CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
          ALTER DATABASE $dbc_dbname SET default_with_oids = on;
          ALTER DATABASE $dbc_dbname SET standard_conforming_strings = off;
          " > $sqlfile
    dbc_pgsql_exec_file $sqlfile
    rm -f $sqlfile
}

# Install plpgsql on database and enable compatibility options (Wrapper)
fixDB() {
    fixDB_9_1
    fixDB_pre_9_1
}

# Create /etc/openacs/config.local file with dbconfig-common
# values, and manage with ucf.
createConfig() {
    dbc_dbserver=$1
    dbc_dbpass=$2
    dbc_dbport=$3
    dbc_dbuser=$4

    # Create file
    localconfigtmp=$(mktemp)
    localconfig="/etc/openacs/config.local"
    cat > $localconfigtmp <<EOF
# Local Openacs database settings, managed by debconf.
db_host=${dbc_dbserver}
db_password=${dbc_dbpass}
db_port=${dbc_dbport}
db_user=${dbc_dbuser}
EOF
    # Install file
    if [ -d /etc/openacs -a -f $localconfigtmp ]; then
        ucf --debconf-ok $localconfigtmp $localconfig || cp -f $localconfigtmp $localconfig
        chmod 640 $localconfig
        chown www-data:www-data $localconfig
        rm -f $localconfigtmp
    fi
}

case "$1" in
    configure)

        # dbconfig-common settings
        dbc_first_version="5.7.0+dfsg-1"
        dbc_pgsql_createdb_encoding='UTF8'

        # source debconf stuff
        [ -f /usr/share/debconf/confmodule ] && . /usr/share/debconf/confmodule

        # source dbconfig-common stuff
        if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
            . /usr/share/dbconfig-common/dpkg/postinst.pgsql
            dbc_go openacs $@ || echo 'Automatic configuration using dbconfig-common failed!'

            # Install plpgsql on database and enable compatibility options
            fixDB || echo "Error installing plpgsql and enabling pgsql compatibility options"

            # Create and install /etc/openacs/config.local
            if [ -z "$dbc_dbserver" ]; then
                dbc_dbserver="localhost";
            fi
            if [ -z "$dbc_dbport" ]; then
                dbc_dbport="5432";
            fi
            createConfig $dbc_dbserver $dbc_dbpass $dbc_dbport $dbc_dbuser || "Error creating /etc/openacs/config.local"
        fi

        # Fix directories
        fixDirs || "Error setting repository|logdir|appdir permissions"

        # Restart aolserver
        [ -f /etc/init.d/aolserver4 ] && invoke-rc.d aolserver4 start
    ;;

    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.


db_stop

exit 0