#!/bin/bash DOMAINS=() welcome_message() { clear echo "#======================================================================#" echo -e "#\e[31m ____ __ ____ _ _ __ __ _ __ ___ ____ ____ \e[0m#" echo -e "#\e[31m ( __)/ _\ ( _ \ ___ ( \/ ) / _\ ( ( \ / _\ / __)( __)( _ \ \e[0m#" echo -e "#\e[31m ) _)/ \ ) _ ((___)/ \/ \/ \/ // \( (_ \ ) _) ) / \e[0m#" echo -e "#\e[31m (__) \_/\_/(____/ \_)(_/\_/\_/\_)__)\_/\_/ \___/(____)(__\_) \e[0m#" echo "# #" echo "#======================================================================#" printf "\n Welcome to Fab-Manager's setup assistant\n\n\n" echo "Thank you for installing Fab-Manager." printf "This script will guide you through the installation process of Fab-Manager\n\n" echo -e "Please report any \e[1mfeedback or improvement request\e[21m on https://feedback.fab-manager.com/" echo -e "For \e[1mbug reports\e[21m, please open a new issue on https://github.com/sleede/fab-manager/issues" echo -e "You can call for \e[1mcommunity assistance\e[21m on https://forum.fab-manager.com/" printf "\nYou can interrupt this installation at any time by pressing Ctrl+C\n" printf "If you do not feel confortable with this installation, you can \e[4msubscribe to our hosting plan\e[24m: contact@fab-manager.com\n\n" read -rp "Continue? (Y/n) " confirm " email ' domain "$FABMANAGER_PATH/config/env" # nginx configuration if [ "$NGINX" != "n" ]; then mkdir -p "$FABMANAGER_PATH/config/nginx" \curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/setup/nginx_with_ssl.conf.example > "$FABMANAGER_PATH/config/nginx/fabmanager.conf.ssl" \curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/setup/nginx.conf.example > "$FABMANAGER_PATH/config/nginx/fabmanager.conf" fi # let's encrypt configuration if [ "$LETSENCRYPT" != "n" ]; then mkdir -p "$FABMANAGER_PATH/letsencrypt/etc/config" mkdir -p "$FABMANAGER_PATH/letsencrypt/systemd" mkdir -p "$FABMANAGER_PATH/letsencrypt/etc/webrootauth" \curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/setup/webroot.ini.example > "$FABMANAGER_PATH/letsencrypt/etc/config/webroot.ini" # temp systemd files \curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/setup/letsencrypt.service > "$FABMANAGER_PATH/letsencrypt/systemd/letsencrypt.service" \curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/setup/letsencrypt.timer > "$FABMANAGER_PATH/letsencrypt/systemd/letsencrypt.timer" fi # ElasticSearch configuration files \curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/setup/elasticsearch.yml > "$FABMANAGER_PATH/elasticsearch/config/elasticsearch.yml" \curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/setup/log4j2.properties > "$FABMANAGER_PATH/elasticsearch/config/log4j2.properties" # docker-compose \curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/setup/docker-compose.yml > "$FABMANAGER_PATH/docker-compose.yml" } prepare_nginx() { if [ "$NGINX" != "n" ]; then sed -i.bak "s/MAIN_DOMAIN/${MAIN_DOMAIN[0]}/g" "$FABMANAGER_PATH/config/nginx/fabmanager.conf" sed -i.bak "s/MAIN_DOMAIN/${MAIN_DOMAIN[0]}/g" "$FABMANAGER_PATH/config/nginx/fabmanager.conf.ssl" sed -i.bak "s/ANOTHER_DOMAIN_1/$OTHER_DOMAINS/g" "$FABMANAGER_PATH/config/nginx/fabmanager.conf.ssl" sed -i.bak "s/URL_WITH_PROTOCOL_HTTPS/https:\/\/${MAIN_DOMAIN[0]}/g" "$FABMANAGER_PATH/config/nginx/fabmanager.conf.ssl" fi } function join_by { local IFS="$1"; shift; echo "$*"; } prepare_letsencrypt() { if [ "$LETSENCRYPT" != "n" ]; then if ! openssl dhparam -in "$FABMANAGER_PATH/config/nginx/ssl/dhparam.pem" -check; then mkdir -p "$FABMANAGER_PATH/config/nginx/ssl" printf "\n\nNow, we will generate a Diffie-Hellman (DH) 4096 bits encryption key, to encrypt connections. This will take a moment, please wait...\n" openssl dhparam -out "$FABMANAGER_PATH/config/nginx/ssl/dhparam.pem" 4096 fi sed -i.bak "s/REPLACE_WITH_YOUR@EMAIL.COM/$EMAIL/g" "$FABMANAGER_PATH/letsencrypt/etc/config/webroot.ini" sed -i.bak "s/MAIN_DOMAIN, ANOTHER_DOMAIN_1/$(join_by , "${DOMAINS[@]}")/g" "$FABMANAGER_PATH/letsencrypt/etc/config/webroot.ini" echo "Now downloading and configuring the certificate signing bot..." docker pull certbot/certbot:latest sed -i.bak "s:/apps/fabmanager:$FABMANAGER_PATH:g" "$FABMANAGER_PATH/letsencrypt/systemd/letsencrypt.service" sudo cp "$FABMANAGER_PATH/letsencrypt/systemd/letsencrypt.service" /etc/systemd/system/letsencrypt.service sudo cp "$FABMANAGER_PATH/letsencrypt/systemd/letsencrypt.timer" /etc/systemd/system/letsencrypt.timer sudo systemctl daemon-reload fi } prepare_docker() { if [ "$(docker ps | wc -l)" -gt 1 ]; then printf "\n\nIf you have previously interrupted the installer, it is recommended to stop any existing docker container before continuing.\n" echo "Here's a list of all existing containers:" docker ps -a read -rp "Force remove all containers? (y/N) " confirm " value &2 echo "Please input a password for this administrator's account" read -rsp " > " password &2 printf "\nConfirm the password\n" read -rsp " > " confirmation &2 printf "\nError: passwords mismatch\n" password=$(read_password) fi echo "$password" } setup_assets_and_databases() { printf "\n\nWe will now setup the database.\n" read -rp "Continue? (Y/n) " confirm