From bd11747ed1f1429a2992ca5ee613594edfc0703a Mon Sep 17 00:00:00 2001 From: Benjamin Schilling Date: Fri, 15 Jan 2021 23:59:17 +0100 Subject: [PATCH] Add netctl recipe --- recipes-houseos/netctl/files/netctl.service | 14 +++++++ recipes-houseos/netctl/files/netctl.sh | 46 +++++++++++++++++++++ recipes-houseos/netctl/files/postinst | 3 ++ recipes-houseos/netctl/netctl_0.1.bb | 14 +++++++ 4 files changed, 77 insertions(+) create mode 100644 recipes-houseos/netctl/files/netctl.service create mode 100644 recipes-houseos/netctl/files/netctl.sh create mode 100644 recipes-houseos/netctl/files/postinst create mode 100644 recipes-houseos/netctl/netctl_0.1.bb diff --git a/recipes-houseos/netctl/files/netctl.service b/recipes-houseos/netctl/files/netctl.service new file mode 100644 index 0000000..f64e2d1 --- /dev/null +++ b/recipes-houseos/netctl/files/netctl.service @@ -0,0 +1,14 @@ +# +# +# SPDX-License-Identifier: MIT +# Copyright (c) 2021 Benjamin Schilling + +[Unit] +Description=netctl service + +[Service] +Type=simple +ExecStart=/bin/bash /opt/netctl/netctl.sh + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/recipes-houseos/netctl/files/netctl.sh b/recipes-houseos/netctl/files/netctl.sh new file mode 100644 index 0000000..c8dd842 --- /dev/null +++ b/recipes-houseos/netctl/files/netctl.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# bash script for network interface configuration +# SPDX-License-Identifier: MIT +# Copyright (c) 2021 Benjamin Schilling + +# ==== configure enp2s0 ==== + +# read IP address +enp2s0_ip=$(kvsc get --key enp2s0-ip) +# read subnet mask +enp2s0_mask=$(kvsc get --key enp2s0-mask) +# read default gw +enp2s0_gw=$(kvsc get --key enp2s0-gw) +# read DNS +enp2s0_dns=$(kvsc get --key enp2s0-dns) + +# set system network unit +echo "[Match]" > /etc/systemd/network/enp2s0.network +echo "Name=enp2s0" >> /etc/systemd/network/enp2s0.network +echo "\n" >> /etc/systemd/network/enp2s0.network +echo "[Network]" >> /etc/systemd/network/enp2s0.network +echo "DNS=$enp2s0_dns" >> /etc/systemd/network/enp2s0.network +echo "Address=$enp2s0_ip/$enp2s0_mask" >> /etc/systemd/network/enp2s0.network +echo "Gateway=$enp2s0_gw" >> /etc/systemd/network/enp2s0.network + +# ==== configure enp3s0 ==== + +# read IP address +enp3s0_ip=$(kvsc get --key enp3s0-ip) +# read subnet mask +enp3s0_subnet=$(kvsc get --key enp3s0-subnet) +# read default gw +enp3s0_gw=$(kvsc get --key enp3s0-gw) +# read DNS +enp3s0_dns=$(kvsc get --key enp3s0-dns) + +# set system network unit +echo "[Match]" > /etc/systemd/network/enp3s0.network +echo "Name=enp3s0" >> /etc/systemd/network/enp3s0.network +echo "\n" >> /etc/systemd/network/enp3s0.network +echo "[Network]" >> /etc/systemd/network/enp3s0.network +echo "DNS=$enp3s0_dns" >> /etc/systemd/network/enp3s0.network +echo "Address=$enp3s0_ip/$enp3s0_mask" >> /etc/systemd/network/enp3s0.network +echo "Gateway=$enp3s0_gw" >> /etc/systemd/network/enp3s0.network + +systemctl restart systemd-networkd \ No newline at end of file diff --git a/recipes-houseos/netctl/files/postinst b/recipes-houseos/netctl/files/postinst new file mode 100644 index 0000000..25bf384 --- /dev/null +++ b/recipes-houseos/netctl/files/postinst @@ -0,0 +1,3 @@ +#!/bin/bash +# enable systemd service unit +systemctl enable /usr/lib/systemd/system/netctl.service \ No newline at end of file diff --git a/recipes-houseos/netctl/netctl_0.1.bb b/recipes-houseos/netctl/netctl_0.1.bb new file mode 100644 index 0000000..fd54699 --- /dev/null +++ b/recipes-houseos/netctl/netctl_0.1.bb @@ -0,0 +1,14 @@ +# ISAR Recipe for the netctl script +# SPDX-License-Identifier: MIT +# Copyright (c) 2021 Benjamin Schilling + +inherit dpkg-raw + +SRC_URI = "file://netctl.sh \ + file://netctl.service" + +do_install() { + install -v -d ${D}/usr/lib/systemd/system/ + install -v -m 644 ${WORKDIR}/netctl.service ${D}/usr/lib/systemd/system/netctl.service + install -v -m 644 ${WORKDIR}/netctl.sh ${D}/opt/netctl/netctl.sh +} \ No newline at end of file