diff options
-rw-r--r-- | changelog.md | 8 | ||||
-rw-r--r-- | etc/ncp-config.d/nc-static-IP.sh | 73 |
2 files changed, 65 insertions, 16 deletions
diff --git a/changelog.md b/changelog.md index 20e14321..bd8b0f85 100644 --- a/changelog.md +++ b/changelog.md @@ -1,9 +1,11 @@ -[v0.54.6](https://github.com/nextcloud/nextcloudpi/commit/1588d46) (2018-05-10) nc-notify-updates: fix wrong default user +[v0.54.7](https://github.com/nextcloud/nextcloudpi/commit/890f0c6) (2018-05-10) armbian: fix static IP -[v0.54.5](https://github.com/nextcloud/nextcloudpi/commit/ee05dbc) (2018-05-10) armbian: fix mDNS +[v0.54.6](https://github.com/nextcloud/nextcloudpi/commit/008f065) (2018-05-10) nc-notify-updates: fix wrong user -[v0.54.4](https://github.com/nextcloud/nextcloudpi/commit/36f4c6f) (2018-05-09) avoid temp dir vulnerabilities +[v0.54.5 ](https://github.com/nextcloud/nextcloudpi/commit/ee05dbc) (2018-05-10) armbian: fix mDNS + +[v0.54.4 ](https://github.com/nextcloud/nextcloudpi/commit/36f4c6f) (2018-05-09) avoid temp dir vulnerabilities [v0.54.3 ](https://github.com/nextcloud/nextcloudpi/commit/66dfbd0) (2018-05-03) nc-datadir: avoid using occ for faster execution diff --git a/etc/ncp-config.d/nc-static-IP.sh b/etc/ncp-config.d/nc-static-IP.sh index 73a2cc11..6da04f0d 100644 --- a/etc/ncp-config.d/nc-static-IP.sh +++ b/etc/ncp-config.d/nc-static-IP.sh @@ -20,31 +20,78 @@ DESCRIPTION="Set up a static IP address (on), or DHCP (off)" configure() { - # delete NCP config - grep -q "^# NextCloudPlus autogenerated" /etc/dhcpcd.conf && \ - sed -i '/^# NextCloudPlus autogenerated/,+6d' /etc/dhcpcd.conf - - [[ $ACTIVE_ != "yes" ]] && { - systemctl restart dhcpcd - echo "DHCP enabled" - return - } - local GW="$( ip r | grep "default via" | awk '{ print $3 }' )" local DNS="$( grep nameserver /etc/resolv.conf | head -1 | awk '{ print $2 }' )" - [[ "$DNS" == "" ]] && DNS="$GW" - cat >> /etc/dhcpcd.conf <<EOF + ## DHCPCD + [[ -f /etc/dhcpcd.conf ]] && { + # delete NCP config + grep -q "^# NextCloudPlus autogenerated" /etc/dhcpcd.conf && \ + sed -i '/^# NextCloudPlus autogenerated/,+6d' /etc/dhcpcd.conf + + [[ $ACTIVE_ != "yes" ]] && { + systemctl restart dhcpcd + echo "DHCP enabled" + return + } + + cat >> /etc/dhcpcd.conf <<EOF # NextCloudPlus autogenerated # don't modify! better use ncp-config interface eth0 static ip_address=$IP_/24 static routers=$GW static domain_name_servers=$DNS + +# Local loopback +auto lo +iface lo inet loopback +EOF + + systemctl restart dhcpcd + } || { + ## NETWORK MANAGER + + cp -n /etc/network/interfaces /etc/network/interfaces-ncp-backup-orig + + [[ $ACTIVE_ != "yes" ]] && { + cat > /etc/network/interfaces <<EOF +# Wired adapter #1 +allow-hotplug eth0 +no-auto-down eth0 +auto eth0 +iface eth0 inet dhcp + +# Local loopback +auto lo +iface lo inet loopback EOF + systemctl restart NetworkManager + echo "DHCP enabled" + return + } - systemctl restart dhcpcd + cat > /etc/network/interfaces <<EOF +# ncp-config generated +source /etc/network/interfaces.d/* + +# Local loopback +auto lo +iface lo inet loopback + +# Interface eth0 +auto eth0 +allow-hotplug eth0 +iface eth0 inet static + address $IP_ + netmask 255.255.255.0 + gateway $GW + dns-nameservers $DNS 8.8.8.8 +EOF + systemctl restart networking + } + sudo -u www-data php /var/www/nextcloud/occ config:system:set trusted_domains 1 --value="$IP_" sudo -u www-data php /var/www/nextcloud/occ config:system:set overwrite.cli.url --value=https://"$IP_" echo "Static IP set to $IP_" |