summaryrefslogtreecommitdiffstats
path: root/net/netopeer2/files/netopeer2-server-setup.default
blob: 0fd4cdda3f42c6cc48b1191153906d161e37cc19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh

# Warning, problems can occur if the device restarts in the middle of this uci-default script

SYSREPOCTL=$(which sysrepoctl)
PERMS=600

NP2_MODDIR=/etc/netopeer2/modules
LN2_MODDIR=/etc/netconf2/modules

LN2_MODULES="iana-ssh-encryption-algs@2024-10-16.yang
iana-ssh-key-exchange-algs@2024-10-16.yang
iana-ssh-mac-algs@2024-10-16.yang
iana-ssh-public-key-algs@2024-10-16.yang
iana-tls-cipher-suite-algs@2024-10-16.yang
ietf-x509-cert-to-name@2014-12-10.yang
iana-crypt-hash@2014-04-04.yang -e crypt-hash-md5 -e crypt-hash-sha-256 -e crypt-hash-sha-512
ietf-crypto-types@2024-10-10.yang -e cleartext-passwords -e cleartext-private-keys
ietf-keystore@2024-10-10.yang -e central-keystore-supported -e inline-definitions-supported -e asymmetric-keys
ietf-truststore@2024-10-10.yang -e central-truststore-supported -e inline-definitions-supported -e certificates -e public-keys
ietf-tcp-common@2024-10-10.yang -e keepalives-supported
ietf-tcp-server@2024-10-10.yang -e tcp-server-keepalives
ietf-tcp-client@2024-10-10.yang -e local-binding-supported -e tcp-client-keepalives
ietf-ssh-common@2024-10-10.yang -e algorithm-discovery -e transport-params
ietf-ssh-server@2024-10-10.yang -e local-users-supported -e local-user-auth-publickey -e local-user-auth-password -e local-user-auth-none
ietf-tls-common@2024-10-10.yang -e algorithm-discovery -e tls12 -e tls13 -e hello-params
ietf-tls-server@2024-10-10.yang -e server-ident-x509-cert -e client-auth-supported -e client-auth-x509-cert
ietf-netconf-server@2025-04-24.yang -e ssh-listen -e tls-listen -e ssh-call-home -e tls-call-home -e central-netconf-server-supported
libnetconf2-netconf-server@2026-04-17.yang"

NP2_MODULES="ietf-interfaces@2018-02-20.yang
ietf-ip@2018-02-22.yang
ietf-netconf@2013-09-29.yang -e writable-running -e candidate -e rollback-on-error -e validate -e startup -e url -e xpath -e confirmed-commit
ietf-netconf-nmda@2019-01-07.yang -e origin -e with-defaults
notifications@2008-07-14.yang
nc-notifications@2008-07-14.yang
ietf-netconf-monitoring@2010-10-04.yang
ietf-network-instance@2019-01-21.yang
ietf-subscribed-notifications@2019-09-09.yang -e encode-xml -e replay -e subtree -e xpath
ietf-yang-push@2019-09-09.yang -e on-change
netopeer-notifications@2026-01-05.yang
ietf-system-capabilities@2022-02-17.yang
ietf-notification-capabilities@2022-02-17.yang
ietf-netconf-private-candidate@2026-02-03.yang -e private-candidate"

SCTL_MODULES=$($SYSREPOCTL -l)

setup_modules() {
	_dir=$1
	_list=/tmp/netopeer2-modules.$$
	printf '%s\n' "$2" > "$_list"

	while read -r _file _features; do
		[ -n "$_file" ] || continue
		_name=${_file%%@*}

		if echo "$SCTL_MODULES" | grep -q "^$_name \+|[^|]*| I"; then
			continue
		fi

		if ! $SYSREPOCTL -i "$_dir/$_file" -s "$_dir" -p $PERMS -v2; then
			rm -f "$_list"
			exit 1
		fi

		for _feature in $_features; do
			[ "$_feature" = "-e" ] && continue
			if ! $SYSREPOCTL -c "$_name" -e "$_feature" -v2; then
				rm -f "$_list"
				exit 1
			fi
		done
	done < "$_list"

	rm -f "$_list"
}

setup_modules "$LN2_MODDIR" "$LN2_MODULES"
setup_modules "$NP2_MODDIR" "$NP2_MODULES"

exit 0