diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-12-01 10:27:44 +0900 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-12-01 10:27:44 +0900 |
commit | ff5b5c1fdd6959c8bf0f694af96ed9ed1fc892d2 (patch) | |
tree | 93e45b81aa8f4e87225c60e200344548bafebbac /contrib | |
parent | 36bec694dc0504cb6a5742e3551ceb4d566f1188 (diff) |
bugfixes to taler-exchange-dbconfig
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/taler-exchange-dbconfig | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/contrib/taler-exchange-dbconfig b/contrib/taler-exchange-dbconfig index b13ba153a..c4790f823 100755 --- a/contrib/taler-exchange-dbconfig +++ b/contrib/taler-exchange-dbconfig @@ -25,14 +25,22 @@ FORCE_PERMS=0 DBUSER="taler-exchange-httpd" DBGROUP="taler-exchange-db" DBNAME="exchange" -CFGFILE="/etc/taler/secrets/exchange-db.secret.conf" +CFGFILE="/etc/taler/taler.conf" +DBCFGFILE="/etc/taler/secrets/exchange-db.secret.conf" # Parse command-line options -while getopts ':g:hn:prsu:' OPTION; do +while getopts 'c:d:g:hn:prsu:' OPTION; do case "$OPTION" in + c) + CFGFILE="$OPTARG" + ;; + d) + DBCFGFILE="$OPTARG" + ;; h) echo 'Supported options:' echo " -c FILENAME -- write configuration to FILENAME (default: $CFGFILE)" + echo " -d FILENAME -- write database access configuration to FILENAME (default: $DBCFGFILE)" echo " -g GROUP -- taler-exchange to be run by GROUP (default: $DBGROUP)" echo " -h -- print this help text" echo " -n NAME -- user NAME for database name (default: $DBNAME)" @@ -58,7 +66,8 @@ while getopts ':g:hn:prsu:' OPTION; do DBUSER="$OPTARG" ;; ?) - exit_fail "Unrecognized command line option" + echo "Unrecognized command line option" 1>&2 + exit 1 ;; esac done @@ -80,7 +89,9 @@ then if ! taler-exchange-dbinit -v 2> /dev/null then echo "Required 'taler-exchange-dbinit' not found. Please fix your installation." + exit 1 fi + DBINIT=$(which taler-exchange-dbinit) fi if ! id "$DBUSER" > /dev/null @@ -117,24 +128,24 @@ then exit 1 fi -if [ -f "$CFGFILE" ] +if [ -f "$DBCFGFILE" ] then - echo "Adding database configuration to '$CFGFILE'." 1>&2 - echo -e "[exchangedb-postgres]\nCONFIG=postgres:///$DBNAME\n" >> "$CFGFILE" - chown root:"$DBGROUP" "$CFGFILE" + echo "Adding database configuration to '$DBCFGFILE'." 1>&2 + echo -e "[exchangedb-postgres]\nCONFIG=postgres:///$DBNAME\n" >> "$DBCFGFILE" + chown root:"$DBGROUP" "$DBCFGFILE" chmod 640 "$CFGFILE" else - echo "Configuration '$CFGFILE' does not yet exist, creating it." 1>&2 - mkdir -p "$(dirname "$CFGFILE")" + echo "Configuration '$DBCFGFILE' does not yet exist, creating it." 1>&2 + mkdir -p "$(dirname "$DBCFGFILE")" echo -e "[exchangedb-postgres]\nCONFIG=postgres:///$DBNAME\n" >> "$CFGFILE" - chown root:"$DBGROUP" "$CFGFILE" - chmod 640 "$CFGFILE" + chown root:"$DBGROUP" "$DBCFGFILE" + chmod 640 "$DBCFGFILE" fi if [ 0 = "$SKIP_DBINIT" ] then echo "Initializing database '$DBNAME'." 1>&2 - sudo -u "$DBUSER" taler-exchange-dbinit -c "$CFGFILE" + sudo -u "$DBUSER" "$DBINIT" -c "$CFGFILE" fi if [ 0 = "$SKIP_DBINIT" ] || [ 1 = "$FORCE_PERMS" ] |