mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
Simplify and refine NETCONF and Classic build variants
- board/common: drop everything not needed by NETCONF mode - board/classic: most board/common helpers relocated here - Simplify Finit scripts for critical services - Source variant from /etc/os-release to select ramdisk /etc Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
committed by
Tobias Waldekranz
parent
5d7e6bd693
commit
8158d3bffb
@@ -1,3 +1,31 @@
|
||||
# For /etc/os-release, uses CondtionArchitechture= from systemd.unit(5)
|
||||
config INFIX_ARCH
|
||||
string
|
||||
default "arm" if BR2_arm
|
||||
default "arm64" if BR2_aarch64
|
||||
default "mips64" if BR2_mips64
|
||||
default "riscv64" if BR2_riscv
|
||||
default "x86_64" if BR2_x86_64
|
||||
|
||||
# For /etc/os-release, VARIANT & VARIANT_ID used, e.g., in mnt script
|
||||
choice
|
||||
prompt "Select variant/flavor"
|
||||
default INFIX_VARIANT_NETCONF
|
||||
|
||||
config INFIX_VARIANT_NETCONF
|
||||
bool "NETCONF"
|
||||
help
|
||||
Managed NETCONF mode, /etc is a ramdisk, all configuration is
|
||||
generated by sysrepo plugins using NETCONF (xml) or RESTCONF.
|
||||
|
||||
config INFIX_VARIANT_CLASSIC
|
||||
bool "Classic /etc mode"
|
||||
help
|
||||
User managed mode, read-write configuration files in /etc that
|
||||
is saved across reboots.
|
||||
|
||||
endchoice
|
||||
|
||||
menu "Packages"
|
||||
|
||||
source "$BR2_EXTERNAL_INFIX_PATH/package/Config.in"
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
dialog --msgbox "This build is hardwired to classic /etc mode." 6 48
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
pdmenu
|
||||
clear
|
||||
@@ -215,7 +215,7 @@ system()
|
||||
{
|
||||
h1 "SYSTEM INFORMATION"
|
||||
echo "System Name : $(uname -n)"
|
||||
echo "System Boot Mode : $(cat /tmp/.boot_mode)"
|
||||
echo "System Variant : $VARIANT"
|
||||
echo "System Description : $PRETTY_NAME"
|
||||
echo "System Contact : $HOME_URL"
|
||||
echo "System Timezone : $(cat /etc/timezone)"
|
||||
@@ -0,0 +1 @@
|
||||
run [S] /lib/infix/swup --
|
||||
@@ -60,8 +60,7 @@ menu:system:System:System Settings
|
||||
exec:_Enable service:edit:initctl enable ~Enter name of service (filename) to enable:~
|
||||
exec:_Disable service:edit:initctl disable ~Enter name of service (filename) to disable:~
|
||||
nop
|
||||
exec:_Change Operating Mode::chom
|
||||
exec:_Factory Reset::yorn "Reboot and factory reset device, are you sure?" factory -y
|
||||
exec:_Factory Reset::yorn "Factory reset device (reboots), are you sure?" factory -y
|
||||
nop
|
||||
exit:_Main menu..
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
#!/bin/sh
|
||||
# Only runs in classic /etc nodes.
|
||||
|
||||
if initctl cond get boot/profinet; then
|
||||
initctl enable snmpd
|
||||
initctl disable lldpd
|
||||
fi
|
||||
|
||||
# Factory default: all switch ports in VLAN 1 of br0
|
||||
# need to check for 'length > 0' because ip command
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
exit 0
|
||||
@@ -18,15 +18,6 @@ config SIGN_KEY
|
||||
|
||||
comment "Additional Artifacts"
|
||||
|
||||
# For /etc/os-release, uses CondtionArchitechture= from systemd.unit(5)
|
||||
config INFIX_ARCH
|
||||
string
|
||||
default "arm" if BR2_arm
|
||||
default "arm64" if BR2_aarch64
|
||||
default "mips64" if BR2_mips64
|
||||
default "riscv64" if BR2_riscv
|
||||
default "x86_64" if BR2_x86_64
|
||||
|
||||
menuconfig DISK_IMAGE
|
||||
bool "Disk image"
|
||||
help
|
||||
|
||||
@@ -11,17 +11,25 @@ GIT_VERSION=$(git -C $BR2_EXTERNAL_INFIX_PATH describe --always --dirty --tags)
|
||||
# original Buildroot information.
|
||||
rm "$TARGET_DIR/etc/os-release"
|
||||
{
|
||||
echo "NAME=\"Infix\""
|
||||
echo "VERSION=${GIT_VERSION}"
|
||||
echo "ID=infix"
|
||||
echo "ID_LIKE=\"${ID}\""
|
||||
echo "VERSION_ID=${GIT_VERSION}"
|
||||
echo "BUILD_ID=\"${NAME} ${VERSION}\""
|
||||
echo "PRETTY_NAME=\"Infix by KernelKit\""
|
||||
echo "ARCHITECTURE=\"${INFIX_ARCH}\""
|
||||
echo "HOME_URL=https://github.com/KernelKit"
|
||||
echo "NAME=\"Infix\""
|
||||
echo "VERSION=${GIT_VERSION}"
|
||||
echo "ID=infix"
|
||||
echo "ID_LIKE=\"${ID}\""
|
||||
echo "VERSION_ID=${GIT_VERSION}"
|
||||
echo "BUILD_ID=\"${NAME} ${VERSION}\""
|
||||
echo "PRETTY_NAME=\"Infix by KernelKit\""
|
||||
if [ "$INFIX_VARIANT_NETCONF" = "y" ]; then
|
||||
echo "VARIANT=\"Managed NETCONF\""
|
||||
echo "VARIANT_ID=netconf"
|
||||
else
|
||||
echo "VARIANT=\"Classic, writable /etc\""
|
||||
echo "VARIANT_ID=classic"
|
||||
fi
|
||||
echo "ARCHITECTURE=\"${INFIX_ARCH}\""
|
||||
echo "HOME_URL=https://github.com/KernelKit"
|
||||
} > "$TARGET_DIR/etc/os-release"
|
||||
|
||||
|
||||
echo "Infix by KernelKit $GIT_VERSION -- $(date +"%b %e %H:%M %Z %Y")" > "$TARGET_DIR/etc/version"
|
||||
|
||||
# Allow pdmenu (setup) to be a login shell
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
#!/bin/sh
|
||||
#set -x
|
||||
|
||||
mode=/mnt/cfg/infix/.use_etc
|
||||
boot=/tmp/.boot_mode
|
||||
if [ -f $boot ]; then
|
||||
current=$(cat $boot)
|
||||
else
|
||||
current="unknown"
|
||||
fi
|
||||
m=on
|
||||
n=off
|
||||
p=off
|
||||
|
||||
select_mode()
|
||||
{
|
||||
if [ -f $mode ]; then
|
||||
m=off
|
||||
if grep -qi profinet $boot; then
|
||||
n=off
|
||||
p=on
|
||||
else
|
||||
n=on
|
||||
p=off
|
||||
fi
|
||||
fi
|
||||
|
||||
exec 3>&1
|
||||
selection=$(dialog --erase-on-exit --no-tags \
|
||||
--hline "Arrow keys + space to select, enter to confirm" \
|
||||
--backtitle "Select Operating Mode" \
|
||||
--title "Select Operating Mode" \
|
||||
--radiolist "System currently runs in: $current mode" 13 60 1 \
|
||||
"1" "Managed NETCONF, XML datastore" "$m" \
|
||||
"2" "Classic Linux, /etc datastore" "$n" \
|
||||
"3" "PROFINET, /etc variant" "$p" \
|
||||
2>&1 1>&3)
|
||||
exit_status=$?
|
||||
exec 3>&-
|
||||
case $exit_status in
|
||||
1) # cancel
|
||||
exit 0
|
||||
;;
|
||||
255) # escape
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
usage:
|
||||
chom [-h] [etc | netconf]
|
||||
|
||||
options:
|
||||
-h Show this help text
|
||||
|
||||
arguments:
|
||||
etc Change to Linux classic mode, /etc
|
||||
netconf Change to NETCONF mode, XML
|
||||
profinet Change to PROFINET mode, /etc variant
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
case $1 in
|
||||
-h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
net* | xml)
|
||||
selection=1
|
||||
;;
|
||||
nat* | etc*)
|
||||
selection=2
|
||||
;;
|
||||
profinet)
|
||||
selection=3
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$selection" ]; then
|
||||
use_dialog=1
|
||||
select_mode
|
||||
fi
|
||||
|
||||
case $selection in
|
||||
1)
|
||||
rm -f $mode 2>/dev/null
|
||||
grep -qi netconf $boot 2>/dev/null && exit 0
|
||||
result="Manageed NETCONF"
|
||||
;;
|
||||
2)
|
||||
echo "classic /etc" > $mode
|
||||
grep -qi classic $boot 2>/dev/null && exit 0
|
||||
result="Classic Linux, /etc"
|
||||
;;
|
||||
3)
|
||||
echo "PROFINET" > $mode
|
||||
grep -qi profinet $boot 2>/dev/null && exit 0
|
||||
result="PROFINET"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$use_dialog" ]; then
|
||||
dialog --erase-on-exit --cr-wrap --title "Activate Mode Change?" --yesno "\n Reboot to $result mode now?" 8 50
|
||||
if [ $? -eq 0 ]; then
|
||||
reboot
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Remember to reboot later to activate the change."
|
||||
exit 0
|
||||
@@ -1,2 +1 @@
|
||||
run [S] /lib/infix/nameif -- Probing network interfaces
|
||||
run if:<!boot/netconf> [S] /lib/infix/swup --
|
||||
|
||||
@@ -15,5 +15,4 @@ alias ipb='ip -br'
|
||||
alias ipaddr='ip addr'
|
||||
alias iplink='ip link'
|
||||
alias bridge='bridge --color=auto'
|
||||
alias setup='pdmenu; clear'
|
||||
alias cli='klish'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Called from /etc/fstab to ensure we have something writable mounted
|
||||
# at /cfg, /etc, /home, /root, and /var.
|
||||
#
|
||||
@@ -14,6 +13,7 @@
|
||||
# directories. Otherwise fall back to a tmpfs based RAM disk. This
|
||||
# effectively brings up the system with the default configuration, but
|
||||
# obviously any subsequent configuration is ephemeral.
|
||||
. /etc/os-release
|
||||
|
||||
set -e
|
||||
|
||||
@@ -88,7 +88,8 @@ else
|
||||
sync
|
||||
fi
|
||||
|
||||
if /lib/infix/use-etc; then
|
||||
# Check build: NETCONF or Classic
|
||||
if [ "$VARIANT_ID" != "netconf" ]; then
|
||||
etcsrc=/mnt/cfg
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f /mnt/cfg/infix/.use_etc ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Finit's condition system may not yet be bootstrapped when this script
|
||||
# is called, e.g., when /etc/fstab is parsed, so we have to manually
|
||||
# check for the boot/etc condition.
|
||||
awk '
|
||||
$0 == "finit.cond" {
|
||||
cond=1;
|
||||
next;
|
||||
}
|
||||
cond == 1 {
|
||||
use_etc = index($0, "etc") != 0;
|
||||
}
|
||||
END {
|
||||
exit(use_etc ? 0 : 1);
|
||||
}
|
||||
' /proc/1/cmdline
|
||||
@@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Override boot mode based on user input from setup tool
|
||||
|
||||
set_cond()
|
||||
{
|
||||
mkdir -p /run/finit/cond/boot
|
||||
ln -s /run/finit/cond/reconf "/run/finit/cond/boot/$1"
|
||||
}
|
||||
|
||||
# Report to the setup and show tools the current boot mode
|
||||
if /lib/infix/use-etc; then
|
||||
if [ -f /mnt/cfg/infix/.use_etc ]; then
|
||||
cat /mnt/cfg/infix/.use_etc > /tmp/.boot_mode
|
||||
if grep -qi profinet /mnt/cfg/infix/.use_etc; then
|
||||
set_cond profinet
|
||||
else
|
||||
set_cond etc
|
||||
fi
|
||||
else
|
||||
echo "classic /etc" > /tmp/.boot_mode
|
||||
set_cond etc
|
||||
fi
|
||||
else
|
||||
echo "NETCONF" > /tmp/.boot_mode
|
||||
set_cond netconf
|
||||
fi
|
||||
@@ -98,6 +98,7 @@ BR2_PACKAGE_HOST_RAUC=y
|
||||
BR2_PACKAGE_HOST_UBOOT_TOOLS=y
|
||||
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y
|
||||
BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT=y
|
||||
INFIX_VARIANT_CLASSIC=y
|
||||
BR2_PACKAGE_FACTORY=y
|
||||
BR2_PACKAGE_FINIT_SULOGIN=y
|
||||
BR2_PACKAGE_FINIT_PLUGIN_HOTPLUG=y
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This is an unmanaged node, leave /etc as-is
|
||||
/lib/infix/use-etc && exit 0
|
||||
|
||||
# This is a managed node, ignore all default configuration ...
|
||||
# ... except for some core services
|
||||
reserved()
|
||||
{
|
||||
for svc in avahi dnsmasq getty klish lldpd nginx ssdpd sshd sysklogd sysrepo; do
|
||||
|
||||
@@ -18,7 +18,6 @@ define CONFD_INSTALL_EXTRA
|
||||
mkdir -p $(TARGET_DIR)/usr/share/factory/cfg
|
||||
cp $(CONFD_PKGDIR)/factory-config.cfg $(TARGET_DIR)/usr/share/factory/cfg/startup-config.cfg
|
||||
mkdir -p $(TARGET_DIR)/lib/infix
|
||||
cp $(CONFD_PKGDIR)/prep-db $(TARGET_DIR)/lib/infix/
|
||||
cp $(CONFD_PKGDIR)/clean-etc $(TARGET_DIR)/lib/infix/
|
||||
endef
|
||||
CONFD_TARGET_FINALIZE_HOOKS += CONFD_INSTALL_EXTRA
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
exit 0
|
||||
@@ -1,8 +1,7 @@
|
||||
run if:<boot/netconf> [S] /lib/infix/clean-etc --
|
||||
run if:<boot/netconf> [S] /lib/infix/prep-db --
|
||||
run [S] /lib/infix/clean-etc --
|
||||
|
||||
service if:<boot/netconf> name:sysrepo [S12345789] sysrepo-plugind -p /run/sysrepo.pid -n -- Configuration daemon
|
||||
run if:<boot/netconf> [S] log <pid/sysrepo> sysrepocfg -v4 -E/cfg/startup-config.cfg -f json --
|
||||
service if:<boot/netconf> name:netopeer [12345789] netopeer2-server -n -- NETCONF daemon
|
||||
service name:sysrepo [S12345789] sysrepo-plugind -p /run/sysrepo.pid -n -- Configuration daemon
|
||||
run [S] log <pid/sysrepo> sysrepocfg -v4 -E/cfg/startup-config.cfg -f json --
|
||||
service name:netopeer [12345789] netopeer2-server -n -- NETCONF daemon
|
||||
|
||||
task if:<boot/netconf> [12345789] resolvconf -u -- Update DNS configuration
|
||||
task [12345789] resolvconf -u -- Update DNS configuration
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
service if:<!boot/profinet> [2345789] <!> env:-/etc/default/lldpd \
|
||||
lldpd -d $LLDPD_ARGS -- LLDP daemon (IEEE 802.1ab)
|
||||
service [2345789] <!> env:-/etc/default/lldpd lldpd -d $LLDPD_ARGS -- LLDP daemon (IEEE 802.1ab)
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
service if:<boot/profinet> [2345789] <net/vlan1/up,pid/snmpd> \
|
||||
log:prio:local7.info,tag:profeth \
|
||||
env:-/etc/default/profeth \
|
||||
profeth -s infix -p /var/lib/profeth $PROFETH_ARGS -- PROFΞTH daemon
|
||||
service [2345789] <net/vlan1/up,pid/snmpd> log:prio:local7.info,tag:profeth \
|
||||
env:-/etc/default/profeth profeth -s infix -p /var/lib/profeth $PROFETH_ARGS -- PROFΞTH daemon
|
||||
|
||||
Reference in New Issue
Block a user