[TOOLS][DOCKER] Change dialog method to command substitution and redirection and add way of finding git's root
This commit is contained in:
		
							
								
								
									
										195
									
								
								bin/configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										195
									
								
								bin/configure
									
									
									
									
										vendored
									
									
								
							@@ -16,38 +16,59 @@ check_input(){
 | 
				
			|||||||
  fi
 | 
					  fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DIALOG=${DIALOG=dialog}
 | 
					 | 
				
			||||||
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
 | 
					 | 
				
			||||||
trap "rm -f $tempfile" 0 1 2 5 15
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Configure"  \
 | 
					exec 3>&1
 | 
				
			||||||
        --inputbox "Domain root:" 12 51 2> $tempfile
 | 
					domain_root=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
 | 
					  --inputbox "Domain root:" 12 51 \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
domain_root=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
check_input $domain_root
 | 
					check_input $domain_root
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Configure"  \
 | 
					exec 3>&1
 | 
				
			||||||
        --inputbox "Subdomain (can be empty):" 12 51 2> $tempfile
 | 
					sub_domain=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
 | 
					  --inputbox "Subdomain (can be empty):" 12 51 \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
sub_domain=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exec 3>&1
 | 
				
			||||||
$DIALOG --title "Configure" --clear \
 | 
					signed=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
  --menu "Use certificate signed by Let's Encrypt?" 12 51 2 \
 | 
					  --menu "Use certificate signed by Let's Encrypt?" 12 51 2 \
 | 
				
			||||||
    "Y" "" \
 | 
					    "Y" "" \
 | 
				
			||||||
        "n" ""  2> $tempfile
 | 
					    "n" "" \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
signed=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ "${signed}" = "${signed#[Yy]}" ]
 | 
					[ "${signed}" = "${signed#[Yy]}" ]
 | 
				
			||||||
signed=$?
 | 
					signed=$?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ $signed -ne 0 ]; then
 | 
					if [ $signed -ne 0 ]; then
 | 
				
			||||||
  $DIALOG --title "Configure"  \
 | 
					  exec 3>&1
 | 
				
			||||||
        --inputbox "Email:" 12 51 2> $tempfile
 | 
					  email=$(dialog \
 | 
				
			||||||
 | 
					    --title "Configure" \
 | 
				
			||||||
 | 
					    --clear \
 | 
				
			||||||
 | 
					    --ok-label "Ok" \
 | 
				
			||||||
 | 
					    --cancel-label "Exit" \
 | 
				
			||||||
 | 
					    --inputbox "Email:" 12 51 \
 | 
				
			||||||
 | 
					    2>&1 1>&3)
 | 
				
			||||||
  check_retval $?
 | 
					  check_retval $?
 | 
				
			||||||
  email=`cat $tempfile`
 | 
					  exec 3>&-
 | 
				
			||||||
  check_input $email
 | 
					  check_input $email
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -58,7 +79,8 @@ else
 | 
				
			|||||||
  domain="${sub_domain}.${domain_root}"
 | 
					  domain="${sub_domain}.${domain_root}"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mkdir -p ./docker/bootstrap
 | 
					root="$(git rev-parse --show-toplevel)"
 | 
				
			||||||
 | 
					mkdir -p root/docker/bootstrap
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cat > ./docker/bootstrap/bootstrap.env <<EOF
 | 
					cat > ./docker/bootstrap/bootstrap.env <<EOF
 | 
				
			||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
@@ -86,74 +108,136 @@ fi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
. ./docker/bootstrap/bootstrap.env
 | 
					. ./docker/bootstrap/bootstrap.env
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --clear --title "Configure" \
 | 
					exec 3>&1
 | 
				
			||||||
 | 
					dbms=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
  --menu "Select DBMS:" 12 51 2 \
 | 
					  --menu "Select DBMS:" 12 51 2 \
 | 
				
			||||||
    "postgres" "" \
 | 
					    "postgres" "" \
 | 
				
			||||||
        "mariadb" ""  2> $tempfile
 | 
					    "mariadb" "" \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
dbms=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Configure" --clear \
 | 
					exec 3>&1
 | 
				
			||||||
        --inputbox "Social database name:" 12 51 2> $tempfile
 | 
					db=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
 | 
					  --inputbox "Social database name:" 12 51 \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
db=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "${dbms}" = 'mariadb' ] 
 | 
					if [ "${dbms}" = 'mariadb' ] 
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
  $DIALOG --title "Configure" --clear \
 | 
					  exec 3>&1
 | 
				
			||||||
          --inputbox "Database user:" 12 51 2> $tempfile
 | 
					  user=$(dialog \
 | 
				
			||||||
 | 
					    --title "Configure" \
 | 
				
			||||||
 | 
					    --clear \
 | 
				
			||||||
 | 
					    --ok-label "Ok" \
 | 
				
			||||||
 | 
					    --cancel-label "Exit" \
 | 
				
			||||||
 | 
					    --inputbox "Database user:" 12 51 \
 | 
				
			||||||
 | 
					    2>&1 1>&3)
 | 
				
			||||||
  check_retval $?
 | 
					  check_retval $?
 | 
				
			||||||
  user=`cat $tempfile`
 | 
					  exec 3>&-
 | 
				
			||||||
  check_input $user
 | 
					  check_input $user
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Configure" --clear \
 | 
					
 | 
				
			||||||
        --inputbox "Database password:" 12 51 2> $tempfile
 | 
					exec 3>&1
 | 
				
			||||||
 | 
					password=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
 | 
					  --inputbox "Database password:" 12 51 \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
