diff options
| author | Bruno Ribas <brunoribas@gmail.com> | 2016-09-16 17:15:28 +0000 |
|---|---|---|
| committer | Bruno Ribas <brunoribas@gmail.com> | 2016-09-16 17:15:28 +0000 |
| commit | d9567a1099d89aa02b792fb1db3d08798d63ec3e (patch) | |
| tree | de4fae15048a9a7c4f3bb378f552b7d795f60111 | |
| parent | 2566b11c2a101a8942450a3d5a3e156bc984bde5 (diff) | |
| download | boca-d9567a1099d89aa02b792fb1db3d08798d63ec3e.tar.gz boca-d9567a1099d89aa02b792fb1db3d08798d63ec3e.zip | |
Added tools/boca-config-dbhost.sh
This script is used as a front end to define where is the BOCA DB.
It receives via argument where is located BOCA DB, localhost or the IP of
the postgres host.
Signed-off-by: Bruno Ribas <brunoribas@gmail.com>
| -rw-r--r-- | tools/boca-config-dbhost.sh | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tools/boca-config-dbhost.sh b/tools/boca-config-dbhost.sh new file mode 100644 index 0000000..306f44f --- /dev/null +++ b/tools/boca-config-dbhost.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# ///////////////////////////////////////////////////////////////////////////// +# //BOCA Online Contest Administrator +# // Copyright (C) 2016- by BOCA Development Team (bocasystem@gmail.com) +# // +# // This program is free software: you can redistribute it and/or modify +# // it under the terms of the GNU General Public License as published by +# // the Free Software Foundation, either version 3 of the License, or +# // (at your option) any later version. +# // +# // This program is distributed in the hope that it will be useful, +# // but WITHOUT ANY WARRANTY; without even the implied warranty of +# // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# // GNU General Public License for more details. +# // You should have received a copy of the GNU General Public License +# // along with this program. If not, see <http://www.gnu.org/licenses/>. +# ///////////////////////////////////////////////////////////////////////////// +# // Last modified 15/Sep/2016 by brunoribas@utfpr.edu.br + +if ! whoami | grep -q '^root$' ; then + echo "$0 must be run as root" + exit 1 +fi + +if (( $# != 1 )); then + echo "Usage:" + echo " $0 bdserver-ip|localhost" + echo + echo "Parameter should be localhost if the postgres is running localhost, or" + echo "the IP address of the postgres" + exit 0 +fi + +bdservernew=$1 + +. /etc/boca.conf + +CHANGE=n +if [[ "x$bdserver" == "x" ]]; then + echo "bdserver=$bdservernew" >> /etc/boca.conf +else + CHANGE=y + VV="$(grep -v '^bdserver=' /etc/boca.conf)" + printf "bdserver=$bdservernew\n$VV\n" > /etc/boca.conf +fi + +bdserver=$bdservernew + +if [[ "$bdserver" == "localhost" && "x$bdcreated" != "xy" ]]; then + if [[ "$CHANGE" == "n" ]]; then + boca-createdb + else + boca-createdb -f + fi +elif [[ "$bdserver" != "localhost" ]]; then + printf "You will be asked to prompt the BD password [enter do continue]" + read + #just to config password + if [[ "$CHANGE" == "n" ]]; then + boca-createdb nocreate + else + boca-createdb -f nocreate + fi +fi + +exit 0 |