File tree Expand file tree Collapse file tree 8 files changed +27
-21
lines changed
Expand file tree Collapse file tree 8 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 1111# More at https://ownyourbits.com
1212#
1313
14+ source /usr/local/etc/library.sh
15+
1416# Distro, NCP version and tag
1517echo " NextCloudPi version|$( cat /usr/local/etc/ncp-version ) "
1618[[ -f /usr/local/etc/ncp-baseimage ]] && echo " NextCloudPi image|$( cat /usr/local/etc/ncp-baseimage ) "
@@ -67,7 +69,7 @@ function is_port_open()
6769{
6870 local port=$1
6971 local public_ip
70- public_ip=" $( curl -4 https://icanhazip.com 2> /dev/null) " || { echo " closed" ; return 1; }
72+ public_ip=" $( curl -m4 - 4 https://icanhazip.com 2> /dev/null) " || { echo " closed" ; return 1; }
7173 local tmp_file=$( mktemp)
7274 local token=$( wget -T2 -t1 -qO- --keep-session-cookies --save-cookies $tmp_file https://portchecker.co | grep -oP " _csrf\" value=\" \K.*\" " )
7375
@@ -85,7 +87,7 @@ echo "port check 443|$( is_port_open 443 )"
8587# LAN
8688IFACE=$( ip r | grep " default via" | awk ' { print $5 }' | head -1 )
8789GW=$( ip r | grep " default via" | awk ' { print $3 }' | head -1 )
88- IP=$( ip a show dev " $IFACE " | grep global | grep -oP ' \d{1,3}(.\d{1,3}){3} ' | head -1 )
90+ IP=" $( get_ip ) "
8991
9092echo " IP|$IP "
9193echo " gateway|$GW "
Original file line number Diff line number Diff line change @@ -48,9 +48,10 @@ configure()
4848 return
4949 }
5050
51- local IFACE=$( ip r | grep " default via" | awk ' { print $5 }' | head -1 )
52- local IP=$( ncc config:system:get trusted_domains " ${TRUSTED_DOMAINS[docker_overwrite]} " | grep -oP ' \d{1,3}(.\d{1,3}){3}' )
53- [[ " $IP " == " " ]] && IP=$( ip a show dev " $IFACE " | grep global | grep -oP ' \d{1,3}(.\d{1,3}){3}' | head -1 )
51+ local IFACE IP
52+ IFACE=$( ip r | grep " default via" | awk ' { print $5 }' | head -1 )
53+ IP=$( ncc config:system:get trusted_domains " ${TRUSTED_DOMAINS[docker_overwrite]} " | grep -oP ' \d{1,3}(.\d{1,3}){3}' )
54+ [[ " $IP " == " " ]] && IP=" $( get_ip) "
5455
5556 [[ " $IP " == " " ]] && { echo " could not detect IP" ; return 1; }
5657
Original file line number Diff line number Diff line change @@ -17,13 +17,13 @@ install()
1717
1818configure ()
1919{
20- local IFACE= $( ip r | grep " default via " | awk ' { print $5 } ' | head -1 )
21- local IP= $( ip a show dev " $IFACE " | grep global | grep -oP ' \d{1,3}(.\d{1,3}){3} ' | head -1 )
20+ local ip
21+ ip= " $( get_ip ) "
2222 upnpc -d " $HTTPSPORT " TCP
2323 upnpc -d " $HTTPPORT " TCP
24- upnpc -a " $IP " 443 " $HTTPSPORT " TCP | tee >( cat - >&2 ) | grep -q " is redirected to internal" || \
24+ upnpc -a " $ip " 443 " $HTTPSPORT " TCP | tee >( cat - >&2 ) | grep -q " is redirected to internal" || \
2525 { echo -e " \nCould not forward ports automatically.\nDo it manually, or activate UPnP in your router and try again" ; return 1; }
26- upnpc -a " $IP " 80 " $HTTPPORT " TCP | tee >( cat - >&2 ) | grep -q " is redirected to internal" || \
26+ upnpc -a " $ip " 80 " $HTTPPORT " TCP | tee >( cat - >&2 ) | grep -q " is redirected to internal" || \
2727 { echo -e " \nCould not forward ports automatically.\nDo it manually, or activate UPnP in your router and try again" ; return 1; }
2828}
2929
Original file line number Diff line number Diff line change 1212
1313# check every hour
1414CHECKINTERVAL=1
15- NCDIR=/var/www/nextcloud
1615
1716configure ()
1817{
@@ -41,12 +40,9 @@ test -e \$NOTIFIED && [[ "\$( cat \$LATEST )" == "\$( cat \$NOTIFIED )" ]] && {
4140
4241echo "Found update from \$ ( cat \$ VERFILE ) to \$ ( cat \$ LATEST ). Sending notification..."
4342
44- IFACE=\$ ( ip r | grep "default via" | awk '{ print \$ 5 }' | head -1 )
45- IP=\$ ( ip a show dev "\$ IFACE" | grep global | grep -oP '\d{1,3}(\.\d{1,3}){3}' | head -1 )
46-
4743notify_admin \
4844 "NextCloudPi update" \
49- "Update from \$ ( cat \$ VERFILE ) to \$ ( cat \$ LATEST ) is available. Update from https://\$ IP :4443"
45+ "Update from \$ ( cat \$ VERFILE ) to \$ ( cat \$ LATEST ) is available. Update from https://\$ (get_ip) :4443"
5046
5147cat \$ LATEST > \$ NOTIFIED
5248EOF
Original file line number Diff line number Diff line change @@ -4,13 +4,12 @@ source /usr/local/etc/library.sh
44
55# wicd service finishes before completing DHCP
66while : ; do
7- iface =" $( ip r | grep " default via " | awk ' { print $5 } ' | head -1 ) "
8- ip =" $( ip a show dev " $iface " | grep global | grep -oP ' \d{1,3}(.\d{1,3}){3} ' | head -1 ) "
7+ ip =" $( get_ip ) "
8+ public_ip =" $( curl -m4 icanhazip.com 2> /dev/null ) "
99
10- public_ip=" $( curl icanhazip.com 2> /dev/null) "
1110 [[ " $public_ip " != " " ]] && ncc config:system:set trusted_domains 11 --value=" $public_ip "
12-
1311 [[ " $ip " != " " ]] && break
12+
1413 sleep 3
1514done
1615
Original file line number Diff line number Diff line change 11
2- [ v1.39.14] ( https://github.com/nextcloud/nextcloudpi/commit/077c3bc ) (2021-09-25) nc-https: only fix infinite redirects behind proxy
2+ [ v1.39.15] ( https://github.com/nextcloud/nextcloudpi/commit/3e408f1 ) (2021-09-27) add get_ip function
3+
4+ [ v1.39.14] ( https://github.com/nextcloud/nextcloudpi/commit/6ad96ed ) (2021-09-25) nc-https: only fix infinite redirects behind proxy
35
46[ v1.39.13] ( https://github.com/nextcloud/nextcloudpi/commit/eef7b09 ) (2021-09-23) ncp-web: make letsencrypt detection more robust
57
Original file line number Diff line number Diff line change @@ -382,6 +382,13 @@ function nc_version()
382382 ncc status | grep " version:" | awk ' { print $3 }'
383383}
384384
385+ function get_ip()
386+ {
387+ local iface
388+ iface=" $( ip r | grep " default via" | awk ' { print $5 }' | head -1 ) "
389+ ip a show dev " $iface " | grep global | grep -oP ' \d{1,3}(.\d{1,3}){3}' | head -1
390+ }
391+
385392function is_an_ip()
386393{
387394 local ip_or_domain=" ${1} "
Original file line number Diff line number Diff line change @@ -67,8 +67,7 @@ rm /.ncp-image
6767cd -
6868rm -rf " ${TMPDIR} "
6969
70- IFACE=" $( ip r | grep " default via" | awk ' { print $5 }' | head -1 ) "
71- IP=" $( ip a show dev " $IFACE " | grep global | grep -oP ' \d{1,3}(.\d{1,3}){3}' | head -1 ) "
70+ IP=" $( get_ip) "
7271
7372echo " Done.
7473
You can’t perform that action at this time.
0 commit comments