Skip to content

Commit c6380b5

Browse files
committed
ADDED: Dynamic unload of data from features, fixed #46
1 parent 07e68d7 commit c6380b5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/core/functions_common.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,42 @@ load_feature_properties()
276276
fi
277277
}
278278

279+
280+
# - Description: Unloads properties loaded from the ${FEATURE_KEYNAME}.dat.sh and functions from the
281+
# ${FEATURE_KEYNAME}.func.sh
282+
# - Permissions: Can be executed indifferently as root or user.
283+
# - Argument 1: Keyname of the properties to unload.
284+
unload_feature_properties()
285+
{
286+
# Unload functions
287+
unset -f "$1_install_pre"
288+
unset -f "$1_install_mid"
289+
unset -f "$1_install_post"
290+
unset -f "$1_uninstall_pre"
291+
unset -f "$1_uninstall_mid"
292+
unset -f "$1_uninstall_post"
293+
294+
# Unload properties from the .dat.sh
295+
if [ -f "${CUSTOMIZER_PROJECT_FOLDER}/data/features/$1/$1.dat.sh" ]; then
296+
# Select non-commentary lines
297+
while read -r line; do
298+
local variable
299+
variable="$(echo "${line}" | grep -v "^[[:blank:]]*#" | cut -d "=" -f1)"
300+
if [ -z "${variable}" ]; then
301+
continue
302+
fi
303+
unset "${variable}"
304+
done < "${CUSTOMIZER_PROJECT_FOLDER}/data/features/$1/$1.dat.sh"
305+
else
306+
output_proxy_executioner "Properties of $1 feature have not been found, so they can not be unloaded. The file
307+
${CUSTOMIZER_PROJECT_FOLDER}/data/features/$1/$1.dat.sh does not exist. " "ERROR"
308+
fi
309+
310+
# Finally unset ${FEATURENAME}_flagsruntime, which is a dynamically declared variable
311+
unset "$1_flagsruntime"
312+
}
313+
314+
279315
# - Description: Performs a post-install clean by using cleaning option of package manager
280316
# - Permission: Can be called as root or user.
281317
post_install_clean()
@@ -903,6 +939,9 @@ execute_installation()
903939
load_feature_properties "${CURRENT_INSTALLATION_KEYNAME}"
904940

905941
output_proxy_executioner "generic_installation ${keyname}" "COMMAND"
942+
943+
unload_feature_properties "${CURRENT_INSTALLATION_KEYNAME}"
944+
906945
output_proxy_executioner "${keyname} ${FLAG_MODE}ed." "INFO"
907946

908947
# Return flag errors to bash defaults (ignore errors)

0 commit comments

Comments
 (0)