diff --git a/scripts/setup-apt.sh b/scripts/setup-apt.sh index 346e466..f76a515 100644 --- a/scripts/setup-apt.sh +++ b/scripts/setup-apt.sh @@ -1,7 +1,7 @@ function apt-install { for pkg in $@; do echo -e "[APT-GET] Installing package $pkg..." - sudo apt-get install -yq $pkg + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" $pkg done } @@ -20,5 +20,5 @@ function package-not-installed { } sudo apt-get -y update -sudo apt-get -y upgrade -sudo apt-get -y dist-upgrade +sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" upgrade +sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" dist-upgrade diff --git a/scripts/setup-backend.sh b/scripts/setup-backend.sh index 14a5957..4d0005d 100644 --- a/scripts/setup-backend.sh +++ b/scripts/setup-backend.sh @@ -7,15 +7,15 @@ pushd ~ cat > /tmp/settings.py < /dev/null sudo -u postgres createdb $USER &> /dev/null touch ~/.setup/postgresql fi - diff --git a/scripts/setup-python.sh b/scripts/setup-python.sh index 314cf3a..8e6238d 100644 --- a/scripts/setup-python.sh +++ b/scripts/setup-python.sh @@ -1,10 +1,17 @@ #!/bin/bash -apt-install-if-needed python3 python3-pip python-dev python3-dev python-pip virtualenvwrapper libxml2-dev libxslt1-dev +if [ "$VERSION_ID" = "18.04" ]; then + # Define python version for virtualenv + PYTHON_VERSION="python3.6" + apt-install-if-needed python3 python3-pip python3-dev python3-pip virtualenvwrapper +elif [ "$VERSION_ID" = "16.04" ]; then + PYTHON_VERSION="python3.5" + apt-install-if-needed python3 python3-pip python-dev python3-dev python-pip virtualenvwrapper libxml2-dev libxslt1-dev +fi source /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh function mkvirtualenv-if-needed { for envname in $@; do - $(lsvirtualenv | grep -q "$envname") || mkvirtualenv "$envname" -p /usr/bin/python3.5 + $(lsvirtualenv | grep -q "$envname") || mkvirtualenv "$envname" -p /usr/bin/$PYTHON_VERSION done } diff --git a/scripts/setup-vars.sh b/scripts/setup-vars.sh index ec0f76a..2ace734 100644 --- a/scripts/setup-vars.sh +++ b/scripts/setup-vars.sh @@ -1,21 +1,54 @@ mkdir -p ~/.setup if [ -e ~/.setup/data.sh ]; then + # For unattended install get variables from cloud installer source ~/.setup/data.sh else - echo -n "Scheme (default http): " - read scheme - echo -n "Hostname (default: localhost:8000): " - read hostname - if [ -z "$hostname" ]; then - hostname="localhost:8000" - fi + # Determine active network interface and active IP Address, if not connected, use hostname + NET_INTERFACE=$(ip addr show | awk '/inet.*brd/{print $NF; exit}') + if [[ $NET_INTERFACE = "" ]]; then + IP_ADDRESS=$(hostname) + else + IP_ADDRESS=${TAIGA_DOMAIN:-$(/sbin/ifconfig $NET_INTERFACE | awk '/inet / { print $2 }' | sed 's/addr://')} + fi + + read -p "Host name (default: $(hostname)):" TAIGA_HOSTNAME + TAIGA_HOSTNAME=${TAIGA_HOSTNAME:-$(hostname)} + + read -p "Fully qualified domain name or IP address (default: $IP_ADDRESS): " TAIGA_DOMAIN + TAIGA_DOMAIN=${TAIGA_DOMAIN:-$IP_ADDRESS} - if [ -z "$scheme" ]; then - scheme="http" + if [ "$TAIGA_DOMAIN" != "$IP_ADDRESS" ] ; then + read -p "Use encryption (from letsencrypt.org + certbot) for domain '$TAIGA_DOMAIN' - requires email next step (y/N):" TAIGA_ENCRYPT + case $TAIGA_ENCRYPT in + [Yy]* ) TAIGA_ENCRYPT="True";; + * ) TAIGA_ENCRYPT="False";; + esac + + if [ "$TAIGA_ENCRYPT" == "True" ] ; then + TAIGA_SCHEME="https" + while [[ $TAIGA_SSL_EMAIL == "" ]]; do + read -p "Email to use for certificate notifications (required, cartificate will fail if invalid): " TAIGA_SSL_EMAIL + done fi + + fi + + read -p "Import Sample Projects (Y/n):" TAIGA_SAMPLE_DATA + case $TAIGA_SAMPLE_DATA in + [Nn]* ) TAIGA_SAMPLE_DATA="False";; + * ) TAIGA_SAMPLE_DATA="True";; + esac + + read -p "Public Registation Enabled: (Y/n):" TAIGA_PUBLIC_REGISTER_ENABLED + case $TAIGA_PUBLIC_REGISTER_ENABLED in + [Nn]* ) TAIGA_PUBLIC_REGISTER_ENABLED="False";; + * ) TAIGA_PUBLIC_REGISTER_ENABLED="True";; + esac + + TAIGA_SCHEME=${TAIGA_SCHEME:-"http"} + fi -echo "Installing taigaio with user=$USER host=$hostname scheme=$scheme" sleep 2 diff --git a/setup-devel.sh b/setup-devel.sh index f79ab22..d6f259f 100755 --- a/setup-devel.sh +++ b/setup-devel.sh @@ -6,8 +6,12 @@ mkdir -p logs mkdir -p conf popd +# System information and verification +source ./scripts/setup-os-release.sh + # Bootstrap -# source ./scripts/setup-vars.sh +source ./scripts/setup-vars.sh +source ./scripts/setup-hostname.sh source ./scripts/setup-config.sh source ./scripts/setup-apt.sh @@ -23,4 +27,3 @@ source ./scripts/setup-python.sh # Setup Taiga source ./scripts/setup-frontend.sh source ./scripts/setup-backend.sh - diff --git a/setup-server.sh b/setup-server.sh index 1d1af7a..214da2e 100755 --- a/setup-server.sh +++ b/setup-server.sh @@ -10,3 +10,7 @@ source ./setup-devel.sh # Post Setup Services source ./scripts/setup-circus.sh source ./scripts/setup-nginx.sh +source ./scripts/setup-certbot.sh + +# Display install info +source ./scripts/setup-post-install.sh