Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add netctl recipe #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions recipes-houseos/netctl/files/netctl.service
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions recipes-houseos/netctl/files/netctl.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions recipes-houseos/netctl/files/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
# enable systemd service unit
systemctl enable /usr/lib/systemd/system/netctl.service
14 changes: 14 additions & 0 deletions recipes-houseos/netctl/netctl_0.1.bb
Original file line number Diff line number Diff line change
@@ -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
}