aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md28
-rwxr-xr-xrpi2-gen-image.sh37
2 files changed, 62 insertions, 3 deletions
diff --git a/README.md b/README.md
index d118955..912c7ce 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,6 @@ Set system `root` password. The same password is used for the created user `pi`.
##### `DEFLOCAL`="en_US.UTF-8"
Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. The script variant `minbase` (ENABLE_MINBASE=true) doesn't install `locales`.
-
##### `TIMEZONE`="Europe/Berlin"
Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command.
@@ -51,6 +50,33 @@ These options are used to configure keyboard layout in `/etc/default/keyboard` f
##### `XKBVARIANT`=""
##### `XKBOPTIONS`=""
+#### Networking settings
+These settings are used to set up networking configuration in `/etc/systemd/network/eth.network`.
+
+#####`ENABLE_DHCP`=true
+Set the system to use DHCP. When set to "true", the following `NET_*` settings (used for static configuration) are ignored.
+
+#####`NET_ADDRESS`=""
+Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
+
+#####`NET_GATEWAY`=""
+Set the IP address for the default gateway.
+
+#####`NET_DNS_1`=""
+Set the IP address for the first DNS server.
+
+#####`NET_DNS_2`=""
+Set the IP address for the second DNS server.
+
+#####`NET_DNS_DOMAINS`=""
+Set the default DNS search domains to use for non fully qualified host names.
+
+#####`NET_NTP_1`=""
+Set the IP address for the first NTP server.
+
+#####`NET_NTP_2`=""
+Set the IP address for the second NTP server.
+
#### Basic system features:
##### `ENABLE_CONSOLE`=true
Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system.
diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh
index a0f7313..6759f76 100755
--- a/rpi2-gen-image.sh
+++ b/rpi2-gen-image.sh
@@ -50,6 +50,18 @@ XKBLAYOUT=${XKBLAYOUT:=""}
XKBVARIANT=${XKBVARIANT:=""}
XKBOPTIONS=${XKBOPTIONS:=""}
+# Network settings
+ENABLE_DHCP=${ENABLE_DHCP:=true}
+# NET_* settings are ignored when ENABLE_DHCP=true
+# NET_ADDRESS is an IPv4 or IPv6 address and its prefix, separated by "/"
+NET_ADDRESS=${NET_ADDRESS:=""}
+NET_GATEWAY=${NET_GATEWAY:=""}
+NET_DNS_1=${NET_DNS_1:=""}
+NET_DNS_2=${NET_DNS_2:=""}
+NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
+NET_NTP_1=${NET_NTP_1:=""}
+NET_NTP_2=${NET_NTP_2:=""}
+
# APT settings
APT_PROXY=${APT_PROXY:=""}
APT_SERVER=${APT_SERVER:="ftp.debian.org"}
@@ -204,7 +216,7 @@ mount --bind /dev/pts $R/dev/pts
# Use proxy inside chroot
if [ -z "$APT_PROXY" ] ; then
- echo "Acquire::http::Proxy \"$APT_PROXY\"" >> $R/etc/apt/apt.conf.d/10proxy
+ echo "Acquire::http::Proxy \"$APT_PROXY\";" >> $R/etc/apt/apt.conf.d/10proxy
fi
# Pin package flash-kernel to repositories.collabora.co.uk
@@ -309,6 +321,10 @@ cat <<EOM >$R/etc/hosts
127.0.0.1 localhost
127.0.1.1 ${HOSTNAME}
EOM
+if [ "$NET_ADDRESS" != "" ] ; then
+NET_IP=$(echo ${NET_ADDRESS} | cut -f 1 -d'/')
+sed -i "s/^127.0.1.1/${NET_IP}/" $R/etc/hosts
+fi
# Set up IPv6 hosts
if [ "$ENABLE_IPV6" = true ] ; then
@@ -326,6 +342,7 @@ cat <<EOM >$R/etc/network/interfaces
# please configure your networks in '/etc/systemd/network/'
EOM
+if [ "$ENABLE_DHCP" = true ] ; then
# Enable systemd-networkd DHCP configuration for interface eth0
cat <<EOM >$R/etc/systemd/network/eth.network
[Match]
@@ -337,7 +354,23 @@ EOM
# Set DHCP configuration to IPv4 only
if [ "$ENABLE_IPV6" = false ] ; then
- sed -i "s/=yes/=v4/" $R/etc/systemd/network/eth.network
+ sed -i "s/^DHCP=yes/DHCP=v4/" $R/etc/systemd/network/eth.network
+fi
+else # ENABLE_DHCP=false
+cat <<EOM >$R/etc/systemd/network/eth.network
+[Match]
+Name=eth0
+
+[Network]
+DHCP=no
+Address=${NET_ADDRESS}
+Gateway=${NET_GATEWAY}
+DNS=${NET_DNS_1}
+DNS=${NET_DNS_2}
+Domains=${NET_DNS_DOMAINS}
+NTP=${NET_NTP_1}
+NTP=${NET_NTP_2}
+EOM
fi
# Enable systemd-networkd service