blob: 5aec0c05446d4de828ed4313a89125ee57cc6b38 [file] [log] [blame]
Václav Kubernátd1beedc2020-09-07 12:09:05 +02001set -eux
2export UBSAN_OPTIONS=halt_on_error=1 # UBSan doesn't stop on errors by default.
3
4if [[ $(dirname "$(dirname "$(realpath "$SYSREPO_REPOSITORY_PATH")")") != "@CMAKE_CURRENT_BINARY_DIR@" ]]; then
5 echo "\$SYSREPO_REPOSITORY_PATH is not inside the build dir! Aborting. ($SYSREPO_REPOSITORY_PATH)"
6 exit 1
7fi
8
9if [[ -z "$SYSREPO_SHM_PREFIX" ]]; then
10 echo '$SYSREPO_SHM_PREFIX is empty! Aborting.'
11 exit 1
12fi
13
14rm -rf "$SYSREPO_REPOSITORY_PATH"
15rm -rf "/dev/shm/$SYSREPO_SHM_PREFIX"*
16cp -r "@SYSREPO_SR_REPO_PATH@" "$SYSREPO_REPOSITORY_PATH"
17
18SYSREPOCTL="@SYSREPOCTL_EXECUTABLE@"
19SYSREPOCFG="@SYSREPOCFG_EXECUTABLE@"
20
21MODULE="$1"
22YANG_DIR=$(dirname "$1")
23shift
24
25# Install the module
26"$SYSREPOCTL" --search-dirs "$YANG_DIR" --install "$MODULE" -a
27
28BACKEND="$1"
29shift
30if [[ "$BACKEND" = "netconf" ]]; then
31 NETOPEER2="@NETOPEER2_EXECUTABLE@"
32 # Setup netopeer config
33 "$SYSREPOCFG" --import --datastore=running --format=xml --module=ietf-netconf-server <<< ""
34
35 # Disable nacm
36 for datastore in startup running; do
37 "$SYSREPOCFG" --import="@CMAKE_CURRENT_SOURCE_DIR@/tests/disable-nacm.xml" --datastore="$datastore" --format=xml --module=ietf-netconf-acm
38 done
39
40 # Run netopeer. Use exec -a, so that each process has a recognizable name for `pkill`.
41 (exec -a "${SYSREPO_SHM_PREFIX}_netopeer2-server" "$NETOPEER2" -v2 "-U$NETOPEER_SOCKET")
42 sleep 5
43fi