@@ -53,6 +53,7 @@ readonly PATH_FILE_ETC_KRB5_KEYTAB='/etc/krb5.keytab'
53
53
readonly MOUNT_PATH_NFSD=' /proc/fs/nfsd'
54
54
readonly MOUNT_PATH_RPC_PIPEFS=' /var/lib/nfs/rpc_pipefs'
55
55
56
+
56
57
# #####################################################################################
57
58
# ## general purpose utilities
58
59
# #####################################################################################
@@ -70,18 +71,25 @@ logHeader() {
70
71
echo ' =================================================================='
71
72
}
72
73
74
+ bail () {
75
+
76
+ log " ERROR: $1 "
77
+ exit 1
78
+ }
79
+
73
80
warn_on_failure () {
74
81
82
+ # shellcheck disable=SC2181
75
83
if [[ $? -ne 0 ]]; then
76
84
log " WARNING: $1 "
77
85
fi
78
86
}
79
87
80
88
exit_on_failure () {
81
89
90
+ # shellcheck disable=SC2181
82
91
if [[ $? -ne 0 ]]; then
83
- log " $1 "
84
- exit 1
92
+ bail " $1 "
85
93
fi
86
94
}
87
95
@@ -153,6 +161,7 @@ stop() {
153
161
154
162
stop_on_failure () {
155
163
164
+ # shellcheck disable=SC2181
156
165
if [[ $? -ne 0 ]]; then
157
166
log " $1 "
158
167
stop
@@ -220,6 +229,13 @@ is_nfs4_enabled() {
220
229
# ## runtime configuration assertions
221
230
# #####################################################################################
222
231
232
+ assert_file_provided () {
233
+
234
+ if [[ ! -f " $1 " ]]; then
235
+ bail " please provide $1 to the container"
236
+ fi
237
+ }
238
+
223
239
assert_kernel_mod () {
224
240
225
241
local -r moduleName=$1
@@ -237,8 +253,7 @@ assert_port() {
237
253
local -r value=${! envName}
238
254
239
255
if [[ -n " $value " && ( " $value " -lt 1 || " $value " -gt 65535 ) ]]; then
240
- log " Please set $1 to a value between 1 and 65535 inclusive"
241
- exit 1
256
+ bail " please set $1 to a value between 1 and 65535 inclusive"
242
257
fi
243
258
}
244
259
@@ -251,8 +266,7 @@ assert_nfs_version() {
251
266
assert_disabled_nfs3 () {
252
267
253
268
if [[ -z " $( is_nfs3_enabled) " && " $( get_reqd_nfs_version) " == ' 3' ]]; then
254
- log ' you cannot simultaneously enable and disable NFS version 3'
255
- exit 1
269
+ bail ' you cannot simultaneously enable and disable NFS version 3'
256
270
fi
257
271
}
258
272
@@ -261,33 +275,20 @@ assert_nfsd_threads() {
261
275
local -r requested=$( get_reqd_nfsd_threads)
262
276
263
277
if [[ " $requested " -lt 1 ]]; then
264
- log " Please set $ENV_VAR_NFS_SERVER_THREAD_COUNT to a positive value"
265
- exit 1
278
+ bail " please set $ENV_VAR_NFS_SERVER_THREAD_COUNT to a positive value"
266
279
fi
267
280
}
268
281
269
282
assert_kerberos_requirements () {
270
283
271
- if [[ -z " $( is_kerberos_enabled) " ]]; then
272
- return
273
- fi
274
-
275
- if [[ ! -f " $PATH_FILE_ETC_IDMAPD_CONF " ]]; then
276
- log " Please provide $PATH_FILE_ETC_IDMAPD_CONF to the container"
277
- exit 1
278
- fi
284
+ if [[ -n " $( is_kerberos_enabled) " ]]; then
279
285
280
- if [[ ! -f " $PATH_FILE_ETC_KRB5_KEYTAB " ]]; then
281
- log " Please provide $PATH_FILE_ETC_KRB5_KEYTAB to the container"
282
- exit 1
283
- fi
286
+ assert_file_provided " $PATH_FILE_ETC_IDMAPD_CONF "
287
+ assert_file_provided " $PATH_FILE_ETC_KRB5_KEYTAB "
288
+ assert_file_provided " $PATH_FILE_ETC_KRB5_CONF "
284
289
285
- if [[ ! -f " $PATH_FILE_ETC_KRB5_CONF " ]]; then
286
- log " Please provide $PATH_FILE_ETC_KRB5_CONF to the container"
287
- exit 1
290
+ assert_kernel_mod rpcsec_gss_krb5
288
291
fi
289
-
290
- assert_kernel_mod rpcsec_gss_krb5
291
292
}
292
293
293
294
@@ -341,8 +342,7 @@ init_exports() {
341
342
done
342
343
343
344
if [[ $collected -eq 0 ]]; then
344
- log ' no valid exports'
345
- exit 1
345
+ bail ' no valid exports'
346
346
fi
347
347
348
348
log " will export $collected filesystem(s)"
@@ -514,6 +514,7 @@ boot_main_print_ready_message() {
514
514
cat $PATH_FILE_ETC_EXPORTS
515
515
}
516
516
517
+
517
518
# #####################################################################################
518
519
# ## main routines
519
520
# #####################################################################################
0 commit comments