Skip to content

Commit

Permalink
scripts UPDATE remove NP2_SCRIPTS_DIR env var
Browse files Browse the repository at this point in the history
  • Loading branch information
roman authored and michalvasko committed Nov 3, 2023
1 parent ddc58eb commit 180f05c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 36 deletions.
8 changes: 2 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ if(INSTALL_MODULES)
set(ENV{NP2_MODULE_PERMS} \"${MODULES_PERMS}\")
set(ENV{NP2_MODULE_OWNER} \"${MODULES_OWNER}\")
set(ENV{NP2_MODULE_GROUP} \"${MODULES_GROUP}\")
set(ENV{NP2_SCRIPTS_DIR} \"${SCRIPT_DIR}\")
set(ENV{LN2_MODULE_DIR} \"${LN2_YANG_MODULE_DIR}\")
set(ENV{SYSREPOCTL_EXECUTABLE} \"${SYSREPOCTL_EXECUTABLE}\")
set(ENV{SYSREPOCFG_EXECUTABLE} \"${SYSREPOCFG_EXECUTABLE}\")
Expand All @@ -374,7 +373,6 @@ if(GENERATE_HOSTKEY)
message(STATUS \"Generating a new RSA host key \\\"genkey\\\" if not already added...\")
set(ENV{SYSREPOCTL_EXECUTABLE} \"${SYSREPOCTL_EXECUTABLE}\")
set(ENV{SYSREPOCFG_EXECUTABLE} \"${SYSREPOCFG_EXECUTABLE}\")
set(ENV{NP2_SCRIPTS_DIR} \"${SCRIPT_DIR}\")
execute_process(COMMAND \"\$ENV{DESTDIR}${SCRIPT_DIR}/merge_hostkey.sh\" RESULT_VARIABLE MERGE_HOSTKEY_RES)
if(NOT MERGE_HOSTKEY_RES EQUAL \"0\")
message(FATAL_ERROR \" scripts/merge_hostkey.sh failed: \${MERGE_HOSTKEY_RES}\")
Expand All @@ -386,7 +384,6 @@ if(MERGE_LISTEN_CONFIG)
message(STATUS \"Merging default server listen configuration if there is none...\")
set(ENV{SYSREPOCTL_EXECUTABLE} \"${SYSREPOCTL_EXECUTABLE}\")
set(ENV{SYSREPOCFG_EXECUTABLE} \"${SYSREPOCFG_EXECUTABLE}\")
set(ENV{NP2_SCRIPTS_DIR} \"${SCRIPT_DIR}\")
execute_process(COMMAND \"\$ENV{DESTDIR}${SCRIPT_DIR}/merge_config.sh\" RESULT_VARIABLE MERGE_CONFIG_RES)
if(NOT MERGE_CONFIG_RES EQUAL \"0\")
message(FATAL_ERROR \" scripts/merge_config.sh failed: \${MERGE_CONFIG_RES}\")
Expand Down Expand Up @@ -420,8 +417,7 @@ add_custom_target(cleancache
)

# uninstall
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -E env "NP2_SCRIPTS_DIR=${SCRIPT_DIR}" ${SCRIPT_DIR}/remove.sh
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_MODULE_PATH}/uninstall.cmake
add_custom_target(uninstall ${SCRIPT_DIR}/remove.sh
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake"
COMMENT "Removing netopeer2 modules from sysrepo..."
)
2 changes: 1 addition & 1 deletion CMakeModules/uninstall.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.5)

set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")

Expand Down
8 changes: 2 additions & 6 deletions scripts/merge_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

set -e

if [ -z "$NP2_SCRIPTS_DIR" ]; then
echo "$0: Required environment variable NP2_SCRIPTS_DIR not set." >&2
exit 1
fi

# import functions
source "${NP2_SCRIPTS_DIR}/common.sh"
script_directory=$(dirname "$0")
source "${script_directory}/common.sh"

# get path to sysrepocfg executable, this will be stored in $SYSREPOCFG
SYSREPOCFG_GET_PATH
Expand Down
8 changes: 2 additions & 6 deletions scripts/merge_hostkey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

set -e

if [ -z "$NP2_SCRIPTS_DIR" ]; then
echo "$0: Required environment variable NP2_SCRIPTS_DIR not set." >&2
exit 1
fi

# import functions
source "${NP2_SCRIPTS_DIR}/common.sh"
script_directory=$(dirname "$0")
source "${script_directory}/common.sh"

# get path to sysrepocfg and openssl executables, these will be stored in $SYSREPOCFG and $OPENSSL, respectively
SYSREPOCFG_GET_PATH
Expand Down
8 changes: 2 additions & 6 deletions scripts/remove.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#!/usr/bin/env bash

if [ -z "$NP2_SCRIPTS_DIR" ]; then
echo "$0: Required environment variable NP2_SCRIPTS_DIR not set." >&2
exit 1
fi

# import functions and modules arrays
source "${NP2_SCRIPTS_DIR}/common.sh"
script_directory=$(dirname "$0")
source "${script_directory}/common.sh"

# get path to sysrepoctl executable, this will be stored in $SYSREPOCTL
SYSREPOCTL_GET_PATH
Expand Down
8 changes: 5 additions & 3 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/usr/bin/env bash

# env variables NP2_MODULE_DIR, NP2_MODULE_PERMS, LN2_MODULE_DIR and NP2_SCRIPTS_DIR must be defined
# env variables NP2_MODULE_DIR, NP2_MODULE_PERMS and LN2_MODULE_DIR must be defined
# and NP2_MODULE_OWNER, NP2_MODULE_GROUP will be used if defined when executing this script!
if [ -z "$NP2_MODULE_DIR" -o -z "$NP2_MODULE_PERMS" -o -z "$LN2_MODULE_DIR" -o -z "$NP2_SCRIPTS_DIR" ]; then

if [ -z "$NP2_MODULE_DIR" -o -z "$NP2_MODULE_PERMS" -o -z "$LN2_MODULE_DIR" ]; then
echo "Required environment variables not defined!"
exit 1
fi

# import functions and modules arrays
source "${NP2_SCRIPTS_DIR}/common.sh"
script_directory=$(dirname "$0")
source "${script_directory}/common.sh"

# get path to sysrepoctl executable, this will be stored in $SYSREPOCTL
SYSREPOCTL_GET_PATH
Expand Down
8 changes: 0 additions & 8 deletions tests/np_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,6 @@ np_glob_setup_np2(void **state, const char *test_name, const char **modules)
SETUP_FAIL_LOG;
return 1;
}
if (setenv("NP2_SCRIPTS_DIR", NP_ROOT_DIR "/scripts", 1)) {
SETUP_FAIL_LOG;
return 1;
}
if (setenv("LN2_MODULE_DIR", LN2_YANG_MODULE_DIR, 1)) {
SETUP_FAIL_LOG;
return 1;
Expand All @@ -175,10 +171,6 @@ np_glob_setup_np2(void **state, const char *test_name, const char **modules)
SETUP_FAIL_LOG;
return 1;
}
if (unsetenv("NP2_SCRIPTS_DIR")) {
SETUP_FAIL_LOG;
return 1;
}
if (unsetenv("LN2_MODULE_DIR")) {
SETUP_FAIL_LOG;
return 1;
Expand Down

0 comments on commit 180f05c

Please sign in to comment.