#!/bin/bash # # Federated installation script PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin trap cleanup `seq 0 15` cleanup() { kill -9 $SPINPID &> /dev/null exit 2 } spin() { spinner="/|\\-/|\\-" while : do for i in `seq 0 7` do echo -n "${spinner:$i:1}" echo -en "\010" sleep 1 done done } fail() { echo -ne "FAILED\n\n$1\n\n" kill -9 $SPINPID &> /dev/null # [ -d "fstack/dns" ] && rm -rf fstack/dns # docker network rm fstack &> /dev/null exit 2; } failcheck() { echo -ne "\n\nFAILED - $1\n\n" exit 2; } get_config() { FSTACKURL="http://137.184.95.3:8000" [ ! -d "fstack/lib" ] && mkdir -p fstack/lib # Download each library file for i in checks network dns ldap mail; do if [ ! -f "fstack/lib/$i.sh" ]; then curl $FSTACKURL/$i.sh -o fstack/lib/$i.sh -s -f &> /dev/null [ $? -ne 0 ] && failcheck "Couldn't download $i.sh" fi done . fstack/lib/checks.sh . fstack/lib/network.sh . fstack/lib/dns.sh . fstack/lib/ldap.sh . fstack/lib/mail.sh . fstack/lib/nextcloud.sh . fstack/lib/panel.sh . fstack/lib/proxy.sh echo -ne "\nFederated Stack install script\n\n" read -p '* Enter domain name (domain.com): ' DOMAIN read -p '* Enter company name (Domain Company): ' COMPANY read -sp '* Enter admin password to use for initial login: ' ADMINPASS [ -z "$DOMAIN" ] && failcheck "Must enter a domain name" [ -z "$COMPANY" ] && failcheck "Must enter a company name" [ -z "$ADMINPASS" ] && failcheck "Must enter a admin password" } while getopts d OPTION; do case "$OPTION" in d) DEBUG=ON;; esac done # Download lib scripts and take in setup variables get_config echo -ne "\n\nStarting Federated install for $DOMAIN\n" # Check that we have docker installed. Check that # we have all ports available and ont in use check_docker check_ports # Configure docker private network config_network # Configure fstack/dns container and start it config_dns start_dns # Configure fstack/ldap container and start it config_ldap start_ldap # Configure fstack/mail container and start it config_mail start_mail # Configure fstack/nextcloud container and start it config_nextcloud start_nextcloud # Configure fstack/panel container and start it config_panel start_panel # Configure fstack/proxy container and start it config_proxy start_proxy # Print out fstack environment details echo -ne "\n\nInstall completed successfully.\n\n" echo -ne "Certificates at fstack/dns/data/etc/letsencrypt/archive/$DOMAIN\n" echo -ne "Webmail is at http://www.$DOMAIN:9002\n" echo -ne "Login user: admin Password: Provided at start\n"