mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
rework top-level helpers
This commit is contained in:
parent
a2bc8c4f38
commit
5d3131b494
1 changed files with 12 additions and 16 deletions
|
@ -9,30 +9,26 @@ if [[ -n "${1:-}" ]]; then
|
||||||
elif [[ -n "${YNH_APP_HELPERS_VERSION:-}" ]]; then
|
elif [[ -n "${YNH_APP_HELPERS_VERSION:-}" ]]; then
|
||||||
# ...or as environment variable set from manifest
|
# ...or as environment variable set from manifest
|
||||||
:
|
:
|
||||||
elif [[ -n "${YNH_APP_PACKAGING_FORMAT:-}" ]]; then
|
|
||||||
# ...or default to packaging format version.
|
|
||||||
YNH_APP_HELPERS_VERSION="$YNH_APP_PACKAGING_FORMAT"
|
|
||||||
else
|
else
|
||||||
# ...or default to 1
|
# ...or default to 1
|
||||||
YNH_APP_HELPERS_VERSION=1
|
YNH_APP_HELPERS_VERSION=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
YNH_APP_HELPERS_DIR="$SCRIPT_DIR/helpers.v${YNH_APP_HELPERS_VERSION}.d"
|
|
||||||
if [[ ! -d "$YNH_APP_HELPERS_DIR" ]]; then
|
|
||||||
echo "Helpers are not available in version '$YNH_APP_HELPERS_VERSION'." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# This is a trick to later only restore set -x if it was set when calling this script
|
# This is a trick to later only restore set -x if it was set when calling this script
|
||||||
readonly XTRACE_ENABLE=$(set +o | grep xtrace)
|
readonly XTRACE_ENABLE=$(set +o | grep xtrace)
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
readarray -t HELPERS < <(find "$YNH_APP_HELPERS_DIR" -mindepth 1 -maxdepth 1 -type f)
|
YNH_APP_HELPERS_DIR="$SCRIPT_DIR/helpers.v${YNH_APP_HELPERS_VERSION}.d"
|
||||||
|
case "$YNH_APP_HELPERS_VERSION" in
|
||||||
for helper in "${HELPERS[@]}"; do
|
1)
|
||||||
[ -r "$helper" ] && source "$helper"
|
readarray -t HELPERS < <(find "$YNH_APP_HELPERS_DIR" -mindepth 1 -maxdepth 1 -type f)
|
||||||
done
|
for helper in "${HELPERS[@]}"; do
|
||||||
|
[ -r "$helper" ] && source "$helper"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Helpers are not available in version '$YNH_APP_HELPERS_VERSION'." >&2
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
eval "$XTRACE_ENABLE"
|
eval "$XTRACE_ENABLE"
|
||||||
|
|
Loading…
Add table
Reference in a new issue