From cfffb38508fc85a1d2d3cd452a2086c2d9278373 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sun, 31 Aug 2014 08:09:13 -0400 Subject: [PATCH 1/4] link-local IPv6 addresses need a '%interface' specification to be useful --- setup/functions.sh | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/setup/functions.sh b/setup/functions.sh index 78e67eda..23c2492b 100644 --- a/setup/functions.sh +++ b/setup/functions.sh @@ -85,6 +85,9 @@ function get_default_privateip { # Return the IP address of the network interface connected # to the Internet. # + # Pass '4' or '6' as an argument to this function to specify + # what type of address to get (IPv4, IPv6). + # # We used to use `hostname -I` and then filter for either # IPv4 or IPv6 addresses. However if there are multiple # network interfaces on the machine, not all may be for @@ -99,11 +102,16 @@ function get_default_privateip { # assigned to an interface. `ip route get` reports the # preferred. That's good enough for us. See issue #121. # + # With IPv6, the best route may be via an interface that + # only has a link-local address (fe80::*). These addresses + # are only unique to an interface and so need an explicit + # interface specification in order to use them with bind(). + # In these cases, we append "%interface" to the address. + # See the Notes section in the man page for getaddrinfo and + # https://discourse.mailinabox.email/t/update-broke-mailinabox/34/9. + # # Also see ae67409603c49b7fa73c227449264ddd10aae6a9 and # issue #3 for why/how we originally added IPv6. - # - # Pass '4' or '6' as an argument to this function to specify - # what type of address to get (IPv4, IPv6). target=8.8.8.8 @@ -112,9 +120,21 @@ function get_default_privateip { # as it's an address on the public Internet. if [ "$1" == "6" ]; then target=2001:4860:4860::8888; fi - ip -$1 -o route get $target \ - | grep -v unreachable \ - | sed "s/.* src \([^ ]*\).*/\1/" + # Get the route information. + route=$(ip -$1 -o route get $target | grep -v unreachable) + + # Parse the address out of the route information. + address=$(echo $route | sed "s/.* src \([^ ]*\).*/\1/") + + if [[ "$1" == "6" && $address == fe80:* ]]; then + # For IPv6 link-local addresses, parse the interface out + # of the route information and append it with a '%'. + interface=$(echo $route | sed "s/.* dev \([^ ]*\).*/\1/") + address=$address%$interface + fi + + echo $address + } function ufw_allow { From ee244386ed629b6c529097724f7b66d39b2710e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Sun, 31 Aug 2014 20:34:57 +0200 Subject: [PATCH 2/4] update ownCloud if necessary this will always download the latest ownCloud and upgrade if ownCloud install dir exist, this apphroach allows us to keep existing user plugins. currently not checking if currently installed version is equal to the one we're downloading as I couldn't find a proper solution for that --- setup/owncloud.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index 1c7aa451..ad71c137 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -12,16 +12,22 @@ apt_install \ apt-get purge -qq -y owncloud* -# Install ownCloud from source if it is not already present -# TODO: Check version? +# Install ownCloud from source +echo installing ownCloud... +rm -f /tmp/owncloud.zip +wget -qO /tmp/owncloud.zip https://download.owncloud.org/community/owncloud-latest.zip + if [ ! -d /usr/local/lib/owncloud ]; then - echo installing ownCloud... - rm -f /tmp/owncloud.zip - wget -qO /tmp/owncloud.zip https://download.owncloud.org/community/owncloud-7.0.1.zip + # fresh install unzip -q /tmp/owncloud.zip -d /usr/local/lib - rm -f /tmp/owncloud.zip +else + # upgrade existing install + unzip -u -o -q /tmp/owncloud.zip -d /usr/local/lib + hide_output php /usr/local/lib/owncloud/occ upgrade fi +rm -f /tmp/owncloud.zip + # Setup ownCloud if the ownCloud database does not yet exist. Running setup when # the database does exist wipes the database and user data. if [ ! -f $STORAGE_ROOT/owncloud/owncloud.db ]; then From 8b2fed1a2a21ae9edfe423eaf55145341ca3cf97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Mon, 1 Sep 2014 10:02:46 +0200 Subject: [PATCH 3/4] fixes comments by @JoshData --- setup/owncloud.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index ad71c137..eecaf438 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -13,21 +13,20 @@ apt_install \ apt-get purge -qq -y owncloud* # Install ownCloud from source -echo installing ownCloud... -rm -f /tmp/owncloud.zip -wget -qO /tmp/owncloud.zip https://download.owncloud.org/community/owncloud-latest.zip +# Check if ownCloud dir exist, and check if version matches 7.0.1 (if it does, upgrade) +owncloud_ver=7.0.2 -if [ ! -d /usr/local/lib/owncloud ]; then - # fresh install - unzip -q /tmp/owncloud.zip -d /usr/local/lib -else - # upgrade existing install - unzip -u -o -q /tmp/owncloud.zip -d /usr/local/lib - hide_output php /usr/local/lib/owncloud/occ upgrade +if [ ! -d /usr/local/lib/owncloud/ ] \ + || ! grep -q $owncloud_ver /usr/local/lib/owncloud/version.php; then + + echo installing ownCloud... + rm -f /tmp/owncloud.zip + wget -qO /tmp/owncloud.zip https://download.owncloud.org/community/owncloud-$owncloud_ver.zip + unzip -u -o -q /tmp/owncloud.zip -d /usr/local/lib #either extracts new or replaces current files + hide_output php /usr/local/lib/owncloud/occ upgrade #if OC is up-to-date it wont matter + rm -f /tmp/owncloud.zip fi -rm -f /tmp/owncloud.zip - # Setup ownCloud if the ownCloud database does not yet exist. Running setup when # the database does exist wipes the database and user data. if [ ! -f $STORAGE_ROOT/owncloud/owncloud.db ]; then From 7603ce0489aa9cfb951c9b4cf246b3b1abcaa0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20K=C3=A5berg?= Date: Mon, 1 Sep 2014 10:32:44 +0200 Subject: [PATCH 4/4] this is what I meant --- setup/owncloud.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index eecaf438..65903220 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -13,9 +13,9 @@ apt_install \ apt-get purge -qq -y owncloud* # Install ownCloud from source -# Check if ownCloud dir exist, and check if version matches 7.0.1 (if it does, upgrade) owncloud_ver=7.0.2 +# Check if ownCloud dir exist, and check if version matches owncloud_ver (if either doesn't - install/upgrade) if [ ! -d /usr/local/lib/owncloud/ ] \ || ! grep -q $owncloud_ver /usr/local/lib/owncloud/version.php; then