From b0a3baf8bb645be8ecf99c8428605270d921bcc6 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 5 May 2018 21:53:34 +0200 Subject: [PATCH] Add dhcpcd configuration - Service file for dhcpcd master service - Service template file for interfaces - Service symlink for each configured interface - Get DHCP address on raspberry pi 3 for ethernet port Signed-off-by: David Oberhollenzer --- board/alix/INIT | 1 + board/rpi3/INIT | 1 + pkg/init/build | 11 ++++++++++- pkg/init/share/init/dhcpcd | 6 ++++++ pkg/init/share/init/dhcpcdmaster | 9 +++++++++ product/router/interfaces.rpi3/port0 | 1 - 6 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 pkg/init/share/init/dhcpcd create mode 100644 pkg/init/share/init/dhcpcdmaster delete mode 100644 product/router/interfaces.rpi3/port0 diff --git a/board/alix/INIT b/board/alix/INIT index 2b383fb..469d868 100644 --- a/board/alix/INIT +++ b/board/alix/INIT @@ -1,2 +1,3 @@ GETTY_TTY="ttyS0" HWCLOCK="yes" +DHCP_PORTS="" \ No newline at end of file diff --git a/board/rpi3/INIT b/board/rpi3/INIT index df1089c..1a528b1 100644 --- a/board/rpi3/INIT +++ b/board/rpi3/INIT @@ -1,2 +1,3 @@ GETTY_TTY="tty1 tty2 tty3 tty4 tty5 tty6 tty7" +DHCP_PORTS="port0" HWCLOCK="no" diff --git a/pkg/init/build b/pkg/init/build index c3ad82b..fcd87fc 100755 --- a/pkg/init/build +++ b/pkg/init/build @@ -57,5 +57,14 @@ deploy() { ln -s "/share/init/agetty" "$DEPLOY/etc/init.d/agetty@$svc" done - unset -v i GETTY_TTY HWCLOCK + if [ ! -z "$DHCP_PORTS" ]; then + ln -s "/share/init/dhcpcdmaster" \ + "$DEPLOY/etc/init.d/dhcpcdmaster" + fi + + for svc in $DHCP_PORTS; do + ln -s "/share/init/dhcpcd" "$DEPLOY/etc/init.d/dhcpcd@$svc" + done + + unset -v i GETTY_TTY HWCLOCK DHCP_PORTS } diff --git a/pkg/init/share/init/dhcpcd b/pkg/init/share/init/dhcpcd new file mode 100644 index 0000000..ad96c77 --- /dev/null +++ b/pkg/init/share/init/dhcpcd @@ -0,0 +1,6 @@ +description "DHCP client on %0" +type once +target boot +after dhcpcd + +exec dhcpcd -n %0 diff --git a/pkg/init/share/init/dhcpcdmaster b/pkg/init/share/init/dhcpcdmaster new file mode 100644 index 0000000..39481f4 --- /dev/null +++ b/pkg/init/share/init/dhcpcdmaster @@ -0,0 +1,9 @@ +description "DHCP client - master service" +type respawn limit 5 +target boot +after sysinit ifrename ifcfg + +exec { + mkdir -p /var/db/dhcpcd + dhcpcd -B --inactive +} diff --git a/product/router/interfaces.rpi3/port0 b/product/router/interfaces.rpi3/port0 deleted file mode 100644 index 09fba90..0000000 --- a/product/router/interfaces.rpi3/port0 +++ /dev/null @@ -1 +0,0 @@ -ip 192.168.0.1/24