From 152d173e699b553870446b5c0778ed56a6dc0d15 Mon Sep 17 00:00:00 2001 From: margarida Date: Tue, 20 Oct 2020 02:49:49 +0100 Subject: [PATCH] [TOOLS][DOCKER] Added first version of configuration shell script --- bin/configure | 69 +++++++++++---------------------------------------- 1 file changed, 15 insertions(+), 54 deletions(-) diff --git a/bin/configure b/bin/configure index 8f378c883e..b20b355cd0 100755 --- a/bin/configure +++ b/bin/configure @@ -1,54 +1,27 @@ #!/bin/sh -check_retval(){ - case $1 in - 1|255) - echo "Stopped" - exit;; - esac -} - -check_input(){ - if [ "$1" = "" ] - then - echo "Can't be empty" - exit - fi -} - DIALOG=${DIALOG=dialog} tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$ trap "rm -f $tempfile" 0 1 2 5 15 -$DIALOG --title "Configure" \ +$DIALOG --title "Configure" --clear \ --inputbox "Domain root:" 12 51 2> $tempfile -check_retval $? domain_root=`cat $tempfile` -check_input $domain_root - - -$DIALOG --title "Configure" \ - --inputbox "Subdomain (can be empty):" 12 51 2> $tempfile -check_retval $? -sub_domain=`cat $tempfile` - $DIALOG --title "Configure" --clear \ - --menu "Use certificate signed by Let's Encrypt?" 12 51 2 \ - "Y" "" \ - "n" "" 2> $tempfile -check_retval $? + --inputbox "Subdomain (can be empty):" 12 51 2> $tempfile +sub_domain=`cat $tempfile` + +$DIALOG --title "Configure" --clear \ + --inputbox "Use certificate signed by Let's Encrypt (Y/n):" 12 51 2> $tempfile signed=`cat $tempfile` [ "${signed}" = "${signed#[Yy]}" ] signed=$? if [ $signed -ne 0 ]; then - $DIALOG --title "Configure" \ - --inputbox "Email:" 12 51 2> $tempfile - check_retval $? - email=`cat $tempfile` - check_input $email + printf "Email: " + read -r email fi if [ -z "$sub_domain" ] @@ -72,6 +45,8 @@ chmod +x ./docker/bootstrap/bootstrap.env docker-compose -f docker/bootstrap/bootstrap.yaml up + +## -------------------------------- git_dir=$PWD while [ ! -d .git ]; do git_dir=$(dirname "${git_dir}") @@ -90,46 +65,34 @@ $DIALOG --clear --title "Configure" \ --menu "Select DBMS:" 12 51 2 \ "postgres" "" \ "mariadb" "" 2> $tempfile -check_retval $? dbms=`cat $tempfile` $DIALOG --title "Configure" --clear \ --inputbox "Social database name:" 12 51 2> $tempfile -check_retval $? db=`cat $tempfile` if [ "${dbms}" = 'mariadb' ] then - $DIALOG --title "Configure" --clear \ - --inputbox "Database user:" 12 51 2> $tempfile - check_retval $? - user=`cat $tempfile` - check_input $user + $DIALOG --title "Configure" --clear \ + --inputbox "Database user:" 12 51 2> $tempfile + user=`cat $tempfile` fi $DIALOG --title "Configure" --clear \ --inputbox "Database password:" 12 51 2> $tempfile -check_retval $? password=`cat $tempfile` -check_input $password $DIALOG --title "Configure" --clear \ --inputbox "Sitename:" 12 51 2> $tempfile -check_retval $? sitename=`cat $tempfile` -check_input $sitename $DIALOG --title "Configure" --clear \ --inputbox "Admin nickname:" 12 51 2> $tempfile -check_retval $? admin_nick=`cat $tempfile` -check_input $admin_nick $DIALOG --title "Configure" --clear \ --inputbox "Admin password:" 12 51 2> $tempfile -check_retval $? admin_password=`cat $tempfile` -check_input $admin_password $DIALOG --clear --title "Configure" \ --menu "Site profile:" 12 51 4 \ @@ -137,14 +100,11 @@ $DIALOG --clear --title "Configure" \ "private" "" \ "community" "" \ "single_user" "" 2> $tempfile -check_retval $? profile=`cat $tempfile` $DIALOG --title "Configure" --clear \ --inputbox "Mailer dsn:" 12 51 2> $tempfile -check_retval $? mailer_dsn=`cat $tempfile` -check_input $mailer_dsn mkdir -p ./docker/db @@ -203,7 +163,8 @@ $DIALOG --title "Services" --clear \ 3 "php" on \ 4 "db" on \ 5 "redis" on 2> $tempfile -check_retval $? +retval=$? + choice=`cat $tempfile` echo "\nservices:" >> docker-compose.yaml