password=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
check_input $password
 | 
					check_input $password
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Configure" --clear \
 | 
					exec 3>&1
 | 
				
			||||||
        --inputbox "Sitename:" 12 51 2> $tempfile
 | 
					sitename=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
 | 
					  --inputbox "Sitename:" 12 51 \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
sitename=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
check_input $sitename
 | 
					check_input $sitename
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Configure" --clear \
 | 
					exec 3>&1
 | 
				
			||||||
        --inputbox "Admin nickname:" 12 51 2> $tempfile
 | 
					admin_nick=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
 | 
					  --inputbox "Admin nickname:" 12 51 \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
admin_nick=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
check_input $admin_nick
 | 
					check_input $admin_nick
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Configure" --clear \
 | 
					exec 3>&1
 | 
				
			||||||
        --inputbox "Admin password:" 12 51 2> $tempfile
 | 
					admin_password=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
 | 
					  --inputbox "Admin password:" 12 51 \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
admin_password=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
check_input $admin_password
 | 
					check_input $admin_password
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --clear --title "Configure" \
 | 
					exec 3>&1
 | 
				
			||||||
 | 
					profile=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
  --menu "Site profile:" 12 51 4 \
 | 
					  --menu "Site profile:" 12 51 4 \
 | 
				
			||||||
    "public"  "" \
 | 
					    "public"  "" \
 | 
				
			||||||
    "private"  "" \
 | 
					    "private"  "" \
 | 
				
			||||||
    "community"  "" \
 | 
					    "community"  "" \
 | 
				
			||||||
        "single_user" ""  2> $tempfile
 | 
					    "single_user" "" \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
profile=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Configure" --clear \
 | 
					exec 3>&1
 | 
				
			||||||
        --inputbox "Mailer dsn:" 12 51 2> $tempfile
 | 
					mailer_dsn=$(dialog \
 | 
				
			||||||
 | 
					  --title "Configure" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
 | 
					  --inputbox "Mailer dsn:" 12 51 \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
mailer_dsn=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
check_input $mailer_dsn
 | 
					check_input $mailer_dsn
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mkdir -p ./docker/db
 | 
					mkdir -p root/docker/db
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "${dbms}" = 'mariadb' ]; then
 | 
					if [ "${dbms}" = 'mariadb' ]; then
 | 
				
			||||||
    $DIALOG --title "Configure" --clear \
 | 
					  exec 3>&1
 | 
				
			||||||
            --inputbox "DB root password" 12 51 2> $tempfile
 | 
					  db_root_password=$(dialog \
 | 
				
			||||||
 | 
					    --title "Configure" \
 | 
				
			||||||
 | 
					    --clear \
 | 
				
			||||||
 | 
					    --ok-label "Ok" \
 | 
				
			||||||
 | 
					    --cancel-label "Exit" \
 | 
				
			||||||
 | 
					    --inputbox "DB root password" 12 51 \
 | 
				
			||||||
 | 
					    2>&1 1>&3)
 | 
				
			||||||
  check_retval $?
 | 
					  check_retval $?
 | 
				
			||||||
    db_root_password=`cat $tempfile`
 | 
					  exec 3>&-
 | 
				
			||||||
  check_input $db_root_password
 | 
					  check_input $db_root_password
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  cat > ./docker/db/db.env <<EOF
 | 
					  cat > ./docker/db/db.env <<EOF
 | 
				
			||||||
DBMS=${dbms}
 | 
					DBMS=${dbms}
 | 
				
			||||||
MYSQL_ROOT_PASSWORD=${db_root_password}
 | 
					MYSQL_ROOT_PASSWORD=${db_root_password}
 | 
				
			||||||
@@ -175,7 +259,7 @@ fi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
echo "${database_url}" >> .env.local
 | 
					echo "${database_url}" >> .env.local
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mkdir -p ./docker/social
 | 
					mkdir -p root/docker/social
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cat > ./docker/social/social.env <<EOF
 | 
					cat > ./docker/social/social.env <<EOF
 | 
				
			||||||
SOCIAL_DBMS="${dbms}"
 | 
					SOCIAL_DBMS="${dbms}"
 | 
				
			||||||
@@ -196,15 +280,22 @@ EOF
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
echo "version: '3.3'" > docker-compose.yaml
 | 
					echo "version: '3.3'" > docker-compose.yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$DIALOG --title "Services" --clear \
 | 
					exec 3>&1
 | 
				
			||||||
 | 
					choice=$(dialog \
 | 
				
			||||||
 | 
					  --title "Services" \
 | 
				
			||||||
 | 
					  --clear \
 | 
				
			||||||
 | 
					  --ok-label "Ok" \
 | 
				
			||||||
 | 
					  --cancel-label "Exit" \
 | 
				
			||||||
  --checklist "Services to include in docker-compose:" 12 44 6 \
 | 
					  --checklist "Services to include in docker-compose:" 12 44 6 \
 | 
				
			||||||
    1 "nginx" on \
 | 
					    1 "nginx" on \
 | 
				
			||||||
    2 "certbot" on \
 | 
					    2 "certbot" on \
 | 
				
			||||||
    3 "php" on \
 | 
					    3 "php" on \
 | 
				
			||||||
    4 "db" on \
 | 
					    4 "db" on \
 | 
				
			||||||
        5 "redis" on  2> $tempfile
 | 
					    5 "redis" on \
 | 
				
			||||||
 | 
					  2>&1 1>&3)
 | 
				
			||||||
check_retval $?
 | 
					check_retval $?
 | 
				
			||||||
choice=`cat $tempfile`
 | 
					exec 3>&-
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "\nservices:" >> docker-compose.yaml
 | 
					echo "\nservices:" >> docker-compose.yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user