From 34007f33f4a19c23b7259e78e71c88c84eb30d33 Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Wed, 4 Sep 2024 11:39:43 +0200 Subject: [PATCH] Bug 37025: (follow-up) Wrap calls to koha modules in koha-shell This change should - allow seamless usage when run as root (implied by /usr/sbin). - give explicit control to the user instead of relying on the environment --- debian/scripts/koha-api-keys | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/debian/scripts/koha-api-keys b/debian/scripts/koha-api-keys index 774912e297..79878e8450 100755 --- a/debian/scripts/koha-api-keys +++ b/debian/scripts/koha-api-keys @@ -62,8 +62,7 @@ if [ "$op" == 'generate' ]; then usage die "Unknown instance '$instance'" ) - - if ! perl -MKoha::Patrons -e "Koha::Patrons->find($borrowernumber) or die;" 2>/dev/null; then + if ! koha-shell -c "perl -MKoha::Patrons -e \"Koha::Patrons->find($borrowernumber) or die;\"" "$instance" 2>/dev/null; then die "Unknown borrowernumber: '$borrowernumber'" fi @@ -71,7 +70,7 @@ if [ "$op" == 'generate' ]; then read -r client_id read -r secret } < <( - perl -MKoha::ApiKeys -e "my \$key = Koha::ApiKey->new( { patron_id => $borrowernumber, description => '$description' } )->store; printf \"%s\n%s\n\", \$key->client_id, \$key->plain_text_secret;" + koha-shell -c "perl -MKoha::ApiKeys -e \"my \\\$key = Koha::ApiKey->new( { patron_id => $borrowernumber, description => '$description' } )->store; printf \\\"%s\\n%s\\n\\\", \\\$key->client_id, \\\$key->plain_text_secret;\"" "$instance" ) printf "Client ID:\t%s\nClient Secret:\t%s\n" "$client_id" "$secret" @@ -87,7 +86,7 @@ if [ "$op" == 'delete' ]; then ) read -rp "Client ID to delete: " client_id - if ! perl -MKoha::ApiKeys -e "Koha::ApiKeys->find('$client_id')->delete or die;" 2>/dev/null; then + if ! koha-shell -c "perl -MKoha::ApiKeys -e \"Koha::ApiKeys->find(\\\"$client_id\\\")->delete or die;\"" "$instance" 2>/dev/null; then die "Unknown client id: '$client_id'" fi -- 2.46.0