clixon: Initial packaging 22362/head
authorPhilip Prindeville <philipp@redfish-solutions.com>
Tue, 10 Oct 2023 01:21:41 +0000 (19:21 -0600)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Tue, 5 Dec 2023 17:59:08 +0000 (10:59 -0700)
Clixon is a YANG-based configuration manager, with interactive CLI,
NETCONF and RESTCONF interfaces, an embedded database and transaction
mechanism.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
utils/clixon/Makefile [new file with mode: 0644]
utils/clixon/files/clixon.init [new file with mode: 0755]
utils/clixon/files/netconf-subsystem.conf [new file with mode: 0644]
utils/clixon/files/restconf.xml [new file with mode: 0644]

diff --git a/utils/clixon/Makefile b/utils/clixon/Makefile
new file mode 100644 (file)
index 0000000..44209b8
--- /dev/null
@@ -0,0 +1,93 @@
+#
+# Copyright (C) 2020-2023 Olof Hagsand and Rubicon Communications, LLC(Netgate)
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=clixon
+PKG_VERSION:=6.5.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/clicon/$(PKG_NAME)/tar.gz/$(PKG_VERSION)?
+PKG_HASH:=c85bf3112ddd9dcc00965780c21bf1589095c8b67f741ef7059c805feccf3bfc
+PKG_MAINTAINER:=Olof Hagsand <olof@hagsand.se>, Philip Prindeville <philipp@redfish-solutions.com>
+
+PKG_LICENSE:=Apache-2.0
+PKG_LICENSE_FILE:=LICENSE.md
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/clixon
+  SECTION:=utils
+  CATEGORY:=Utilities
+  URL:=https://www.clicon.org
+  TITLE:=YANG-based toolchain
+  DEPENDS:=+cligen +libopenssl +libnghttp2 +libcurl \
+        @(PACKAGE_openssh-server||PACKAGE_openssh-server-pam)
+  USERID:=clicon=61:clicon=61
+endef
+
+define Package/clixon/description
+  YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI.
+endef
+
+define Package/clixon/conffiles
+/etc/clixon/restconf.xml
+/etc/ssh/sshd_config.d/90-netconf-subsystem.conf
+endef
+
+CONFIGURE_ARGS += \
+       --exec-prefix=/usr \
+       --with-restconf=native \
+       --with-configfile=/etc/clixon/clixon.xml \
+       --with-cligen=$(STAGING_DIR)/usr
+
+CONFIGURE_ARGS:=$(filter-out --disable-dependency-tracking,$(CONFIGURE_ARGS))
+
+INSTALLFLAGS:=-s --strip-program=$(TARGET_CROSS)strip
+
+CONFIGURE_VARS+= \
+       INSTALLFLAGS="$(INSTALLFLAGS)" \
+       SSH_BIN=/usr/bin/ssh
+
+define Build/InstallDev
+       $(INSTALL_DIR) $(1)/usr/include
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/clixon $(1)/usr/include/
+       $(INSTALL_DIR) $(1)/usr/lib/
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libclixon.so* \
+             $(PKG_INSTALL_DIR)/usr/lib/libclixon_backend.so* \
+             $(PKG_INSTALL_DIR)/usr/lib/libclixon_restconf.so* \
+             $(PKG_INSTALL_DIR)/usr/lib/libclixon_cli.so* \
+             $(1)/usr/lib/
+endef
+
+define Package/clixon/install
+       $(INSTALL_DIR) $(1)/etc/clixon
+       $(INSTALL_DATA) ./files/restconf.xml $(1)/etc/clixon/
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/clixon_* $(1)/usr/sbin/
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/clixon_* $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/usr/share/clixon
+       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/clixon/*.yang $(1)/usr/share/clixon/
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libclixon.so* \
+             $(PKG_INSTALL_DIR)/usr/lib/libclixon_backend.so* \
+             $(PKG_INSTALL_DIR)/usr/lib/libclixon_restconf.so* \
+             $(PKG_INSTALL_DIR)/usr/lib/libclixon_cli.so* \
+             $(1)/usr/lib/
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/clixon.init $(1)/etc/init.d/clixon
+       $(INSTALL_DIR) $(1)/etc/ssh/sshd_config.d
+       $(INSTALL_CONF) ./files/netconf-subsystem.conf $(1)/etc/ssh/sshd_config.d/90-netconf-subsystem.conf
+endef
+
+$(eval $(call BuildPackage,clixon))
+
diff --git a/utils/clixon/files/clixon.init b/utils/clixon/files/clixon.init
new file mode 100755 (executable)
index 0000000..edf9b1a
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh /etc/rc.common
+
+START=95
+STOP=05
+
+USE_PROCD=1
+PROG=/usr/sbin/clixon_backend
+CONFIGFILE=/etc/clixon/clixon.xml
+
+get_xmldb_dir() {
+    $PROG -F -f "$CONFIGFILE" -1 -l s -C text -s none \
+           | awk '/^   CLICON_XMLDB_DIR / { print substr($2, 0, length($2) - 1); }'
+}
+
+start_service() {
+    local state="init"
+
+    [ -f "$(get_xmldb_dir)/running_db" ] && state="running"
+
+    procd_open_instance
+    procd_set_param command "$PROG"
+
+    procd_set_param file $CONFIGFILE
+
+    procd_append_param command -F
+    procd_append_param command -f $CONFIGFILE
+    procd_append_param command -l s
+    procd_append_param command -s $state
+
+    procd_close_instance
+}
+
+stop_service() {
+    service_stop "$PROG"
+}
diff --git a/utils/clixon/files/netconf-subsystem.conf b/utils/clixon/files/netconf-subsystem.conf
new file mode 100644 (file)
index 0000000..d40316f
--- /dev/null
@@ -0,0 +1 @@
+Subsystem      netconf         /usr/bin/clixon_netconf
diff --git a/utils/clixon/files/restconf.xml b/utils/clixon/files/restconf.xml
new file mode 100644 (file)
index 0000000..a170b36
--- /dev/null
@@ -0,0 +1,13 @@
+<restconf>
+    <enable>true</enable>
+    <auth-type>none</auth-type>
+    <pretty>false</pretty>
+    <debug>0</debug>
+    <log-destination>syslog</log-destination>
+    <socket>
+      <namespace>default</namespace>
+      <address>0.0.0.0</address>
+      <port>80</port>
+      <ssl>false</ssl>
+    </socket>
+</restconf>