debian/littlebird-tc-core.postinst
changeset 14 1267d8034336
parent 11 24417d8949b5
child 17 d6923e55cfae
equal deleted inserted replaced
12:3572ec238dc1 14:1267d8034336
     1 #!/bin/sh
     1 #!/bin/sh
     2 echo "$0: $@" >&2
     2 echo "$0: $@" >&2
     3 # postinst script for littlebird
     3 # postinst script for littlebird
     4 #
     4 #
     5 # see: dh_installdeb(1)
     5 # see: dh_installdeb(1)
       
     6 . /usr/share/debconf/confmodule
     6 
     7 
     7 set -e
     8 set -e
     8 
     9 
     9 # summary of how this script can be called:
    10 # summary of how this script can be called:
    10 #        * <postinst> `configure' <most-recently-configured-version>
    11 #        * <postinst> `configure' <most-recently-configured-version>
    24 
    25 
    25     DIR=/srv/www/littlebird/TrustCenter/data
    26     DIR=/srv/www/littlebird/TrustCenter/data
    26     chown -R :www-data "$DIR"
    27     chown -R :www-data "$DIR"
    27     chmod -R g+w "$DIR"
    28     chmod -R g+w "$DIR"
    28 
    29 
       
    30     # Timezone in /usr/local/zend/etc/php.ini
       
    31     f=/usr/local/zend/etc/php.ini
       
    32     perl -pi -e 's{^;?\s*(date\.timezone\s*=).*$}{$1 "Europe/Berlin"}' $f
       
    33 
       
    34     # not sure if this conforms to policy: changing another packages
       
    35     # config files
       
    36     if test -d /etc/php5/cli; then
       
    37 	echo "# linking php.ini to zend" >&2
       
    38 	( set -e
       
    39 	  cd /etc/php5/cli
       
    40 	  s=/usr/local/zend/etc/conf.php.ini
       
    41 	  if test `readlink -f php.ini` != `readlink -f $s`
       
    42 	  then
       
    43 	      rm -vf php.ini
       
    44 	      ln -vs $s php.ini
       
    45 	  fi
       
    46 	)
       
    47     fi
       
    48 
       
    49     if test -d "/etc/php5/conf.d"; then
       
    50 	echo "# linkin other zend inis" >&2
       
    51 	( set -e
       
    52 	  cd /etc/php5/conf.d
       
    53 	  for p in mysqli.ini curl.ini mcrypt.ini gd.ini
       
    54 	  do
       
    55 	    s=/usr/local/zend/etc/conf.d/$p
       
    56 	    if test `readlink -f $p` != `readlink -f $s`
       
    57 	    then
       
    58 		rm -vf $p
       
    59 		ln -vs $s .
       
    60 	    fi
       
    61 	  done
       
    62 	 )
       
    63     fi
       
    64 
       
    65 
       
    66     # apache configuration
       
    67     db_get littlebird-tc/web/servername && servername="$RET" || true
       
    68     db_get littlebird-tc/web/serveradmin && serveradmin="$RET" || true
       
    69     db_get littlebird-tc/web/crt && crt="$RET" || true
       
    70     db_get littlebird-tc/web/key && key="$RET" || true
       
    71 
       
    72     # snakeoil certificate
       
    73     if test "$crt" && test "$key" && ! test -f "$crt" && ! test -f "$key"; then
       
    74 	mkdir -p `dirname $crt`
       
    75 	mkdir -p `dirname $key`
       
    76 	openssl req -new -x509 -days 10 -subj "/O=DEMO/CN=$servername" \
       
    77 	    -out "$crt" -keyout "$key" -nodes
       
    78     fi
       
    79 
       
    80     # tweak the config file, but just the lines following a magical
       
    81     # debconf line
       
    82     perl - serveradmin="$serveradmin" servername="$servername" \
       
    83 	   crt="$crt" key="$key" <<'_'
       
    84 	use strict;
       
    85 	use warnings;
       
    86 	my $mark = '# debconf:';
       
    87 	my %o;
       
    88 	foreach (@ARGV) { my ($k, $v) = split /=/, $_, 2; $o{$k} = $v; }
       
    89 	open(F, "+</etc/apache2/conf.d/littlebird-tc") or die;
       
    90         $_ = join "", <F>;
       
    91 	s|^(([ \t]*?)# debconf: (.*?){{(.*?)}}(.*?)\n).*?\n|$1$2$3$o{$4}$5\n|migs;
       
    92 	seek(F, 0, 0);
       
    93 	print(F $_);
       
    94 	truncate(F, tell F);
       
    95 	close(F);
       
    96 _
       
    97 
       
    98     # need log dir(s)
       
    99     ( . /etc/apache2/envvars
       
   100       file=`perl -ne '/^\s*errorlog\s+(\S+)/i&&print "$1\n"' /etc/apache2/conf.d/littlebird-tc`
       
   101       dir=`eval dirname "$file"`
       
   102       mkdir -p "$dir"
       
   103       file=`perl -ne '/^\s*customlog\s+(\S+)/i&&print "$1\n"' /etc/apache2/conf.d/littlebird-tc`
       
   104       dir=`eval dirname "$file"`
       
   105       mkdir -p "$dir"
       
   106     )
       
   107 
       
   108 
       
   109     invoke-rc.d apache2 reload 1>&1
       
   110     echo >&2
       
   111 
    29     ;;
   112     ;;
    30 
   113 
    31     abort-upgrade|abort-remove|abort-deconfigure)
   114     abort-upgrade|abort-remove|abort-deconfigure)
    32     ;;
   115     ;;
    33 
   116 
    38 esac
   121 esac
    39 
   122 
    40 # dh_installdeb will replace this with shell code automatically
   123 # dh_installdeb will replace this with shell code automatically
    41 # generated by other debhelper scripts.
   124 # generated by other debhelper scripts.
    42 
   125 
    43 #DEBHELPER#
   126 
    44 
   127 
    45 exit 0
   128 exit 0