This file is indexed.

postinst is in redmine 3.2.1-2.

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

set -e

. /usr/share/debconf/confmodule

#######################################################################
# update Gemfile.lock, always
#######################################################################
rm -f /var/lib/redmine/Gemfile.lock
(cd /usr/share/redmine && bundle --local --quiet)
chown www-data:www-data /var/lib/redmine/Gemfile.lock

#######################################################################
# create necessary directories
#######################################################################

mkdir -p /var/log/redmine

#######################################################################
# manage instances
#######################################################################

. /usr/share/dbconfig-common/dpkg/postinst

manage_instance() {
  local instance="$1"
  shift

  db_get redmine/instances/$instance/database-type || true
  local dbtype="$RET"

  dbc_generate_include=template:/etc/redmine/$instance/database.yml
  dbc_generate_include_args="-o template_infile=/usr/share/redmine/templates/database-${dbtype}.yml.template"
  dbc_generate_include_owner="root:www-data"
  dbc_generate_include_perms="640"
  dbc_dbfile_owner="root:www-data"
  dbc_dbuser=redmine_$instance
  # this is for sqlite3 to be r/w for www-data
  dbc_dbfile_perms="0660"
  dbc_mysql_createdb_encoding="UTF8"
  dbc_pgsql_createdb_encoding="UTF8"
  dbc_dbname=redmine_$instance

  if db_get redmine/instances/$instance/db/basepath && [ -n "$RET" ]; then
    dbc_basepath="$RET"
  fi

  /usr/share/redmine/bin/redmine-instances create $instance

  dbc_go redmine/instances/$instance "$@"

  local secret_key=/etc/redmine/$instance/secret_key.txt
  if [ ! -f $secret_key ]; then
    openssl rand -hex 16 > $secret_key
  fi
  chown root:www-data $secret_key
  chmod 0640  $secret_key

  cd /usr/share/redmine
  su www-data -s /bin/sh -c "REDMINE_INSTANCE=$instance SCHEMA=/dev/null bundle exec rake db:migrate"

  db_get redmine/instances/$instance/default-language || true
  REDMINE_LANG="${RET:-en}"
  su www-data -s /bin/sh -c "REDMINE_INSTANCE=$instance REDMINE_LANG=$REDMINE_LANG bundle exec rake redmine:load_default_data"
}

db_get redmine/current-instances || true
instances="$RET"
for inst in $instances; do
  manage_instance "$inst" "$@"
done

##