X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=debian%2Fscripts%2Fkoha-list;h=0dd72e1a947a01dc348ffe030d693124f94a270b;hb=2fc1b469e223065d168a6e33a0a7c541a76a6ada;hp=1e19f1afc41dc0e9483a5e0e0a287bff5ebe7a3c;hpb=c190d93a12c2741b8d4539b7bee175257da815c8;p=koha.git diff --git a/debian/scripts/koha-list b/debian/scripts/koha-list index 1e19f1afc4..0dd72e1a94 100755 --- a/debian/scripts/koha-list +++ b/debian/scripts/koha-list @@ -1,6 +1,6 @@ #!/bin/sh # -# koha-instances -- List all Koha instances. +# koha-list -- List all Koha instances. # Copyright 2010 Catalyst IT, Ltd # # This program is free software: you can redistribute it and/or modify @@ -19,56 +19,250 @@ set -e -is_enabled() { - if grep '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \ - "/etc/apache2/sites-available/$name" > /dev/null - then - return 1 +# 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 + +show_instances() +{ + local show=$1 + local show_email=$2 + local show_sip=$3 + + for instance in $( get_instances ); do + case $show in + "all") + if instance_filter_email $instance $show_email && \ + instance_filter_letsencrypt $instance $show_letsencrypt && \ + instance_filter_plack $instance $show_plack && \ + instance_filter_sip $instance $show_sip; then + echo $instance + fi ;; + "enabled") + if is_enabled $instance; then + if instance_filter_email $instance $show_email && \ + instance_filter_letsencrypt $instance $show_letsencrypt && \ + instance_filter_plack $instance $show_plack && \ + instance_filter_sip $instance $show_sip; then + echo $instance + fi + fi ;; + "disabled") + if ! is_enabled $instance; then + if instance_filter_email $instance $show_email && \ + instance_filter_letsencrypt $instance $show_letsencrypt && \ + instance_filter_plack $instance $show_plack && \ + instance_filter_sip $instance $show_sip; then + echo $instance + fi + fi ;; + esac + done +} + + +instance_filter_sip() +{ + local instancename=$1 + local show_sip=$2; + + case $show_sip in + "all") + return 0 ;; + "enabled") + if is_sip_enabled $instancename; then + return 0 + fi ;; + "disabled") + if ! is_sip_enabled $instancename; then + return 0 + fi ;; + esac + + # Didn't match any criteria + return 1 +} + +instance_filter_plack() +{ + local instancename=$1 + local show_plack=$2; + + case $show_plack in + "all") + return 0 ;; + "enabled") + if is_plack_enabled $instancename; then + return 0 + fi ;; + "disabled") + if ! is_plack_enabled $instancename; then + return 0 + fi ;; + esac + + # Didn't match any criteria + return 1 +} + +instance_filter_letsencrypt() +{ + local instancename=$1 + local show_letsencrypt=$2; + + case $show_letsencrypt in + "all") + return 0 ;; + "enabled") + if is_letsencrypt_enabled $instancename; then + return 0 + fi ;; + "disabled") + if ! is_letsencrypt_enabled $instancename; then + return 0 + fi ;; + esac + + # Didn't match any criteria + return 1 +} + +instance_filter_email() +{ + local instancename=$1 + local show_email=$2; + + case $show_email in + "all") + return 0 ;; + "enabled") + if is_email_enabled $instancename; then + return 0 + fi ;; + "disabled") + if ! is_email_enabled $instancename; then + return 0 + fi ;; + esac + + # Didn't match any criteria + return 1 +} + +set_show() +{ + local show_param=$1 + + if [ "$show" = "all" ]; then + show=$show_param else - return 0 + die "Error: --enabled and --disabled are mutually exclusive." fi } -help() { - echo <