This file is indexed.

postinst is in phabricator 0~git20160124-1ubuntu1.

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

mode="$1"
version="$2"

# Source debconf library.
. /usr/share/debconf/confmodule

db_get "phabricator/domain_name"
domain_name="$RET"
db_get "phabricator/mysql_host"
mysql_host="$RET"
db_get "phabricator/phabricator_mysql_user"
phabricator_mysql_user="$RET"
db_get "phabricator/phabricator_mysql_pwd"
phabricator_mysql_pwd="$RET"
db_get "phabricator/webserver"
WWWTYPE="$RET"

#creating unprivileged system user to run the phabricator daemons
if ! getent passwd phabricator >/dev/null; then
    adduser --system  --ingroup www-data --home "/var/lib/phabricator" --quiet phabricator || true
elif [ $(id -gn phabricator) != www-data ]; then
    #we have a phabricator user, but it isn't in the right group
    usermod -g www-data phabricator
fi

local_disk_path="/var/lib/phabricator/phd_storage"
repo_default_local_path="/var/lib/phabricator/repositories"
log_directory="/var/log/phabricator"
local_conf_file="/var/lib/phabricator/local.json"

for dir in $repo_default_local_path $log_directory; do
    #create a statoverride unless one already exists
    if ! dpkg-statoverride --list $dir >/dev/null 2>&1; then
        dpkg-statoverride --update --add phabricator nogroup 755 $dir 
    fi
done

touch $local_conf_file

set_config() {
    #we check if the configuration option is already set or not, in order to avoid overwritting local modifications
    [[ $(/usr/share/phabricator/bin/config get $1 | jq -r '.config[] | select(.source=="local") | .status') == "set" ]] || /usr/share/phabricator/bin/config set $1 $2
}

case "$1" in
configure)
    /usr/share/phabricator/bin/config set phabricator.base-uri http://$domain_name/
esac

set_config storage.local-disk.path $local_disk_path
#PHP doesn't provide the correct timezone, so we override the (default) date.timezone php setting
#see http://us3.php.net/date_default_timezone_get
set_config phabricator.timezone $(cat /etc/timezone)

set_config phd.pid-directory "/run/phabricator"
#repository.default-local-path is where phabricator daemon will set up repositories
set_config repository.default-local-path $repo_default_local_path
set_config phd.log-directory $log_directory

if [[ -n $phabricator_mysql_user && -n $phabricator_mysql_pwd ]]; then
    /usr/share/phabricator/bin/config set mysql.host $mysql_host
    /usr/share/phabricator/bin/config set mysql.user $phabricator_mysql_user
    /usr/share/phabricator/bin/config set mysql.pass $phabricator_mysql_pwd
    set_config storage.mysql-engine.max-size 0
    /usr/share/phabricator/bin/storage upgrade --user $phabricator_mysql_user --password $phabricator_mysql_pwd --force
fi
#TODO:
#else
#	echo "Not finished. please reconfigure"

if ! dpkg-statoverride --list $local_conf_file >/dev/null 2>&1; then
    dpkg-statoverride --update --add root www-data 640 $local_conf_file 
fi

### Webserver configuration

ucf --debconf-ok /usr/share/phabricator/conf_templates/phabricator.apache.conf /etc/apache2/conf-available/phabricator.conf
ucfr phabricator /etc/apache2/conf-available/phabricator.conf
ucf --debconf-ok /usr/share/phabricator/conf_templates/phabricator.lighttpd.conf /etc/lighttpd/conf-available/20-phabricator.conf
ucfr phabricator /etc/lighttpd/conf-available/20-phabricator.conf
ucf --debconf-ok /usr/share/phabricator/conf_templates/phabricator.nginx.conf /etc/nginx/sites-available/phabricator.conf
ucfr phabricator /etc/nginx/sites-available/phabricator.conf

db_stop

# Update the webserver, if needed
case $WWWTYPE in
    apache2)
        #TODO: check if this is really the best place to modify the file
        sed -i "s/  ServerName .*/  ServerName $domain_name/" /etc/apache2/conf-available/phabricator.conf
        #       Sniplet adjusted from http://wiki.debian.org/Apache/PackagingFor24
        if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
            . /usr/share/apache2/apache2-maintscript-helper
            apache2_invoke enmod rewrite
            apache2_invoke enconf phabricator.conf
        elif  dpkg-query -f '${Version}'  -W 'apache2.2-common' > /dev/null 2>&1; then
            a2enmod -q rewrite
            [ -d /etc/apache2/conf.d/ ] && [ ! -h /etc/apache2/conf.d/phabricator.conf ] && ln -s ../conf-available/phabricator.conf /etc/apache2/conf.d/phabricator.conf
        else
            echo "Apache2 not installed, skipping"
        fi
        ;;
    lighttpd)
        if [ -e /etc/lighttpd/conf-available/20-phabricator.conf ] ; then
            sed -i "s/\$HTTP\[\"host\"\] =.* {/\$HTTP[\"host\"] == \"$domain_name\" {/" /etc/lighttpd/conf-available/20-phabricator.conf
            if which lighty-enable-mod >/dev/null 2>&1 ; then
                lighty-enable-mod phabricator
            else
                echo "Lighttpd not installed, skipping"
            fi
        fi
        ;;
    nginx)
        if [ -e /etc/nginx/sites-available/phabricator.conf ] ; then
            sed -i "s/  server_name .*/  server_name $domain_name;/" /etc/nginx/sites-available/phabricator.conf
            [ ! -h /etc/nginx/sites-enabled/phabricator.conf ] && ln -s /etc/nginx/sites-available/phabricator.conf /etc/nginx/sites-enabled/phabricator.conf
        fi
        ;;
    *)

        ;;
esac

# Always trigger reload of webservers if the configuration is enabled
if [ -e /etc/apache2/conf.d/phabricator.conf -o -e /etc/apache2/conf-enabled/phabricator.conf ] ; then
    invoke-rc.d apache2 reload || true
fi
if [ -e /etc/lighttpd/conf-enabled/20-phabricator.conf ] ; then
    #   We need to take care: bug #446324
    invoke-rc.d lighttpd reload 3>/dev/null || true
fi
if [ -e /etc/nginx/sites-available/phabricator.conf ] ; then
    invoke-rc.d nginx reload || true
fi

#we need to have a readable/writable local disk storage!
if ! dpkg-statoverride --list $local_disk_path >/dev/null 2>&1; then
    dpkg-statoverride --update --add www-data www-data 755 $local_disk_path
fi
# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
	if [ -x "/etc/init.d/phabricator" ]; then
		update-rc.d phabricator defaults >/dev/null
	fi
	if [ -x "/etc/init.d/phabricator" ] || [ -e "/etc/init/phabricator.conf" ]; then
		invoke-rc.d phabricator start || exit $?
	fi
fi
# End automatically added section


echo "Installation complete. You can now access Phabricator at $(/usr/share/phabricator/bin/config get phabricator.base-uri | jq '.config[0].value')"

exit 0