Commit f132bf89 authored by Aral Balkan's avatar Aral Balkan

Improved the look of the script to highlight potential issues and current state.

parent cd997d3e
......@@ -28,6 +28,15 @@
# Helpers
#
# ANSI character codes
ansiBoldStart='\033[1m'
ansiBoldEnd='\033[22m'
ansiForegroundBlack='\033[30m'
ansiForegroundDefault='\033[39m'
ansiBackgroundBlue='\033[44m'
ansiBackgroundYellow='\033[43m'
ansiBackgroundDefault='\033[49m'
# Runs command in requested directory and restores the working directory at the end.
# Usage: run <directory> "<command>"
runIn(){
......@@ -45,7 +54,7 @@ setupRepository(){
runIn $ROOT "git clone ${gitRepositoryPrefix}/${nameOfRepository}.git"
# TODO: Once we have the data.better.fyi repositories set up and
# ===== being used by the builder script, we can disable the
# ===== being used by the builder script, we can disable the
# origin push endpoints so as to avoid an accidental push to
# the source repositories from the deployment environment.
#
......@@ -58,13 +67,20 @@ setupRepository(){
# Abort on errors.
set -e
echo -e "\n┌────────────────────────────────────────┐"
echo -e "│ Better Builder Deployment Server Setup │"
echo -e "└────────────────────────────────────────┘\n"
echo -e "\n────────────────────────────────────────────────────────────────────────────────"
echo -e "${ansiBackgroundBlue}${ansiForegroundBlack} Better Builder Deployment Server Setup ${ansiBackgroundDefault}${ansiForegroundDefault}"
echo -e "────────────────────────────────────────────────────────────────────────────────\n"
echo -e "${ansiBackgroundYellow}${ansiForegroundBlack} Warning! ${ansiBackgroundDefault}${ansiForegroundDefault} This installer script creates a fresh Better Builder server:\n"
echo -e " Do not run this on your development machine.\n"
echo -e " * It will destroy your current installation of Better Builder, if one exists."
echo -e " * It will uninstall Dokku, Docker, and any related dependencies and data.\n"
echo -e "[Warning!] This installer script is meant to be used to create a fresh installation of Builder. It will destroy your current installation of Better Builder if there is one. It will also uninstall Dokku and any dependencies it has (including Docker) as well as any related data.\n"
echo -e "Press CTRL-C if you want to exit now.\n"
echo -e " (Press CTRL-C if you want to exit now.)\n"
echo -e "────────────────────────────────────────────────────────────────────────────────\n"
# Check for commandline arguments.
......@@ -82,29 +98,31 @@ while getopts ":s" opt; do
esac
done
echo -e "Using Let’s Encrypt ${letsEncryptServer} server.\n" >&2
echo -e " ┌────────────────────────────────────────┐"
echo -e " │ Using Let’s Encrypt ${ansiBoldStart}${letsEncryptServer}${ansiBoldEnd} server. │"
echo -e " └────────────────────────────────────────┘\n"
# Configuration options.
echo -e "1. Configuration options (for better.fyi, all of these have the correct defaults).\n"
echo -e "1. Configuration options (all defaults are for better.fyi).\n"
#
# Prompt for configuration (With defaults set for better.fyi.)
# Note: defaults are Bash 3-compatible on purpose.
#
read -e -p "Builder domain (builder.better.fyi): " builderDomain
read -e -p " Builder domain (builder.better.fyi): " builderDomain
builderDomain=${builderDomain:-builder.better.fyi}
read -e -p "Email address for Let’s Encrypt TLS certificates (hello+builder@ind.ie): " letsEncryptEmailAddress
read -e -p " Email address for Let’s Encrypt TLS certificates (hello+builder@ind.ie): " letsEncryptEmailAddress
letsEncryptEmailAddress=${letsEncryptEmailAddress:-hello+builder@ind.ie}
read -e -p "Git repository prefix (git@source.ind.ie:blockdown): " gitRepositoryPrefix
read -e -p " Git repository prefix (git@source.ind.ie:blockdown): " gitRepositoryPrefix
gitRepositoryPrefix=${gitRepositoryPrefix:-git@source.ind.ie:blockdown}
read -e -p "Data for site remote repository URL (git@blockdown-site.ind.ie:data.git): " dataForSiteRemoteRepositoryURL
read -e -p " Data for site remote repository URL (git@blockdown-site.ind.ie:data.git): " dataForSiteRemoteRepositoryURL
dataForSiteRemoteRepositoryURL=${dataForSiteRemoteRepositoryURL:-git@blockdown-site.ind.ie:data.git}
read -e -p "Public key (default is better.fyi’s): " publicKey
read -e -p " Public key (default is better.fyi’s): " publicKey
publicKey=${publicKey:-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCoeMcQpU1XaSkv9AZtvUOg0bYEoRXTQ4MREGXoAZCR0pFWfzbzG0+av6WyNulu+MU5JF87u3YnwAAB6FB92mMbRS1xMtuV0Bu5TwPj5MjUqbznm8Sd+XO7A37g0oBPWrCKe24G+dGAmRVHZjT9qisTQhKpbEW1TxdvbNxDYALTzBuUFmhCJnMYorTpOVXL0SkUX89AkoVXdjVCq55sf3MGG+AN9OomSvveZ8tK0FwGOlT9w5niNktBfVicNpQFpURSbKFCqjZp7qkDLDRebKI1grgDUELhQWYj32vNkMX3lzqC/AIqwVkEO11Y9DSalray4f7O9X9YR3hB1MPRcBSw6DD36lCtVA6cASGdzvxDMX1f7gFoq22gfGJMVVYn+uHClrlrTiXl+ueZr3+DgC2Zc+/pWhqBsJ7NdxeWRYQWVmrOAPWLthxoPKxnlgbuRR9xBugWB+F73ipNZ5/iS6/eYoqmvaC07Uta6vXoYxncSxZR2GBrE1sI0eQKtbWZKP0w6Rb44QglX+atwxNLo5CcTHqJw5OkOJf1imeh4vfQSnENkjAK72iM/mgGzBY/AfIBxUswY+L9hEFxhfbH72WVO75G1k3mqB52wdj4Sjjz8kGDpppz9LNGIBeuSmrgJl0e05F4Vw9hz2vhg4i2pFwSlGZFx/J1WfI3ZH5YicIPJQ== hello+blockdown_builder@ind.ie}
#
......@@ -123,9 +141,9 @@ publicKey=${publicKey:-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCoeMcQpU1XaSkv9AZtv
#
echo -e "\n2. Secrets\n"
read -e -p "GitLab web hook token: " gitlabWebHookToken
read -e -p " GitLab web hook token: " gitlabWebHookToken
echo "Private key (paste and press return): "
echo " Private key (paste and press return): "
privateKey=$(sed '/^$/q')
echo -e "Thank you, I have all the information I need to set up the Better Builder deployment server.\n"
......@@ -249,4 +267,6 @@ dokku letsencrypt $builderDomain
# (Ask dokku-letsencrypt to check weekly.)
sudo cp ./dokku-letsencrypt-auto-renew.sh /etc/cron.weekly
echo -e "\nDone! Better Builder is now deployed and running.\n"
echo -e "\n ┌─────────────────────────────────────────────────────┐"
echo -e " │ Done! Better Builder is now deployed and running. │"
echo -e " └─────────────────────────────────────────────────────┘\n"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment