introduced ucf
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Mon, 05 Sep 2011 12:20:54 +0200
changeset 54 706239603081
parent 52 f90939237a7c
child 55 e586621a78fc
introduced ucf
debian/MISC/apache/littlebird-tc
debian/MISC/mysql/littlebird-tc-core.cnf
debian/changelog
debian/control
debian/examples/apache/littlebird-tc
debian/examples/mysql/littlebird-tc.cnf
debian/littlebird-tc-common.install
debian/littlebird-tc-core.install
debian/littlebird-tc-core.postinst
debian/littlebird-tc-core.postrm
debian/littlebird-tc-sql.install
debian/littlebird-tc-sql.postinst
--- a/debian/MISC/apache/littlebird-tc	Sat Sep 03 00:03:24 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-# Note: all lines following a # debconf line are managed
-# by debconf. If you want to take control, just remove the
-# # debconf line.
-<IfModule mod_ssl.c>
-    # debconf: {{listen}}
-    # Listen 443
-</IfModule>
-
-<VirtualHost *:80>
-    # debconf: ServerAdmin {{serveradmin}}
-    ServerAdmin webmaster@example.com
-    # debconf: ServerName {{servername}}
-    ServerName www.example.com
-    # debconf: Redirect permanent / {{serverurl}}
-    Redirect permanent / https://www.example.com/
-</VirtualHost>
-
-<IfModule mod_ssl.c>
-    # debconf: <VirtualHost _default_:{{serverport}}>
-    <VirtualHost _default_:443>
-
-        # debconf: ServerAdmin {{serveradmin}}
-        ServerAdmin webmaster@example.com
-        # debconf: ServerName {{servername}}
-        ServerName www.example.com
-
-        DocumentRoot /srv/www/littlebird/TrustCenter/public
-        <Directory /srv/www/littlebird/TrustCenter/public>
-            RewriteEngine On
-            RewriteCond %{REQUEST_FILENAME} -s [OR]
-            RewriteCond %{REQUEST_FILENAME} -l [OR]
-            RewriteCond %{REQUEST_FILENAME} -d
-            RewriteRule ^.*$ - [NC,L]
-            RewriteRule ^.*$ index.php [NC,L]
-            AllowOverride All
-            Order allow,deny
-            allow from all
-        </Directory>
-
-        SSLEngine on
-        # debconf: SSLCertificateFile {{crt}}
-        SSLCertificateFile /etc/ssl/certs/www.example.com-crt.pem
-        # debconf: SSLCertificateKeyFile {{key}}
-        SSLCertificateKeyFile /etc/ssl/key/www.example.com-key.pem
-
-        SSLOptions +ExportCertData
-
-        SSLVerifyClient require
-        SSLVerifyDepth 2
-        SSLCACertificateFile /srv/www/littlebird/CA/certs/Trustcenter_CA_LB.pem
-        SSLCADNRequestFile   /srv/www/littlebird/CA/certs/Trustcenter_CA.pem
-        <Location /css>
-            SSLVerifyClient none
-        </Location>
-        <Location /js>
-            SSLVerifyClient none
-        </Location>
-        <Location /images>
-            SSLVerifyClient none
-        </Location>
-
-        LogLevel warn
-        # debconf: ErrorLog ${APACHE_LOG_DIR}/{{servername}}/error.log
-        ErrorLog ${APACHE_LOG_DIR}/www.example.com/error.log
-        # debconf: CustomLog ${APACHE_LOG_DIR}/{{servername}}/access.log combined
-        CustomLog ${APACHE_LOG_DIR}/www.example.com/access.log combined
-    </VirtualHost>
-</IfModule>
--- a/debian/MISC/mysql/littlebird-tc-core.cnf	Sat Sep 03 00:03:24 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-[mysql]
-default-character-set = utf8
--- a/debian/changelog	Sat Sep 03 00:03:24 2011 +0200
+++ b/debian/changelog	Mon Sep 05 12:20:54 2011 +0200
@@ -1,3 +1,12 @@
+littlebird (2011072500-56) stable; urgency=low
+
+  * fixed sql postinst script (no endless loop if no access)
+  * fixed postrm script 
+  * ucf --debconf-ok 
+  * testing ucf 
+
+ -- Heiko Schlittermann <hs@schlittermann.de>  Mon, 05 Sep 2011 11:37:58 +0200
+
 littlebird (2011072500-55) stable; urgency=low
 
   * documentation should reflect main (instead of non-free) as well. 
--- a/debian/control	Sat Sep 03 00:03:24 2011 +0200
+++ b/debian/control	Mon Sep 05 12:20:54 2011 +0200
@@ -16,7 +16,7 @@
 Architecture: all
 Depends: ${shlibs:Depends}, ${misc:Depends}, littlebird-tc-common (>= ${source:Version}), 
 	littlebird-tc-common (>= ${source:Version}), 
