From 1f7c87830776cd422dc93f26e9fe30543ead9104 Mon Sep 17 00:00:00 2001 From: satanist Date: Sun, 8 May 2022 13:50:28 +0200 Subject: [PATCH] cargohold-cli: print full url --- backend/cargohold-cli | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/cargohold-cli b/backend/cargohold-cli index 99c7caa..23f5c19 100755 --- a/backend/cargohold-cli +++ b/backend/cargohold-cli @@ -1,5 +1,6 @@ #!/usr/bin/env bash -DATABASE=cargohold.db3 +DATABASE=${DATABASE:-cargohold.db3} +BASEURL=${BASEURL:-https://files.stumpf.es} usage(){ printf "This utility can be used to manage the cargohold database from the command line\n\n" @@ -35,7 +36,7 @@ addalias(){ fi alias=${4:-$(xxd -g 0 -l 16 -p /dev/urandom)} - printf "Adding alias %s pointing to %s (ACL %s, User %s)\n" "$alias" "$2" "$3" "$1" + printf "Adding alias %s/%s pointing to %s (ACL %s, User %s)\n" "$BASEURL" "$alias" "$2" "$3" "$1" sqlite3 "$DATABASE" "PRAGMA foreign_keys = ON; INSERT INTO aliases (alias, user, real, access) VALUES ('$alias', '$1', '$2', '$3');" } @@ -44,7 +45,7 @@ list(){ sqlite3 -column -header "$DATABASE" "SELECT name, storage FROM users;" printf "\nListing all aliases\n" - sqlite3 -column "$DATABASE" "SELECT user || ': ' || alias || ' (' || access || ') -> ' || real FROM aliases;" + sqlite3 -column "$DATABASE" "SELECT user || ': ' || '$BASEURL/' || alias || ' (' || access || ') -> ' || real FROM aliases;" } if [ "$#" -lt 1 ]; then -- cgit v1.2.3