debian/littlebird-tc-core.postinst
changeset 54 706239603081
parent 28 f87fe5029832
child 63 4b1a3d9a3cae
equal deleted inserted replaced
52:f90939237a7c 54:706239603081
    27     DIR=/srv/www/littlebird/TrustCenter/data
    27     DIR=/srv/www/littlebird/TrustCenter/data
    28     chown -R :www-data "$DIR"
    28     chown -R :www-data "$DIR"
    29     chmod -R g+w "$DIR"
    29     chmod -R g+w "$DIR"
    30 
    30 
    31     # Timezone in /usr/local/zend/etc/php.ini
    31     # Timezone in /usr/local/zend/etc/php.ini
       
    32     # note: this file is handled as a conffile under ucf control
    32     f=/usr/local/zend/etc/php.ini
    33     f=/usr/local/zend/etc/php.ini
    33     perl -pi -e 's{^;?\s*(date\.timezone\s*=).*$}{$1 "Europe/Berlin"}' $f
    34     perl -pi -e 's{^;?\s*(date\.timezone\s*=).*$}{$1 "Europe/Berlin"}' $f
    34 
    35 
    35     # not sure if this conforms to policy: changing another packages
    36     # not sure if this conforms to policy: changing another packages
    36     # config files
    37     # config files
    93 	    db_input critical littlebird-tc/web/cert-failed || true
    94 	    db_input critical littlebird-tc/web/cert-failed || true
    94 	    db_go || true
    95 	    db_go || true
    95 	fi
    96 	fi
    96     fi
    97     fi
    97 
    98 
       
    99     # wozu brauchen wir das? hs - 9/2011
       
   100     test "$crt" && ucfr littlebird-tc-core "$crt"
       
   101     test "$key" && ucfr littlebird-tc-core "$key"
       
   102 
    98     # tweak the config file, but just the lines following a magical
   103     # tweak the config file, but just the lines following a magical
    99     # debconf line
   104     # debconf line
   100     perl - serveradmin="$serveradmin" servername="$servername" serverport="$serverport" \
   105     cp /usr/share/doc/littlebird-tc/examples/apache/littlebird-tc $tmp
       
   106     perl - "$tmp" serveradmin="$serveradmin" servername="$servername" serverport="$serverport" \
   101 	   crt="$crt" key="$key" <<'_'
   107 	   crt="$crt" key="$key" <<'_'
   102 	use strict;
   108 	use strict;
   103 	use warnings;
   109 	use warnings;
   104 	my $mark = '# debconf:';
   110 	my $mark = '# debconf:';
       
   111 	my $tmpfile = shift;
   105 	my %o;
   112 	my %o;
   106 	foreach (@ARGV) { my ($k, $v) = split /=/, $_, 2; $o{$k} = $v }
   113 	foreach (@ARGV) { my ($k, $v) = split /=/, $_, 2; $o{$k} = $v }
   107 	if ($o{serverport} eq "443") { 
   114 	if ($o{serverport} eq "443") { 
   108 	    $o{serverurl} = "https://$o{servername}/";
   115 	    $o{serverurl} = "https://$o{servername}/";
   109 	    $o{listen} = "# Listen 443";
   116 	    $o{listen} = "# Listen 443";
   112 	    $o{serverurl} = "https://$o{servername}:$o{serverport}/";
   119 	    $o{serverurl} = "https://$o{servername}:$o{serverport}/";
   113 	    $o{listen} = "Listen $o{serverport}";
   120 	    $o{listen} = "Listen $o{serverport}";
   114 	}
   121 	}
   115 	
   122 	
   116 
   123 
   117 	open(F, "+</etc/apache2/conf.d/littlebird-tc") or die;
   124 	open(F, "+<$tmpfile") or die;
   118 	$_ = join "" => <F>;
   125 	$_ = join "" => <F>;
   119 	s|^(([ \t]*?)# debconf: (.*?){{(.*?)}}(.*?)\n).*?\n|$1$2$3$o{$4}$5\n|migs;
   126 	s|^(([ \t]*?)# debconf: (.*?){{(.*?)}}(.*?)\n).*?\n|$1$2$3$o{$4}$5\n|migs;
   120 	seek(F, 0, 0);
   127 	seek(F, 0, 0);
   121 	print(F $_);
   128 	print(F $_);
   122 	truncate(F, tell F);
   129 	truncate(F, tell F);
   123 	close(F);
   130 	close(F);
   124 _
   131 _
       
   132 
       
   133     ucf --debconf-ok $tmp /etc/apache2/conf.d/littlebird-tc
   125 
   134 
   126     # need log dir(s)
   135     # need log dir(s)
   127     ( . /etc/apache2/envvars
   136     ( . /etc/apache2/envvars
   128       file=`perl -ne '/^\s*errorlog\s+(\S+)/i&&print "$1\n"' /etc/apache2/conf.d/littlebird-tc`
   137       file=`perl -ne '/^\s*errorlog\s+(\S+)/i&&print "$1\n"' /etc/apache2/conf.d/littlebird-tc`
   129       dir=`eval dirname "$file"`
   138       dir=`eval dirname "$file"`
   132       dir=`eval dirname "$file"`
   141       dir=`eval dirname "$file"`
   133       mkdir -p "$dir"
   142       mkdir -p "$dir"
   134     )
   143     )
   135 
   144 
   136     # fix application_ini, there should be a cleaner approach
   145     # fix application_ini, there should be a cleaner approach
       
   146     # for now we do not consider this as a config file!
   137 
   147 
   138     db_get littlebird-tc/db/name && dbname="$RET" || true
   148     db_get littlebird-tc/db/name && dbname="$RET" || true
   139     db_get littlebird-tc/db/host && dbhost="$RET" || true
   149     db_get littlebird-tc/db/host && dbhost="$RET" || true
   140     db_get littlebird-tc/db/user && dbuser="$RET" || true
   150     db_get littlebird-tc/db/user && dbuser="$RET" || true
   141     db_get littlebird-tc/db/pass && dbpass="$RET" || true
   151     db_get littlebird-tc/db/pass && dbpass="$RET" || true
   166 	
   176 	
   167 
   177 
   168 
   178 
   169     db_stop || true
   179     db_stop || true
   170 	( . /etc/apache2/envvars
   180 	( . /etc/apache2/envvars
       
   181 	  invoke=`which invoke-rc.d`
   171 	  if ! apache2 -M 2>/dev/null | grep -q ssl_module; then
   182 	  if ! apache2 -M 2>/dev/null | grep -q ssl_module; then
   172 		  a2enmod ssl
   183 		  a2enmod ssl
   173 		  invoke-rc.d apache2 restart >&2
   184 		  test "$invoke" && $invoke apache2 restart >&2
   174 	  else
   185 	  else
   175 		  invoke-rc.d apache2 reload >&2
   186 		  test "$invoke" && $invoke apache2 reload >&2
   176 	  fi
   187 	  fi
   177 	)
   188 	)
   178 
   189 
   179     ;;
   190     ;;
   180 
   191