Skip to content

Commit

Permalink
armbian: fix static IP
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed May 10, 2018
1 parent 09741e1 commit 5dca250
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 16 deletions.
8 changes: 5 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
73 changes: 60 additions & 13 deletions etc/ncp-config.d/nc-static-IP.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_"
Expand Down

0 comments on commit 5dca250

Please sign in to comment.