diff --git a/Config.in b/Config.in index 2fbcb242..e0926cbd 100644 --- a/Config.in +++ b/Config.in @@ -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" diff --git a/board/classic/rootfs/bin/chom b/board/classic/rootfs/bin/chom deleted file mode 100755 index c823b3f5..00000000 --- a/board/classic/rootfs/bin/chom +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -dialog --msgbox "This build is hardwired to classic /etc mode." 6 48 diff --git a/board/common/rootfs/bin/help b/board/classic/rootfs/bin/help similarity index 100% rename from board/common/rootfs/bin/help rename to board/classic/rootfs/bin/help diff --git a/board/common/rootfs/bin/hostnm b/board/classic/rootfs/bin/hostnm similarity index 100% rename from board/common/rootfs/bin/hostnm rename to board/classic/rootfs/bin/hostnm diff --git a/board/classic/rootfs/bin/setup b/board/classic/rootfs/bin/setup new file mode 100755 index 00000000..107a6e85 --- /dev/null +++ b/board/classic/rootfs/bin/setup @@ -0,0 +1,3 @@ +#!/bin/sh +pdmenu +clear diff --git a/board/common/rootfs/bin/show b/board/classic/rootfs/bin/show similarity index 99% rename from board/common/rootfs/bin/show rename to board/classic/rootfs/bin/show index 4b70eb1f..6c69adfc 100755 --- a/board/common/rootfs/bin/show +++ b/board/classic/rootfs/bin/show @@ -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)" diff --git a/board/common/rootfs/bin/yorn b/board/classic/rootfs/bin/yorn similarity index 100% rename from board/common/rootfs/bin/yorn rename to board/classic/rootfs/bin/yorn diff --git a/board/classic/rootfs/etc/finit.d/20-infix-classic.conf b/board/classic/rootfs/etc/finit.d/20-infix-classic.conf new file mode 100644 index 00000000..7e3a18a0 --- /dev/null +++ b/board/classic/rootfs/etc/finit.d/20-infix-classic.conf @@ -0,0 +1 @@ +run [S] /lib/infix/swup -- diff --git a/board/common/rootfs/etc/pdmenurc b/board/classic/rootfs/etc/pdmenurc similarity index 95% rename from board/common/rootfs/etc/pdmenurc rename to board/classic/rootfs/etc/pdmenurc index 2df7541f..399bdcc7 100644 --- a/board/common/rootfs/etc/pdmenurc +++ b/board/classic/rootfs/etc/pdmenurc @@ -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.. diff --git a/board/common/rootfs/lib/infix/swup b/board/classic/rootfs/lib/infix/swup similarity index 86% rename from board/common/rootfs/lib/infix/swup rename to board/classic/rootfs/lib/infix/swup index 40d402d0..d23ba44a 100755 --- a/board/common/rootfs/lib/infix/swup +++ b/board/classic/rootfs/lib/infix/swup @@ -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 diff --git a/board/classic/rootfs/lib/infix/use-etc b/board/classic/rootfs/lib/infix/use-etc deleted file mode 100755 index 039e4d00..00000000 --- a/board/classic/rootfs/lib/infix/use-etc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exit 0 diff --git a/board/common/Config.in b/board/common/Config.in index 9f89d9b8..c9fcf380 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -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 diff --git a/board/common/post-build.sh b/board/common/post-build.sh index 626ecbf4..7bad26c6 100755 --- a/board/common/post-build.sh +++ b/board/common/post-build.sh @@ -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 diff --git a/board/common/rootfs/bin/chom b/board/common/rootfs/bin/chom deleted file mode 100755 index 76072871..00000000 --- a/board/common/rootfs/bin/chom +++ /dev/null @@ -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 </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 diff --git a/board/common/rootfs/etc/finit.d/10-infix.conf b/board/common/rootfs/etc/finit.d/10-infix.conf index 286c955a..73e2b824 100644 --- a/board/common/rootfs/etc/finit.d/10-infix.conf +++ b/board/common/rootfs/etc/finit.d/10-infix.conf @@ -1,2 +1 @@ run [S] /lib/infix/nameif -- Probing network interfaces -run if: [S] /lib/infix/swup -- diff --git a/board/common/rootfs/etc/profile.d/convenience.sh b/board/common/rootfs/etc/profile.d/convenience.sh index e27fc5c5..72509b17 100644 --- a/board/common/rootfs/etc/profile.d/convenience.sh +++ b/board/common/rootfs/etc/profile.d/convenience.sh @@ -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' diff --git a/board/common/rootfs/lib/infix/mnt b/board/common/rootfs/lib/infix/mnt index d9d18606..bded7c64 100755 --- a/board/common/rootfs/lib/infix/mnt +++ b/board/common/rootfs/lib/infix/mnt @@ -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 diff --git a/board/common/rootfs/lib/infix/use-etc b/board/common/rootfs/lib/infix/use-etc deleted file mode 100755 index 7364d03b..00000000 --- a/board/common/rootfs/lib/infix/use-etc +++ /dev/null @@ -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 diff --git a/board/common/rootfs/libexec/finit/hook/mount/all/boot-mode.sh b/board/common/rootfs/libexec/finit/hook/mount/all/boot-mode.sh deleted file mode 100755 index 678fa449..00000000 --- a/board/common/rootfs/libexec/finit/hook/mount/all/boot-mode.sh +++ /dev/null @@ -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 diff --git a/configs/x86_64_classic_defconfig b/configs/x86_64_classic_defconfig index b61fc89d..531dbb28 100644 --- a/configs/x86_64_classic_defconfig +++ b/configs/x86_64_classic_defconfig @@ -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 diff --git a/package/confd/clean-etc b/package/confd/clean-etc index 0de6cef2..ca909fd9 100755 --- a/package/confd/clean-etc +++ b/package/confd/clean-etc @@ -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 diff --git a/package/confd/confd.mk b/package/confd/confd.mk index 46c7801b..cc3a9de6 100644 --- a/package/confd/confd.mk +++ b/package/confd/confd.mk @@ -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 diff --git a/package/confd/prep-db b/package/confd/prep-db deleted file mode 100755 index 541a41f5..00000000 --- a/package/confd/prep-db +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -e - -exit 0 diff --git a/package/confd/sysrepo.conf b/package/confd/sysrepo.conf index a78d4e56..ffae6e84 100644 --- a/package/confd/sysrepo.conf +++ b/package/confd/sysrepo.conf @@ -1,8 +1,7 @@ -run if: [S] /lib/infix/clean-etc -- -run if: [S] /lib/infix/prep-db -- +run [S] /lib/infix/clean-etc -- -service if: name:sysrepo [S12345789] sysrepo-plugind -p /run/sysrepo.pid -n -- Configuration daemon -run if: [S] log sysrepocfg -v4 -E/cfg/startup-config.cfg -f json -- -service if: name:netopeer [12345789] netopeer2-server -n -- NETCONF daemon +service name:sysrepo [S12345789] sysrepo-plugind -p /run/sysrepo.pid -n -- Configuration daemon +run [S] log sysrepocfg -v4 -E/cfg/startup-config.cfg -f json -- +service name:netopeer [12345789] netopeer2-server -n -- NETCONF daemon -task if: [12345789] resolvconf -u -- Update DNS configuration +task [12345789] resolvconf -u -- Update DNS configuration diff --git a/package/skeleton-init-finit/skeleton/etc/finit.d/available/lldpd.conf b/package/skeleton-init-finit/skeleton/etc/finit.d/available/lldpd.conf index 186f0372..ece41b2f 100644 --- a/package/skeleton-init-finit/skeleton/etc/finit.d/available/lldpd.conf +++ b/package/skeleton-init-finit/skeleton/etc/finit.d/available/lldpd.conf @@ -1,2 +1 @@ -service if: [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) diff --git a/package/skeleton-init-finit/skeleton/etc/finit.d/available/profeth.conf b/package/skeleton-init-finit/skeleton/etc/finit.d/available/profeth.conf index e7d30018..f8e7e73a 100644 --- a/package/skeleton-init-finit/skeleton/etc/finit.d/available/profeth.conf +++ b/package/skeleton-init-finit/skeleton/etc/finit.d/available/profeth.conf @@ -1,4 +1,2 @@ -service if: [2345789] \ - log:prio:local7.info,tag:profeth \ - env:-/etc/default/profeth \ - profeth -s infix -p /var/lib/profeth $PROFETH_ARGS -- PROFΞTH daemon +service [2345789] log:prio:local7.info,tag:profeth \ + env:-/etc/default/profeth profeth -s infix -p /var/lib/profeth $PROFETH_ARGS -- PROFΞTH daemon