diff --git a/bin/install-federated.sh b/bin/install-federated.sh index 5d3cac2..2b8b3b7 100755 --- a/bin/install-federated.sh +++ b/bin/install-federated.sh @@ -3,48 +3,21 @@ # Federated installation script PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +. /federated/lib/functions.sh 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 +# 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 +# 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 @@ -63,6 +36,7 @@ get_config() { . /federated/lib/wireguard.sh . /federated/lib/connector.sh . /federated/lib/baserow.sh + . /federated/lib/calcom.sh echo -ne "\nFederated Stack install script\n\n" read -p '* Enter domain name (domain.com): ' DOMAIN @@ -93,7 +67,7 @@ check_ports 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 baserow; do +for i in dns postgresql ldap mail collabora proxy nextcloud matrix element listmonk vaultwarden panel wireguard jitsi connector baserow calcom; do config_$i start_$i done @@ -113,6 +87,7 @@ vaultwarden.$DOMAIN vpn.$DOMAIN connector.$DOMAIN baserow.$DOMAIN +calcom.$DOMAIN * Your VPN Wireguard configuration is.. EOF diff --git a/bin/start.sh b/bin/start.sh index 0d817e7..968d616 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -3,7 +3,7 @@ # Federated Start Script usage() { - echo "$0: all|dns|postgresql|ldap|mail|collabora|nextcloud|matrix|element|jitsi|listmonk|vaultwarden|panel|proxy|wireguard|connector|baserow" + echo "$0: all|dns|postgresql|ldap|mail|collabora|nextcloud|matrix|element|jitsi|listmonk|vaultwarden|panel|proxy|wireguard|connector|baserow|calcom" exit 2 } startservice() { @@ -11,7 +11,7 @@ startservice() { cd /federated/apps/$SERVICE && docker-compose -f docker-compose.yml -p $SERVICE up -d } startservice_all() { - for i in dns postgresql ldap mail collabora nextcloud matrix element jitsi listmonk vaultwarden panel proxy wireguard connector baserow; do + for i in dns postgresql ldap mail collabora nextcloud matrix element jitsi listmonk vaultwarden panel proxy wireguard connector baserow calcom; do echo "* Starting $i.." cd /federated/apps/$i && docker-compose -f docker-compose.yml -p $i up -d done @@ -22,6 +22,6 @@ SERVICE=$1 case "$SERVICE" in all) startservice_all;; - dns|postgresql|ldap|mail|collabora|nextcloud|matrix|element|jitsi|listmonk|vaultwarden|panel|proxy|wireguard|connector|baserow) startservice;; + dns|postgresql|ldap|mail|collabora|nextcloud|matrix|element|jitsi|listmonk|vaultwarden|panel|proxy|wireguard|connector|baserow|calcom) startservice;; *) usage;; esac diff --git a/bin/stop.sh b/bin/stop.sh index 8fc69e5..187606f 100755 --- a/bin/stop.sh +++ b/bin/stop.sh @@ -3,7 +3,7 @@ # Federated Stop Script usage() { - echo "$0: all|dns|postgresql|ldap|mail|collabora|nextcloud|matrix|element|jitsi|listmonk|vaultwarden|panel|proxy|wireguard|connector|baserow" + echo "$0: all|dns|postgresql|ldap|mail|collabora|nextcloud|matrix|element|jitsi|listmonk|vaultwarden|panel|proxy|wireguard|connector|baserow|calcom" exit 2 } stopservice() { @@ -11,7 +11,7 @@ stopservice() { cd /federated/apps/$SERVICE && docker-compose -f docker-compose.yml -p $SERVICE down } stopservice_all() { - for i in dns postgresql ldap mail collabora nextcloud matrix element jitsi listmonk vaultwarden panel proxy wireguard connector baserow; do + for i in dns postgresql ldap mail collabora nextcloud matrix element jitsi listmonk vaultwarden panel proxy wireguard connector baserow calcom; do echo "* Stopping $i.." cd /federated/apps/$i && docker-compose -f docker-compose.yml -p $i down done @@ -22,6 +22,6 @@ SERVICE=$1 case "$SERVICE" in all) stopservice_all;; - dns|postgresql|ldap|mail|collabora|nextcloud|matrix|element|jitsi|listmonk|vaultwarden|panel|proxy|wireguard|connector|baserow) stopservice;; + dns|postgresql|ldap|mail|collabora|nextcloud|matrix|element|jitsi|listmonk|vaultwarden|panel|proxy|wireguard|connector|baserow|calcom) stopservice;; *) usage;; esac diff --git a/lib/baserow.sh b/lib/baserow.sh index 957ea2e..38067dd 100644 --- a/lib/baserow.sh +++ b/lib/baserow.sh @@ -64,10 +64,10 @@ cat > /federated/apps/baserow/data/createuser.sh < /dev/null EOF chmod +x /federated/apps/baserow/data/createuser.sh @@ -76,36 +76,8 @@ echo -ne "done." } start_baserow() { - # Start /federated/apps/baserow with output to /dev/null - echo -ne "\n* Starting /federated/apps/baserow service.." - spin & - SPINPID=$! - - if [ $DEBUG ]; then - # Start /federated/apps/baserow with output to console for debug - docker-compose -f /federated/apps/baserow/docker-compose.yml -p baserow up - [ $? -eq 0 ] && echo -ne "done.\n" || fail "There was a problem starting service /federated/apps/baserow" - else - docker-compose -f /federated/apps/baserow/docker-compose.yml -p baserow up -d &> /dev/null - - # Keep trying baserow port 3000 to make sure it's up - # before we proceed - RETRY="30" - while [ $RETRY -gt 0 ]; do - docker exec -it baserow curl http://localhost:3000 &> /dev/null - if [ $? -eq 0 ]; then - break - else - if [ "$RETRY" == 1 ]; then - docker-compose -f /federated/apps/baserow/docker-compose.yml -p baserow down &> /dev/null - kill -9 $SPINPID &> /dev/null - fail "There was a problem starting service /federated/apps/baserow\nCheck the output of 'docker logs baserow' or turn on\ndebug with -d" - fi - ((RETRY--)) - sleep 7 - fi - done - fi + # Start service with command to make sure it's up before proceeding + start_service "baserow" "docker exec -it baserow curl http://localhost:8000 &> /dev/null" # Move createuser.sh and set it executable mv /federated/apps/baserow/data/createuser.sh /federated/apps/baserow/data/baserow/data/ diff --git a/lib/calcom.sh b/lib/calcom.sh new file mode 100644 index 0000000..63a93e8 --- /dev/null +++ b/lib/calcom.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# Cal.com Service + +PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +config_calcom() { + echo -ne "\n* Configuring /federated/apps/calcom container.." + spin & + SPINPID=$! + + if [ ! -d "/federated/apps/calcom" ]; then + mkdir -p /federated/apps/calcom + fi + + DOMAIN_ARRAY=(${DOMAIN//./ }) + DOMAIN_FIRST=${DOMAIN_ARRAY[0]} + DOMAIN_LAST=${DOMAIN_ARRAY[1]} + +cat > /federated/apps/calcom/docker-compose.yml </dev/null | md5sum | awk '{ print $1 }'` +sed -i "s#CALENDSO_ENCRYPTION_KEY=.*#CALENDSO_ENCRYPTION_KEY=$CALENDSO_ENCRYPTION_KEY#g" /federated/apps/calcom/.env + +sed -i "s#POSTGRES_USER=.*#POSTGRES_USER=calcom#g" /federated/apps/calcom/.env +sed -i "s#POSTGRES_PASSWORD=.*#POSTGRES_PASSWORD=$CALCOM_SECRET#g" /federated/apps/calcom/.env +sed -i "s#POSTGRES_DB=.*#POSTGRES_DB=calcom#g" /federated/apps/calcom/.env +sed -i "s#DATABASE_HOST=.*#DATABASE_HOST=postgresql\.$DOMAIN:5432#g" /federated/apps/calcom/.env +sed -i "s#DATABASE_URL=.*#DATABASE_URL=postgresql://calcom:$CALCOM_SECRET@postgresql\.$DOMAIN/calcom#g" /federated/apps/calcom/.env + +cat >> /federated/apps/calcom/.env < /dev/null +echo -ne "done." +} + +start_calcom() { + # Start service with command to make sure it's up before proceeding + start_service "calcom" "nc -z 172.99.0.29 3000 &> /dev/null" + + kill -9 $SPINPID &> /dev/null + echo -ne "done." +} diff --git a/lib/checks.sh b/lib/checks.sh index cf7e22d..00c9ac0 100644 --- a/lib/checks.sh +++ b/lib/checks.sh @@ -58,8 +58,8 @@ check_ports() { # Check if ss command exists if command -v ss &> /dev/null; then - # Check every port we need if it's in use - for i in 25 53 80 143 389 587 993 8000; do + # Check every port we need if it's in use + for i in 25 53 80 143 389 587 993 8000; do SS=`ss -tulwn | grep LISTEN | awk '{ print $5 }' | awk -F: '{ print $NF }' | grep "^$i$" | head -1` # If port 53 (dns) in use by system-resolvd (Ubuntu) then auto fix if [ "$SS" == 53 ]; then diff --git a/lib/dns.sh b/lib/dns.sh index fc6e1f1..d90d432 100644 --- a/lib/dns.sh +++ b/lib/dns.sh @@ -188,6 +188,8 @@ listmonk IN A $EXTERNALIP vaultwarden IN A $EXTERNALIP vpn IN A $EXTERNALIP connector IN A $EXTERNALIP +baserow IN A $EXTERNALIP +calcom IN A $EXTERNALIP $DOMAIN. IN A $EXTERNALIP EOF diff --git a/lib/files/calcom/.env b/lib/files/calcom/.env new file mode 100644 index 0000000..4c9c1dc --- /dev/null +++ b/lib/files/calcom/.env @@ -0,0 +1,61 @@ +# Set this value to 'agree' to accept our license: +# LICENSE: https://github.com/calendso/calendso/blob/main/LICENSE +# +# Summary of terms: +# - The codebase has to stay open source, whether it was modified or not +# - You can not repackage or sell the codebase +# - Acquire a commercial license to remove these terms by emailing: license@cal.com +NEXT_PUBLIC_LICENSE_CONSENT= +LICENSE= + +# BASE_URL and NEXT_PUBLIC_APP_URL are both deprecated. Both are replaced with one variable, NEXT_PUBLIC_WEBAPP_URL +# BASE_URL=http://localhost:3000 +# NEXT_PUBLIC_APP_URL=http://localhost:3000 + +NEXT_PUBLIC_WEBAPP_URL=http://localhost + +# Configure NEXTAUTH_URL manually if needed, otherwise it will resolve to {NEXT_PUBLIC_WEBAPP_URL}/api/auth +# NEXTAUTH_URL=http://localhost:3000/api/auth + +# It is highly recommended that the NEXTAUTH_SECRET must be overridden and very unique +# Use `openssl rand -base64 32` to generate a key +NEXTAUTH_SECRET=secret + +# Encryption key that will be used to encrypt CalDAV credentials, choose a random string, for example with `dd if=/dev/urandom bs=1K count=1 | md5sum` +CALENDSO_ENCRYPTION_KEY=secret + +# Deprecation note: JWT_SECRET is no longer used +# JWT_SECRET=secret + +POSTGRES_USER=cal +POSTGRES_PASSWORD=secret +POSTGRES_DB=cal +DATABASE_HOST=postgresql:5432 +DATABASE_URL=postgresql +GOOGLE_API_CREDENTIALS={} + +# Set this to '1' if you don't want Cal to collect anonymous usage +CALCOM_TELEMETRY_DISABLED= + +# Used for the Office 365 / Outlook.com Calendar integration +MS_GRAPH_CLIENT_ID= +MS_GRAPH_CLIENT_SECRET= + +# Used for the Zoom integration +ZOOM_CLIENT_ID= +ZOOM_CLIENT_SECRET= + +# E-mail settings +# Configures the global From: header whilst sending emails. +EMAIL_FROM=notifications@example.com + +# Configure SMTP settings (@see https://nodemailer.com/smtp/). +EMAIL_SERVER_HOST=smtp.example.com +EMAIL_SERVER_PORT=587 +EMAIL_SERVER_USER=email_user +EMAIL_SERVER_PASSWORD=email_password + +NODE_ENV=production +VIRTUAL_PROTO=http +VIRTUAL_PORT=3000 +VIRTUAL_HOST=calcom.northendnetwork.com diff --git a/lib/files/connector/FederatedCore.dmg b/lib/files/connector/FederatedCore.dmg index f95ce12..94c7860 100644 Binary files a/lib/files/connector/FederatedCore.dmg and b/lib/files/connector/FederatedCore.dmg differ diff --git a/lib/functions.sh b/lib/functions.sh index 94b0ff6..5f3fb74 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -1,3 +1,32 @@ +# Federated Computer functions + +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; +} +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 +} create_password() { # eval $1_var=$1 # echo "$postgres_var" @@ -5,12 +34,15 @@ create_password() { echo "$SECRET"; } start_blah() { - echo "val1 is $1"; - echo "val2 is $2"; - echo "val3 is $3"; - echo "val4 is $4"; + SERVICE="$1" + COMMAND="$2" + $COMMAND &> /dev/null + [ $? -eq 0 ] && echo -ne "done.\n" || fail "There was a problem starting service /federated/apps/$SERVICE" } start_service() { + SERVICE="$1" + COMMAND="$2" + # Start /federated/apps/SERVICE with output to /dev/null echo -ne "\n* Starting /federated/apps/$SERVICE service.." spin & @@ -19,7 +51,7 @@ start_service() { if [ $DEBUG ]; then # Start /federated/apps/SERVICE with output to console for debug docker-compose -f /federated/apps/$SERVICE/docker-compose.yml -p $SERVICE up - [ $? -eq 0 ] && echo -ne "done.\n" || fail "There was a problem starting service /federated/apps/SERVICE" + [ $? -eq 0 ] && echo -ne "done.\n" || fail "There was a problem starting service /federated/apps/$SERVICE" else docker-compose -f /federated/apps/$SERVICE/docker-compose.yml -p $SERVICE up -d &> /dev/null @@ -27,7 +59,7 @@ start_service() { # we proceed RETRY="30" while [ $RETRY -gt 0 ]; do - nc -z 172.99.0.19 9000 &> /dev/null + bash -c "$COMMAND" &> /dev/null if [ $? -eq 0 ]; then break else diff --git a/lib/listmonk.sh b/lib/listmonk.sh index e29507d..785878b 100644 --- a/lib/listmonk.sh +++ b/lib/listmonk.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Federated Computer Listmonk Service +# Listmonk Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin diff --git a/lib/mail.sh b/lib/mail.sh index fef8aae..97ca43e 100644 --- a/lib/mail.sh +++ b/lib/mail.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Federated Computer Mail Service +# Mail Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin diff --git a/lib/nextcloud.sh b/lib/nextcloud.sh index 1122b2f..23990e2 100644 --- a/lib/nextcloud.sh +++ b/lib/nextcloud.sh @@ -160,6 +160,7 @@ PATH=/var/www/html:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/sbin:/bin ./occ ldap:set-config s01 turnOnPasswordChange 0 ./occ ldap:set-config s01 useMemberOfToDetectMembership 1 ./occ ldap:set-config s01 ldapConfigurationActive 1 +./occ ldap:set-config s01 ldap_expert_username_attr uid ./occ config:system:set overwriteprotocol --value=https ./occ config:system:delete trusted_domains ./occ config:system:set trusted_domains 1 --value=* diff --git a/lib/postgresql.sh b/lib/postgresql.sh index ca99fc9..0e51424 100644 --- a/lib/postgresql.sh +++ b/lib/postgresql.sh @@ -77,6 +77,7 @@ VAULTWARDEN_SECRET=$(create_password); LISTMONK_SECRET=$(create_password); MATRIX_SECRET=$(create_password); BASEROW_SECRET=$(create_password); +CALCOM_SECRET=$(create_password); # cat postgresql/data/docker-entrypoint-initdb.d/init.sql cat > /federated/apps/postgresql/data/docker-entrypoint-initdb.d/init.sql < /dev/null