From e782725111e1cf0b87c54bfc7c406328dec3ce95 Mon Sep 17 00:00:00 2001 From: Derek Crudgington Date: Fri, 31 Mar 2023 13:05:41 +0000 Subject: [PATCH] Fixed gitea and caddy --- bin/install-federated.sh | 3 +- lib/dns.sh | 1 + lib/functions.sh | 60 +++++++++++++++++++++------------------- lib/gitea.sh | 4 +-- lib/panel.sh | 2 +- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/bin/install-federated.sh b/bin/install-federated.sh index 8e35a24..36473d7 100755 --- a/bin/install-federated.sh +++ b/bin/install-federated.sh @@ -33,7 +33,6 @@ get_config() { . /federated/lib/panel.sh . /federated/lib/proxy.sh . /federated/lib/wireguard.sh - . /federated/lib/connector.sh . /federated/lib/baserow.sh . /federated/lib/calcom.sh . /federated/lib/gitea.sh @@ -80,7 +79,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 calcom gitea caddy; do +for i in dns postgresql ldap mail collabora proxy nextcloud matrix element listmonk vaultwarden panel wireguard jitsi baserow calcom gitea caddy; do config_$i start_$i done diff --git a/lib/dns.sh b/lib/dns.sh index 38a97dd..698b830 100644 --- a/lib/dns.sh +++ b/lib/dns.sh @@ -189,6 +189,7 @@ vaultwarden IN A $EXTERNALIP vpn IN A $EXTERNALIP connector IN A $EXTERNALIP baserow IN A $EXTERNALIP +gitea IN A $EXTERNALIP calcom IN A $EXTERNALIP blog IN A $EXTERNALIP documentation IN A $EXTERNALIP diff --git a/lib/functions.sh b/lib/functions.sh index 9d017ad..25bdcc0 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -187,41 +187,43 @@ 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 - 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 - if [ $OSRELEASE == "Ubuntu" ]; then - if [ `pgrep -x systemd-resolve` ]; then - echo -ne "\n* Port 53 in use by systemd-resolved, fixing.." - spin & - SPINPID=$! + # Check every port we need if it's in use (only if we have never run before) + if [ $(ls /federated/apps | wc -l) -eq "0" ]; then + 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 + if [ $OSRELEASE == "Ubuntu" ]; then + if [ `pgrep -x systemd-resolve` ]; then + echo -ne "\n* Port 53 in use by systemd-resolved, fixing.." + spin & + SPINPID=$! - # Install resolvconf to fix - sudo apt install resolvconf -y &> /dev/null - [ $? -eq 0 ] && echo -ne "." || failcheck "Failed running sudo apt install resolvconf" + # Install resolvconf to fix + sudo apt install resolvconf -y &> /dev/null + [ $? -eq 0 ] && echo -ne "." || failcheck "Failed running sudo apt install resolvconf" - # Shut down systemd-resolved - systemctl stop systemd-resolved &> /dev/null - [ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved" - systemctl disable systemd-resolved &> /dev/null - [ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved" + # Shut down systemd-resolved + systemctl stop systemd-resolved &> /dev/null + [ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved" + systemctl disable systemd-resolved &> /dev/null + [ $? -ne 0 ] && failcheck "Failed running systemctl stop systemd-resolved" - # Put nameserver entries so will exist on reboot - echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/tail - echo "nameserver 8.8.8.8" > /run/resolvconf/resolv.conf + # Put nameserver entries so will exist on reboot + echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/tail + echo "nameserver 8.8.8.8" > /run/resolvconf/resolv.conf - kill -9 $SPINPID &> /dev/null - echo -ne "done." - else + kill -9 $SPINPID &> /dev/null + echo -ne "done." + else echo -ne "\nFAILED - Port 53 (dns) is already in use\n\n" && exit 2 - fi + fi + fi + elif [ "$SS" == "$i" ]; then + failcheck "FAILED - Port $i is already in use" fi - elif [ "$SS" == "$i" ]; then - failcheck "FAILED - Port $i is already in use" - fi - done + done + fi fi } check_os() { diff --git a/lib/gitea.sh b/lib/gitea.sh index 2ab9ded..851b494 100644 --- a/lib/gitea.sh +++ b/lib/gitea.sh @@ -83,10 +83,10 @@ GITEA_TOKEN_2=\`curl -H "Content-Type: application/json" -d '{"name":"gitea2","s # Create the repository and webhooks for i in www blog documentation; do # Create the repository - curl -k -X POST http://gitea.$DOMAIN:3000/api/v1/user/repos -H "content-type: application/json" -H "Authorization: token \$GITEA_TOKEN_2" --data '{"name":"$i.$DOMAIN","auto_init":true,"default_branch":"master"}' + curl -k -X POST http://gitea.$DOMAIN:3000/api/v1/user/repos -H "content-type: application/json" -H "Authorization: token \$GITEA_TOKEN_2" --data "{\"name\":\"\$i.$DOMAIN\",\"auto_init\":true,\"default_branch\":\"master\"}" # Create the webhook curl -X 'POST' \ - 'http://gitea.$DOMAIN:3000/api/v1/repos/gitea/$i.$DOMAIN/hooks' \ + "http://gitea.$DOMAIN:3000/api/v1/repos/gitea/\$i.$DOMAIN/hooks" \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -H "Authorization: token \$GITEA_TOKEN_2" \ diff --git a/lib/panel.sh b/lib/panel.sh index 645e9ff..dd7ea42 100644 --- a/lib/panel.sh +++ b/lib/panel.sh @@ -39,7 +39,7 @@ networks: EOF cat > /federated/apps/panel/.env <