diff options
author | nachoparker <nacho@ownyourbits.com> | 2018-05-10 14:44:49 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2018-05-10 14:55:27 +0300 |
commit | 5dca2501778c34aff9247bfe5fe1e207db0e9bad (patch) | |
tree | f03fabb39a88c84def88aa3a6c95568e38c57402 /etc/ncp-config.d/nc-static-IP.sh | |
parent | 09741e10094ad7cca9cc82b2446ec2d2d344ab64 (diff) |
armbian: fix static IPv0.54.7
Diffstat (limited to 'etc/ncp-config.d/nc-static-IP.sh')
-rw-r--r-- | etc/ncp-config.d/nc-static-IP.sh | 73 |
1 files changed, 60 insertions, 13 deletions
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_" |