Bug 13143 - Detect if the password is in a pipe
authorLiz Rea <liz@catalyst.net.nz>
Tue, 7 Jul 2015 01:06:36 +0000 (13:06 +1200)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Wed, 27 Jan 2016 06:27:08 +0000 (06:27 +0000)
1. cd kohaclone/debian/scripts
2. sudo koha-passwd instance | cat
   Output should be password only
3. sudo koha-passwd instance
   Output should be "Password for $instance is: $password"

Does this get at what you were wanting, Robin?

NOTE:
$ cd ~
$ sudo mkdir /etc/koha
$ sudo mkdir /etc/koha/sites
$ sudo mkdir /etc/koha/sites/library
$ sudo ln -s ~/koha-dev/etc/koha-conf.xml /etc/koha/sites/library/koha-conf.xml
$ sudo mkdir /usr/share/koha
$ sudo ln -s ~/kohaclone/debian/scripts /usr/share/koha/bin

This will fake out your system enough to get koha-passwd to run in your git
system. Since you are using your git system, no need for the sudo's in
steps 2 & 3. And no need to roll a custom build to test it.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>

debian/scripts/koha-passwd

index b9faa02..5be04b4 100755 (executable)
@@ -45,11 +45,15 @@ EOF
 for name in "$@"
 do
     if is_instance $name ; then
-    passwd=$(xmlstarlet sel -t -v 'yazgfs/config/pass' /etc/koha/sites/$name/koha-conf.xml);
-    echo "Password for $name: $passwd"
-    echo "Press enter to clear the screen..."
-    read anykey
-    clear
+        passwd=$(xmlstarlet sel -t -v 'yazgfs/config/pass' /etc/koha/sites/$name/koha-conf.xml);
+        if [ -t 1 ]; then
+            echo "Password for $name: $passwd"
+            echo "Press enter to clear the screen..."
+            read anykey
+            clear
+        else
+            echo "$passwd"
+        fi
     else
         warn "Unknown instance $name."
     fi