test/bin/install-federated.sh
2023-01-23 18:09:30 +00:00

118 lines
2.8 KiB
Bash
Executable File

#!/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 "apps/dns" ] && rm -rf apps/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 "/federated/lib" ] && mkdir -p /federated/lib
# Download each library file
for i in checks network dns ldap mail; do
if [ ! -f "/federated/lib/$i.sh" ]; then
curl $FSTACKURL/$i.sh -o /federated/lib/$i.sh -s -f &> /dev/null
[ $? -ne 0 ] && failcheck "Couldn't download $i.sh"
fi
done
. /federated/lib/functions.sh
. /federated/lib/checks.sh
. /federated/lib/network.sh
. /federated/lib/dns.sh
. /federated/lib/postgresql.sh
. /federated/lib/ldap.sh
. /federated/lib/mail.sh
. /federated/lib/collabora.sh
. /federated/lib/nextcloud.sh
. /federated/lib/matrix.sh
. /federated/lib/element.sh
. /federated/lib/jitsi.sh
. /federated/lib/listmonk.sh
. /federated/lib/vaultwarden.sh
. /federated/lib/panel.sh
. /federated/lib/proxy.sh
. /federated/lib/wireguard.sh
. /federated/lib/connector.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 not in use
check_docker
check_ports
# Configure docker private network
config_network
# Configure and start each federated service
for i in dns postgresql ldap mail collabora proxy nextcloud matrix element listmonk vaultwarden panel wireguard jitsi connector; do
config_$i
start_$i
done
# Print out federated environment details
cat << EOF
* The services are at these hostnames..
mail.$DOMAIN
www.$DOMAIN
panel.$DOMAIN
nextcloud.$DOMAIN
jitsi.$DOMAIN
element.$DOMAIN
listmonk.$DOMAIN
vaultwarden.$DOMAIN
vpn.$DOMAIN
connector.$DOMAIN
* Your VPN Wireguard configuration is..
EOF
cat /federated/apps/wireguard/data/config/peer1/peer1.conf