-	zend-server-php-5.3, php-5.3-loader-zend-server, php5-cli, openssl
+	zend-server-php-5.3, php-5.3-loader-zend-server, php5-cli, openssl, ucf
 Recommends: littlebird-tc-sql (>= ${source:Version})
 Provides: littlebird-tc
 Description: littlebird trustcenter core
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/examples/apache/littlebird-tc	Mon Sep 05 12:20:54 2011 +0200
@@ -0,0 +1,68 @@
+# Note: all lines following a # debconf line are managed
+# by debconf. If you want to take control, just remove the
+# # debconf line.
+<IfModule mod_ssl.c>
+    # debconf: {{listen}}
+    # Listen 443
+</IfModule>
+
+<VirtualHost *:80>
+    # debconf: ServerAdmin {{serveradmin}}
+    ServerAdmin webmaster@example.com
+    # debconf: ServerName {{servername}}
+    ServerName www.example.com
+    # debconf: Redirect permanent / {{serverurl}}
+    Redirect permanent / https://www.example.com/
+</VirtualHost>
+
+<IfModule mod_ssl.c>
+    # debconf: <VirtualHost _default_:{{serverport}}>
+    <VirtualHost _default_:443>
+
+        # debconf: ServerAdmin {{serveradmin}}
+        ServerAdmin webmaster@example.com
+        # debconf: ServerName {{servername}}
+        ServerName www.example.com
+
+        DocumentRoot /srv/www/littlebird/TrustCenter/public
+        <Directory /srv/www/littlebird/TrustCenter/public>
+            RewriteEngine On
+            RewriteCond %{REQUEST_FILENAME} -s [OR]
+            RewriteCond %{REQUEST_FILENAME} -l [OR]
+            RewriteCond %{REQUEST_FILENAME} -d
+            RewriteRule ^.*$ - [NC,L]
+            RewriteRule ^.*$ index.php [NC,L]
+            AllowOverride All
+            Order allow,deny
+            allow from all
+        </Directory>
+
+        SSLEngine on
+        # debconf: SSLCertificateFile {{crt}}
+        SSLCertificateFile /etc/ssl/certs/www.example.com-crt.pem
+        # debconf: SSLCertificateKeyFile {{key}}
+        SSLCertificateKeyFile /etc/ssl/key/www.example.com-key.pem
+
+        SSLOptions +ExportCertData
+
+        SSLVerifyClient require
+        SSLVerifyDepth 2
+        SSLCACertificateFile /srv/www/littlebird/CA/certs/Trustcenter_CA_LB.pem
+        SSLCADNRequestFile   /srv/www/littlebird/CA/certs/Trustcenter_CA.pem
+        <Location /css>
+            SSLVerifyClient none
+        </Location>
+        <Location /js>
+            SSLVerifyClient none
+        </Location>
+        <Location /images>
+            SSLVerifyClient none
+        </Location>
+
+        LogLevel warn
+        # debconf: ErrorLog ${APACHE_LOG_DIR}/{{servername}}/error.log
+        ErrorLog ${APACHE_LOG_DIR}/www.example.com/error.log
+        # debconf: CustomLog ${APACHE_LOG_DIR}/{{servername}}/access.log combined
+        CustomLog ${APACHE_LOG_DIR}/www.example.com/access.log combined
+    </VirtualHost>
+</IfModule>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/examples/mysql/littlebird-tc.cnf	Mon Sep 05 12:20:54 2011 +0200
@@ -0,0 +1,2 @@
+[mysql]
+default-character-set = utf8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/littlebird-tc-common.install	Mon Sep 05 12:20:54 2011 +0200
@@ -0,0 +1,1 @@
+debian/examples/mysql/littlebird-tc.cnf /etc/mysql/conf.d
--- a/debian/littlebird-tc-core.install	Sat Sep 03 00:03:24 2011 +0200
+++ b/debian/littlebird-tc-core.install	Mon Sep 05 12:20:54 2011 +0200
@@ -1,3 +1,2 @@
 LittleBird/encoded/LittleBird-Test/{CA,library,TrustCenter} /srv/www/littlebird
-debian/MISC/mysql/littlebird-tc-core.cnf /etc/mysql/conf.d
-debian/MISC/apache/littlebird-tc /etc/apache2/conf.d
+debian/examples/apache /usr/share/doc/littlebird-tc/examples
--- a/debian/littlebird-tc-core.postinst	Sat Sep 03 00:03:24 2011 +0200
+++ b/debian/littlebird-tc-core.postinst	Mon Sep 05 12:20:54 2011 +0200
@@ -29,6 +29,7 @@
     chmod -R g+w "$DIR"
 
     # Timezone in /usr/local/zend/etc/php.ini
+    # note: this file is handled as a conffile under ucf control
     f=/usr/local/zend/etc/php.ini
     perl -pi -e 's{^;?\s*(date\.timezone\s*=).*$}{$1 "Europe/Berlin"}' $f
 
@@ -95,13 +96,19 @@
 	fi
     fi
 
