diff options
-rw-r--r-- | bin/ncp-diag | 6 | ||||
-rw-r--r-- | bin/ncp/NETWORKING/dnsmasq.sh | 7 | ||||
-rw-r--r-- | bin/ncp/NETWORKING/nc-forward-ports.sh | 8 | ||||
-rw-r--r-- | bin/ncp/UPDATES/nc-notify-updates.sh | 6 | ||||
-rw-r--r-- | bin/nextcloud-domain.sh | 7 | ||||
-rw-r--r-- | changelog.md | 4 | ||||
-rw-r--r-- | etc/library.sh | 7 | ||||
-rw-r--r-- | install.sh | 3 |
8 files changed, 27 insertions, 21 deletions
diff --git a/bin/ncp-diag b/bin/ncp-diag index d19afcef..49260a70 100644 --- a/bin/ncp-diag +++ b/bin/ncp-diag @@ -11,6 +11,8 @@ # More at https://ownyourbits.com # +source /usr/local/etc/library.sh + # Distro, NCP version and tag echo "NextCloudPi version|$( cat /usr/local/etc/ncp-version )" [[ -f /usr/local/etc/ncp-baseimage ]] && echo "NextCloudPi image|$( cat /usr/local/etc/ncp-baseimage )" @@ -67,7 +69,7 @@ function is_port_open() { local port=$1 local public_ip - public_ip="$(curl -4 https://icanhazip.com 2>/dev/null)" || { echo "closed"; return 1; } + public_ip="$(curl -m4 -4 https://icanhazip.com 2>/dev/null)" || { echo "closed"; return 1; } local tmp_file=$(mktemp) local token=$(wget -T2 -t1 -qO- --keep-session-cookies --save-cookies $tmp_file https://portchecker.co | grep -oP "_csrf\" value=\"\K.*\"") @@ -85,7 +87,7 @@ echo "port check 443|$( is_port_open 443 )" # LAN IFACE=$( ip r | grep "default via" | awk '{ print $5 }' | head -1 ) GW=$( ip r | grep "default via" | awk '{ print $3 }' | head -1 ) -IP=$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) +IP="$(get_ip)" echo "IP|$IP" echo "gateway|$GW" diff --git a/bin/ncp/NETWORKING/dnsmasq.sh b/bin/ncp/NETWORKING/dnsmasq.sh index ed765242..07fb5d2a 100644 --- a/bin/ncp/NETWORKING/dnsmasq.sh +++ b/bin/ncp/NETWORKING/dnsmasq.sh @@ -48,9 +48,10 @@ configure() return } - local IFACE=$( ip r | grep "default via" | awk '{ print $5 }' | head -1 ) - local IP=$( ncc config:system:get trusted_domains "${TRUSTED_DOMAINS[docker_overwrite]}" | grep -oP '\d{1,3}(.\d{1,3}){3}' ) - [[ "$IP" == "" ]] && IP=$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) + local IFACE IP + IFACE=$( ip r | grep "default via" | awk '{ print $5 }' | head -1 ) + IP=$( ncc config:system:get trusted_domains "${TRUSTED_DOMAINS[docker_overwrite]}" | grep -oP '\d{1,3}(.\d{1,3}){3}' ) + [[ "$IP" == "" ]] && IP="$(get_ip)" [[ "$IP" == "" ]] && { echo "could not detect IP"; return 1; } diff --git a/bin/ncp/NETWORKING/nc-forward-ports.sh b/bin/ncp/NETWORKING/nc-forward-ports.sh index f404941c..aab6c9d4 100644 --- a/bin/ncp/NETWORKING/nc-forward-ports.sh +++ b/bin/ncp/NETWORKING/nc-forward-ports.sh @@ -17,13 +17,13 @@ install() configure() { - local IFACE=$( ip r | grep "default via" | awk '{ print $5 }' | head -1 ) - local IP=$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) + local ip + ip="$(get_ip)" upnpc -d "$HTTPSPORT" TCP upnpc -d "$HTTPPORT" TCP - upnpc -a "$IP" 443 "$HTTPSPORT" TCP | tee >(cat - >&2) | grep -q "is redirected to internal" || \ + upnpc -a "$ip" 443 "$HTTPSPORT" TCP | tee >(cat - >&2) | grep -q "is redirected to internal" || \ { echo -e "\nCould not forward ports automatically.\nDo it manually, or activate UPnP in your router and try again"; return 1; } - upnpc -a "$IP" 80 "$HTTPPORT" TCP | tee >(cat - >&2) | grep -q "is redirected to internal" || \ + upnpc -a "$ip" 80 "$HTTPPORT" TCP | tee >(cat - >&2) | grep -q "is redirected to internal" || \ { echo -e "\nCould not forward ports automatically.\nDo it manually, or activate UPnP in your router and try again"; return 1; } } diff --git a/bin/ncp/UPDATES/nc-notify-updates.sh b/bin/ncp/UPDATES/nc-notify-updates.sh index 98e4240f..de239f13 100644 --- a/bin/ncp/UPDATES/nc-notify-updates.sh +++ b/bin/ncp/UPDATES/nc-notify-updates.sh @@ -12,7 +12,6 @@ # check every hour CHECKINTERVAL=1 -NCDIR=/var/www/nextcloud configure() { @@ -41,12 +40,9 @@ test -e \$NOTIFIED && [[ "\$( cat \$LATEST )" == "\$( cat \$NOTIFIED )" ]] && { echo "Found update from \$( cat \$VERFILE ) to \$( cat \$LATEST ). Sending notification..." -IFACE=\$( ip r | grep "default via" | awk '{ print \$5 }' | head -1 ) -IP=\$( ip a show dev "\$IFACE" | grep global | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 ) - notify_admin \ "NextCloudPi update" \ - "Update from \$( cat \$VERFILE ) to \$( cat \$LATEST ) is available. Update from https://\$IP:4443" + "Update from \$( cat \$VERFILE ) to \$( cat \$LATEST ) is available. Update from https://\$(get_ip):4443" cat \$LATEST > \$NOTIFIED EOF diff --git a/bin/nextcloud-domain.sh b/bin/nextcloud-domain.sh index 39556889..f15c7a39 100644 --- a/bin/nextcloud-domain.sh +++ b/bin/nextcloud-domain.sh @@ -4,13 +4,12 @@ source /usr/local/etc/library.sh # wicd service finishes before completing DHCP while :; do - iface="$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )" - ip="$( ip a show dev "$iface" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 )" + ip="$(get_ip)" + public_ip="$(curl -m4 icanhazip.com 2>/dev/null)" - public_ip="$(curl icanhazip.com 2>/dev/null)" [[ "$public_ip" != "" ]] && ncc config:system:set trusted_domains 11 --value="$public_ip" - [[ "$ip" != "" ]] && break + sleep 3 done diff --git a/changelog.md b/changelog.md index 50c33915..db575ae6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ -[v1.39.14](https://github.com/nextcloud/nextcloudpi/commit/077c3bc) (2021-09-25) nc-https:only fix infinite redirects behind proxy +[v1.39.15](https://github.com/nextcloud/nextcloudpi/commit/3e408f1) (2021-09-27) add get_ip function + +[v1.39.14](https://github.com/nextcloud/nextcloudpi/commit/6ad96ed) (2021-09-25) nc-https:only fix infinite redirects behind proxy [v1.39.13](https://github.com/nextcloud/nextcloudpi/commit/eef7b09) (2021-09-23) ncp-web: make letsencrypt detection more robust diff --git a/etc/library.sh b/etc/library.sh index 01677652..2e147645 100644 --- a/etc/library.sh +++ b/etc/library.sh @@ -382,6 +382,13 @@ function nc_version() ncc status | grep "version:" | awk '{ print $3 }' } +function get_ip() +{ + local iface + iface="$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )" + ip a show dev "$iface" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 +} + function is_an_ip() { local ip_or_domain="${1}" @@ -67,8 +67,7 @@ rm /.ncp-image cd - rm -rf "${TMPDIR}" -IFACE="$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )" -IP="$( ip a show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 )" +IP="$(get_ip)" echo "Done. |