Skip to content

Commit d6e9c5c

Browse files
committed
allow for server and client configuration files to be placed into different locations
CONFIG_FILE -> CONFIG_SERVER and CONFIG_CLIENT Fixes #172
1 parent c8f71f6 commit d6e9c5c

File tree

9 files changed

+68
-41
lines changed

9 files changed

+68
-41
lines changed

config/CMakeLists.txt

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,53 +63,64 @@
6363
include(ProcessorCount)
6464
ProcessorCount(CORES)
6565

66-
set(CONFIG_FILE "/etc/GUFI/config" CACHE FILEPATH "Where high level GUFI tools will look for configuration")
67-
if (NOT IS_ABSOLUTE "${CONFIG_FILE}")
68-
message(FATAL_ERROR "CONFIG_FILE must be set to absolute path")
69-
endif()
70-
if (EXISTS "${CONFIG_FILE}")
71-
if (APPLE OR DARWIN)
72-
execute_process(COMMAND stat -L -f "%HT" "${CONFIG_FILE}"
73-
OUTPUT_VARIABLE CONFIG_FILE_TYPE
74-
OUTPUT_STRIP_TRAILING_WHITESPACE
75-
)
76-
if (NOT CONFIG_FILE_TYPE STREQUAL "Regular File")
77-
message(FATAL_ERROR "CONFIG_FILE must point to a file. Got ${CONFIG_FILE_TYPE}")
78-
endif()
79-
else()
80-
execute_process(COMMAND stat --dereference --format "%F" "${CONFIG_FILE}"
81-
OUTPUT_VARIABLE CONFIG_FILE_TYPE
82-
OUTPUT_STRIP_TRAILING_WHITESPACE
83-
)
84-
if (NOT CONFIG_FILE_TYPE STREQUAL "regular file")
85-
message(FATAL_ERROR "CONFIG_FILE must point to a file. Got ${CONFIG_FILE_TYPE}")
66+
set(CONFIG_DEFAULT "/etc/GUFI/config")
67+
68+
function(config_file var_name type)
69+
set("${var_name}" "${CONFIG_DEFAULT}" CACHE FILEPATH "Where high level GUFI tools will look for the ${type} configuration")
70+
if (NOT IS_ABSOLUTE "${${var_name}}")
71+
message(FATAL_ERROR "${var_name} must be set to absolute path")
72+
endif()
73+
if (EXISTS "${${var_name}}")
74+
if (APPLE OR DARWIN)
75+
execute_process(COMMAND stat -L -f "%HT" "${${var_name}}"
76+
OUTPUT_VARIABLE CONFIG_FILE_TYPE
77+
OUTPUT_STRIP_TRAILING_WHITESPACE
78+
)
79+
if (NOT CONFIG_FILE_TYPE STREQUAL "Regular File")
80+
message(FATAL_ERROR "${var_name} must point to a file. Got ${CONFIG_FILE_TYPE}")
81+
endif()
82+
else()
83+
execute_process(COMMAND stat --dereference --format "%F" "${${var_name}}"
84+
OUTPUT_VARIABLE CONFIG_FILE_TYPE
85+
OUTPUT_STRIP_TRAILING_WHITESPACE
86+
)
87+
if (NOT CONFIG_FILE_TYPE STREQUAL "regular file")
88+
message(FATAL_ERROR "${var_name} must point to a file. Got ${CONFIG_FILE_TYPE}")
89+
endif()
8690
endif()
8791
endif()
88-
endif()
89-
if (NOT CONFIG_FILE STREQUAL "/etc/GUFI/config")
90-
message(WARNING "CONFIG_FILE ${CONFIG_FILE} may conflict with filesystem package when installing GUFI RPMs")
91-
endif()
92+
if (NOT "${${var_name}}" STREQUAL "${CONFIG_DEFAULT}")
93+
message(WARNING "${var_name} ${${var_name}} may conflict with filesystem package when installing GUFI RPMs")
94+
endif()
95+
endfunction()
9296

93-
get_filename_component(CONFIG_FILE_PARENT "${CONFIG_FILE}" DIRECTORY)
97+
config_file(CONFIG_SERVER "server")
98+
if (CLIENT)
99+
config_file(CONFIG_CLIENT "client")
100+
endif()
94101

95102
if (CLIENT)
103+
get_filename_component(CONFIG_CLIENT_PARENT "${CONFIG_CLIENT}" DIRECTORY)
104+
96105
# client config
97106
# copy the hard coded client example file
98107
configure_file(client.example.in "${CMAKE_BINARY_DIR}/client.example" @ONLY)
99108

100109
# make install and rpm
101110
install(FILES "${CMAKE_BINARY_DIR}/client.example"
102-
DESTINATION "${CONFIG_FILE_PARENT}"
111+
DESTINATION "${CONFIG_CLIENT_PARENT}"
103112
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ # 664
104113
COMPONENT Client)
105114
endif()
106115

116+
get_filename_component(CONFIG_SERVER_PARENT "${CONFIG_SERVER}" DIRECTORY)
117+
107118
# server config
108119
# copy the hard coded server example file
109120
configure_file(server.example.in "${CMAKE_BINARY_DIR}/server.example" @ONLY)
110121

111122
# make install and rpm
112123
install(FILES "${CMAKE_BINARY_DIR}/server.example"
113-
DESTINATION "${CONFIG_FILE_PARENT}"
124+
DESTINATION "${CONFIG_SERVER_PARENT}"
114125
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ # 664
115126
COMPONENT Server)