+    # wozu brauchen wir das? hs - 9/2011
+    test "$crt" && ucfr littlebird-tc-core "$crt"
+    test "$key" && ucfr littlebird-tc-core "$key"
+
     # tweak the config file, but just the lines following a magical
     # debconf line
-    perl - serveradmin="$serveradmin" servername="$servername" serverport="$serverport" \
+    cp /usr/share/doc/littlebird-tc/examples/apache/littlebird-tc $tmp
+    perl - "$tmp" serveradmin="$serveradmin" servername="$servername" serverport="$serverport" \
 	   crt="$crt" key="$key" <<'_'
 	use strict;
 	use warnings;
 	my $mark = '# debconf:';
+	my $tmpfile = shift;
 	my %o;
 	foreach (@ARGV) { my ($k, $v) = split /=/, $_, 2; $o{$k} = $v }
 	if ($o{serverport} eq "443") { 
@@ -114,7 +121,7 @@
 	}
 	
 
-	open(F, "+</etc/apache2/conf.d/littlebird-tc") or die;
+	open(F, "+<$tmpfile") or die;
 	$_ = join "" => <F>;
 	s|^(([ \t]*?)# debconf: (.*?){{(.*?)}}(.*?)\n).*?\n|$1$2$3$o{$4}$5\n|migs;
 	seek(F, 0, 0);
@@ -123,6 +130,8 @@
 	close(F);
 _
 
+    ucf --debconf-ok $tmp /etc/apache2/conf.d/littlebird-tc
+
     # need log dir(s)
     ( . /etc/apache2/envvars
       file=`perl -ne '/^\s*errorlog\s+(\S+)/i&&print "$1\n"' /etc/apache2/conf.d/littlebird-tc`
@@ -134,6 +143,7 @@
     )
 
     # fix application_ini, there should be a cleaner approach
+    # for now we do not consider this as a config file!
 
     db_get littlebird-tc/db/name && dbname="$RET" || true
     db_get littlebird-tc/db/host && dbhost="$RET" || true
@@ -168,11 +178,12 @@
 
     db_stop || true
 	( . /etc/apache2/envvars
+	  invoke=`which invoke-rc.d`
 	  if ! apache2 -M 2>/dev/null | grep -q ssl_module; then
 		  a2enmod ssl
-		  invoke-rc.d apache2 restart >&2
+		  test "$invoke" && $invoke apache2 restart >&2
 	  else
-		  invoke-rc.d apache2 reload >&2
+		  test "$invoke" && $invoke apache2 reload >&2
 	  fi
 	)
 
--- a/debian/littlebird-tc-core.postrm	Sat Sep 03 00:03:24 2011 +0200
+++ b/debian/littlebird-tc-core.postrm	Mon Sep 05 12:20:54 2011 +0200
@@ -24,11 +24,23 @@
     purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
 
 	case "$1" in
-	purge|remove)
-	    db_subst littlebird-tc/removal action ${1%e}ing || true
+	purge)
+	    ucf --debconf-ok --purge /etc/apache2/conf.d/littlebird-tc
+
+	    ucfq --with-colons littlebird-tc-core | while IFS=: read file rest
+	    done
+		ucfr --purge littlebird-tc-core "$file"
+	    done
+
+	    db_subst littlebird-tc/removal action purging || true
 	    db_input high littlebird-tc/removal || true
 	    db_go || true
-	;;
+	    ;;
+	remove)
+	    db_subst littlebird-tc/removal action removing || true
+	    db_input high littlebird-tc/removal || true
+	    db_go || true
+	    ;;
 	esac
     ;;
 
--- a/debian/littlebird-tc-sql.install	Sat Sep 03 00:03:24 2011 +0200
+++ b/debian/littlebird-tc-sql.install	Mon Sep 05 12:20:54 2011 +0200
@@ -1,1 +1,1 @@
-LittleBird/encoded/LittleBird-Test/Database/. /usr/share/littlebird/tc-sql
+LittleBird/encoded/LittleBird-Test/Database/. /usr/share/littlebird-tc/sql
--- a/debian/littlebird-tc-sql.postinst	Sat Sep 03 00:03:24 2011 +0200
+++ b/debian/littlebird-tc-sql.postinst	Mon Sep 05 12:20:54 2011 +0200
@@ -35,6 +35,7 @@
 
 		# check admin access
 		if ! _mysql -e "" mysql 2>$tmp; then
+		    db_set   littlebird-tc/db/have-admin false || true
 		    db_subst littlebird-tc/db/failure message "`cat $tmp`" || true
 		    db_subst littlebird-tc/db/failure name "$name" || true
 		    db_subst littlebird-tc/db/failure host "$host" || true
@@ -65,7 +66,7 @@
 		    FLUSH PRIVILEGES;
 EOF
 	    
-		    /usr/share/littlebird/tc-sql/install_test_iteration_2011-06.sh \
+		    /usr/share/littlebird-tc/sql/install_test_iteration_2011-06.sh \
 			--host "$host" --db "$name" \
 			--adminuser "$adminuser" --adminpass "$adminpass" \
 			--user "$user" --pass "$pass"