File: postinst

package info (click to toggle)
otrs2 2.0.4p01-17
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 7,892 kB
  • ctags: 4,437
  • sloc: perl: 81,607; xml: 8,135; sql: 8,013; sh: 1,113; makefile: 22; php: 16
file content (72 lines) | stat: -rw-r--r-- 1,732 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

set -e

OTRSHOME=/usr/share/otrs
CONFIGFILES="Kernel/Config.pm Kernel/Config/GenericAgent.pm maintainance.html"

setup_database()
{
  . /usr/share/dbconfig-common/dpkg/postinst
  dbc_generate_include="perl:/etc/otrs/database.pm"
  dbc_generate_include_owner="otrs:www-data"
  dbc_generate_include_perms="0640"
  dbc_first_version="2.0.4p01-10"
  dbc_go otrs2 "$@"
}

setup_cron()
{
  # save old cron config to new file /etc/otrs/cron before removing it
  if [ -e /etc/cron.d/otrs_aaa_base ]; then
    cat /etc/cron.d/otrs_* > /etc/otrs/cron
    for FILE in /etc/cron.d/otrs_*; do
      ucf --purge $FILE
      mv -f $FILE $FILE.dpkg-old
    done
  fi

  # register the new cron config
  TMPFILE=$(mktemp)
  cat /var/lib/otrs/cron/* > $TMPFILE
  ucf --three-way --debconf-ok $TMPFILE /etc/otrs/cron
  rm -f $TMPFILE
}

setup_apache()
{
  if [ -e /etc/otrs/apache2-httpd.include.conf -a \
     ! -e /etc/apache2/conf.d/otrs2 ]; then
    mv /etc/otrs/apache2-httpd.include.conf /etc/apache2/conf.d/otrs2
  fi
  ucf --three-way --debconf-ok $OTRSHOME/scripts/apache2-httpd-new.include.conf \
    /etc/apache2/conf.d/otrs2
  a2enmod perl
  a2enmod rewrite
  db_stop
  invoke-rc.d apache2 force-reload
}

. /usr/share/debconf/confmodule

case "$1" in
  configure|reconfigure)
  setup_database "$@"
  for FILE in $CONFIGFILES; do
    ucf --three-way --debconf-ok $OTRSHOME/$FILE.dist /etc/otrs/$FILE
  done
  setup_cron
  ucf --three-way --debconf-ok $OTRSHOME/.fetchmailrc.dist /etc/otrs/fetchmailrc
  chmod 600 /etc/otrs/fetchmailrc
  setup_apache
  $OTRSHOME/bin/SetPermissions.sh $OTRSHOME otrs www-data www-data www-data
  ;;

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

#DEBHELPER#