contrib/CI/generic_rpm.sh.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ rpm -ql gufi-*.rpm | sed '/.*\.build-id/d' | sort
7979
dnf install -y gufi-*.rpm
8080

8181
# compare the configuration files
82-
@DIFF@ server.example "$(dirname @CONFIG_FILE@)/server.example"
82+
@DIFF@ server.example "$(dirname @CONFIG_SERVER@)/server.example"
8383

8484
# remove the configuration file
85-
rm -r "$(dirname @CONFIG_FILE@)"
85+
rm -r "$(dirname @CONFIG_SERVER@)"

contrib/CI/rpms.sh.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ rpm -ql gufi-client*.rpm | sort
8282
dnf install -y gufi-server-*.rpm
8383

8484
# compare the configuration files
85-
@DIFF@ server.example "$(dirname @CONFIG_FILE@)/server.example"
85+
@DIFF@ server.example "$(dirname @CONFIG_SERVER@)/server.example"
8686

8787
# uninstall GUFI-Server
8888
dnf autoremove -y GUFI-Server
@@ -94,4 +94,4 @@ python3 -m pip install --upgrade pip
9494
dnf install -y gufi-client-*.rpm
9595

9696
# compare the configuration files
97-
@DIFF@ client.example "$(dirname @CONFIG_FILE@)/client.example"
97+
@DIFF@ client.example "$(dirname @CONFIG_CLIENT@)/client.example"

docs/latex/sections/build.tex

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,20 @@ \subsubsection{System Paths}
207207
\hline
208208
\texttt{-D<VAR>=<VALUE>} & Description \\
209209
\hline
210-
\texttt{CONFIG\_FILE=<FILEPATH>} & Path of configuration file used by scripts. \\
211-
& Defaults to \guficonfigfile. \\
212-
& Note that many paths will conflict with the paths of other \\
213-
& packages if installing GUFI via package. If installing GUFI \\
214-
& with \texttt{make install}, point to a convenient location. \\
210+
\texttt{CONFIG\_CLIENT=<FILEPATH>} & Path of configuration file used by scripts. \\
211+
\texttt{CONFIG\_SERVER=<FILEPATH>} & \\
212+
& Two different paths are available in case \\
213+
& the server and client deployments place their \\
214+
& configuration files in different locations. \\
215+
& \\
216+
& When \texttt{CLIENT=Off}, \texttt{CONFIG\_SERVER} \\
217+
& is used as the location of the configuration file. \\
218+
& \\
219+
& Both default to \guficonfigfile. \\
220+
& \\
221+
& Note that many paths will conflict with the paths of other \\
222+
& packages if installing GUFI via package. If installing GUFI \\
223+
& with \texttt{make install}, point to a convenient location. \\
215224
\hline
216225
\texttt{BASH\_COMPLETION=<On|Off>} & Whether or not to install bash completion script to \\
217226
& \texttt{/etc/bash\_completion.d} (default: On). \\

docs/man/gufi_find.1.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ Size of each thread's output buffer
107107
.Sh FILES
108108
.Bl -tag -width -compact
109109
.It Pa @CMAKE_INSTALL_PREFIX@/@BIN@/gufi_find
110-
.It Pa @CONFIG_FILE@
110+
.It Pa @CONFIG_SERVER@
111+
.It Pa @CONFIG_CLIENT@
111112
.El
112113

113114
.\" .Sh BUGS

docs/man/gufi_ls.1.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ Size of each thread's output buffer
6969
.Sh FILES
7070
.Bl -tag -width -compact
7171
.It Pa @CMAKE_INSTALL_PREFIX@/@BIN@/gufi_ls
72-
.It Pa @CONFIG_FILE@
72+
.It Pa @CONFIG_SERVER@
73+
.It Pa @CONFIG_CLIENT@
7374
.El
7475

7576
.\" .Sh BUGS

docs/man/gufi_stats.1.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ Total number of leaf directories under the provided path
7979
.Sh FILES
8080
.Bl -tag -width -compact
8181
.It Pa @CMAKE_INSTALL_PREFIX@/@BIN@/gufi_stats
82-
.It Pa @CONFIG_FILE@
82+
.It Pa @CONFIG_SERVER@
83+
.It Pa @CONFIG_CLIENT@
8384
.El
8485

8586
.\" .Sh BUGS

scripts/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,17 @@ set(LIBRARIES
136136
)
137137

138138
foreach(LIBRARY ${LIBRARIES})
139+
set(CONFIG_FILE "${CONFIG_SERVER}")
139140
configure_file("${LIBRARY}" "${LIBRARY}" @ONLY)
140141

141142
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY}" DESTINATION "${LIB}" COMPONENT Server)
142143

143144
# when running make install, client files will not overwrite server files
144145
if (CLIENT)
145-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LIBRARY}" DESTINATION "${LIB}" COMPONENT Client)
146+
set(CONFIG_FILE "${CONFIG_CLIENT}")
147+
configure_file("${LIBRARY}" "client_${LIBRARY}" @ONLY)
148+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/client_${LIBRARY}" DESTINATION "${LIB}" COMPONENT Client
149+
RENAME "${LIBRARY}")
146150
endif()
147151
endforeach()
148152

scripts/bash_completion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
GUFI_PWD=""
6565

66-
CONFIG="${1-@CONFIG_FILE@}"
66+
CONFIG="${1-@CONFIG_SERVER@}"
6767

6868
__gufi() {
6969
# make sure the config file exists

0 commit comments

Comments
 (0)