X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=debian%2Fscripts%2Fkoha-foreach;h=2f5a150fcbd46e4a2f64805fa8f3984ff33b2a24;hb=005d67063f1a665e993ad8af3ff867bba0983c10;hp=9cf150d8115047cdd5a1dc20a5aa0a1c4d7eb0bc;hpb=f57ceeb8c56cfcae782db9802f5f6df8a2a1bc93;p=koha-ffzg.git diff --git a/debian/scripts/koha-foreach b/debian/scripts/koha-foreach index 9cf150d811..2f5a150fcb 100755 --- a/debian/scripts/koha-foreach +++ b/debian/scripts/koha-foreach @@ -15,26 +15,60 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - set -e +# Read configuration variable file if it is present +[ -r /etc/default/koha-common ] && . /etc/default/koha-common + +# include helper functions +if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then + . "/usr/share/koha/bin/koha-functions.sh" +else + echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 + exit 1 +fi + +chdir="no" +starting_dir=$(pwd) + listopts="" while [ ! -z "$1" ] do case "$1" in + --chdir) chdir="yes";; --email) listopts="$listopts --email";; --noemail) listopts="$listopts --noemail";; --enabled) listopts="$listopts --enabled";; + --disabled) listopts="$listopts --disabled";; + --sip) listopts="$listopts --sip";; + --nosip) listopts="$listopts --nosip";; + --plack) listopts="$listopts --plack";; + --noplack) listopts="$listopts --noplack";; + --letsencrypt) listopts="$listopts --letsencrypt" ;; +--noletsencrypt) listopts="$listopts --noletsencrypt" ;; *) break;; esac shift done - + for name in $(koha-list $listopts) do - sudo -u "$name-koha" \ - env PERL5LIB=/usr/share/koha/lib \ - KOHA_CONF="/etc/koha/sites/$name/koha-conf.xml" \ - "$@" -done + # Replace the __instancename__ placeholder for the instance name (Bug 8566) + cmd=`echo "$@" | sed -e s/__instancename__/${name}/g` + + if [ "${cmd}" != "" ]; then + + # Change to the instance's home dir if required + [ "$chdir" != "no" ] && eval cd ~$name"-koha" + if koha-shell ${name} -c "${cmd}"; then + : #noop + else + rv=$? + echo "${name}: $rv status returned by \"${cmd}\"" + fi + + # Go back to the original dir if required + [ "$chdir" != "no" ] && cd "$starting_dir" + fi +done