Commits

Michele Bini committed f47ef62

Quieter postinst script.

  • Participants
  • Parent commits 5ed02bc

Comments (0)

Files changed (4)

File bin/generate-timekoin-keys

 #!/bin/sh
 
+set -e
+
 cd /usr/share/timekoin/util/
 
-if [ "$1" = "--reset" ]; then
-    resetkeys=1
-elif [ x"$1" = x ]; then
-    resetkeys=0
-else
+resetkeys=0
+quiet=0
+
+usage() {
     echo
     echo "$0: Generate a private/public key pair for timekoin"
     echo "Usage: $0 [--reset]"
     echo
-    echo "Use --reset to regenerate the Timekoin private/public key pair."
-    echo "Before doing this, you should backup your key pair."
+    echo "Options:"
+    echo "--quiet  Be less verbose.  This is useful for scripts."
+    echo "--reset  Regenerate the Timekoin private/public key pair."
+    echo " 	     Before doing this, consider backing up your"
+    echo " 	   existing key pair."
     echo
-fi
+    exit 1
+}
 
-echo "<?PHP
+main() {
+    echo "<?PHP
 \$_GET['cmdline'] = 1;
+\$_GET['quiet'] = $quiet;
 \$_GET['resetkeys'] = $resetkeys;
 include('keys.php');
 ?>"|su www-data -c php
+}
+
+processargs() {
+    if [ -n "$1" ]; then
+	case "$1" in
+	    --help)   usage        ;;
+	    --reset)  resetkeys=1  ;;
+	    --quiet)  quiet=1      ;;
+	    --)       : 	   ;;
+	    --*)      die "Unrecognized option: $N.  For more info: $0 --help" ;;
+	    *)        main "$@"; return ;;
+	esac
+	shift
+	processargs "$@"
+    else
+	main "$@"
+    fi
+}
+
+processargs "$@"

File debian/changelog

+timekoin (1.9-deb38) unstable; urgency=low
+
+  * Quieter postinst script.
+
+ -- Michele Bini <michele.bini@gmail.com>  Fri, 21 Sep 2012 02:27:55 +0200
+
 timekoin (1.9-deb37) unstable; urgency=low
 
   * Fix to key generation script.

File debian/postinst

 dbc_generate_include_owner="root:www-data"
 dbc_generate_include_perms="640"
 # dbc_mysql_createdb_encoding=""
-# could set the collation setting here
+# could perhaps set the collation here
 
 dbc_go timekoin $@
 
-ln -s /etc/timekoin/apache.conf /etc/apache2/conf.d/timekoin.conf || true
+ln -s /etc/timekoin/apache.conf /etc/apache2/conf.d/timekoin.conf >/dev/null 2>/dev/null || true
 
-generate-timekoin-keys
+generate-timekoin-keys --quiet
 
 # Reload apache2 if it is running
 if service apache2 status >/dev/null 2>/dev/null; then

File util/keys.php

 <?PHP
+
 include '/usr/share/timekoin/public/configuration.php';
 
+global $keys_quiet;
 global $keys_cmdline;
 
 $keys_cmdline = ((isset($_GET['cmdline']) && ($_GET['cmdline'] == 1)));
+$keys_quiet = ((isset($_GET['quiet']) && ($_GET['quiet'] == 1)));
 
 function println($l) {
   global $keys_cmdline;
   $result = (($result !== "Private Key Goes Here") ||
 	     ($result !== ""));
   if ($result) {
-    println("A private key is already present.");
+    if (!$keys_quiet) { println("A private key is already present."); }
     # A previous key was set
     if ($keys_cmdline) {
-      println("Use --reset to force resetting the key.");
+      if (!$keys_quiet) { println("Use --reset to force resetting the key."); }
     } else {
       echo "<br/><form method=get><input type=checkbox id=resetkeys name=resetkeys ><label for=resetkeys>Reset private and public keys for Timekoin</label><input type=Submit id=submit name=submit value=\"Reset\"></form>";
     }