Improve error handling in autoinstall run
This commit is contained in:
parent
e81f5ab4da
commit
aed681d0b0
1 changed files with 39 additions and 37 deletions
|
@ -4,7 +4,7 @@ group=${args[group]:?}
|
|||
file=${args[--file]:-}
|
||||
clean=${args[--clean]:-}
|
||||
|
||||
_handle_entry() {
|
||||
_install_entry() {
|
||||
type="$1"
|
||||
source="$2"
|
||||
target="$3"
|
||||
|
@ -30,19 +30,49 @@ _handle_entry() {
|
|||
install_args+=("--completions=$completions")
|
||||
fi
|
||||
|
||||
if [[ $source = \$* ]]
|
||||
then
|
||||
source=$(eval "echo $source")
|
||||
fi
|
||||
install_args+=("$source")
|
||||
|
||||
install_args+=("$(eval "echo $target")")
|
||||
install_args+=("$target")
|
||||
|
||||
"$0" "${install_args[@]}"
|
||||
}
|
||||
|
||||
_handle_entry() {
|
||||
unset AUTOINSTALL_ITEM_TYPE \
|
||||
AUTOINSTALL_ITEM_SOURCE \
|
||||
AUTOINSTALL_ITEM_TARGET \
|
||||
AUTOINSTALL_ITEM_HOOK \
|
||||
AUTOINSTALL_ITEM_PIPE \
|
||||
AUTOINSTALL_ITEM_COMPLETIONS \
|
||||
AUTOINSTALL_ITEM_GROUPS
|
||||
|
||||
eval "$1"
|
||||
|
||||
# check if we have the required vars
|
||||
if [[ -z "${AUTOINSTALL_ITEM_TYPE:-}" \
|
||||
|| -z "${AUTOINSTALL_ITEM_SOURCE:-}" \
|
||||
|| -z "${AUTOINSTALL_ITEM_TARGET:-}" \
|
||||
|| -z "${AUTOINSTALL_ITEM_GROUPS:-}" ]]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$group" != "all" ]]
|
||||
then
|
||||
# check if group is in groups
|
||||
if [[ ! "${AUTOINSTALL_ITEM_GROUPS}" =~ (^|,)$group(,|$) ]]
|
||||
then
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
_install_entry "$AUTOINSTALL_ITEM_TYPE" "$AUTOINSTALL_ITEM_SOURCE" \
|
||||
"$AUTOINSTALL_ITEM_TARGET" "${AUTOINSTALL_ITEM_HOOK:-}" "${AUTOINSTALL_ITEM_PIPE:-}" "${AUTOINSTALL_ITEM_COMPLETIONS:-}"
|
||||
|
||||
"$0" "${install_args[@]}" || true # Continue on error
|
||||
}
|
||||
|
||||
file_lines=$(wc -l < "$file")
|
||||
line=0
|
||||
line=129
|
||||
while [[ $line -lt $file_lines ]]; do
|
||||
entry=$(tail -n +$line "$file" | awk '/^$/{exit} {print} ')
|
||||
entry_len=$(echo "$entry" | wc -l)
|
||||
|
@ -52,33 +82,5 @@ while [[ $line -lt $file_lines ]]; do
|
|||
continue
|
||||
fi
|
||||
|
||||
unset AUTOINSTALL_ITEM_TYPE \
|
||||
AUTOINSTALL_ITEM_SOURCE \
|
||||
AUTOINSTALL_ITEM_TARGET \
|
||||
AUTOINSTALL_ITEM_HOOK \
|
||||
AUTOINSTALL_ITEM_PIPE \
|
||||
AUTOINSTALL_ITEM_COMPLETIONS \
|
||||
AUTOINSTALL_ITEM_GROUPS
|
||||
eval "$entry"
|
||||
|
||||
# check if we have the required vars
|
||||
if [[ -z "${AUTOINSTALL_ITEM_TYPE:-}" \
|
||||
|| -z "${AUTOINSTALL_ITEM_SOURCE:-}" \
|
||||
|| -z "${AUTOINSTALL_ITEM_TARGET:-}" \
|
||||
|| -z "${AUTOINSTALL_ITEM_GROUPS:-}" ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$group" != "all" ]]
|
||||
then
|
||||
# check if group is in groups
|
||||
if [[ ! "${AUTOINSTALL_ITEM_GROUPS}" =~ (^|,)$group(,|$) ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
_handle_entry "$AUTOINSTALL_ITEM_TYPE" "$AUTOINSTALL_ITEM_SOURCE" \
|
||||
"$AUTOINSTALL_ITEM_TARGET" "${AUTOINSTALL_ITEM_HOOK:-}" "${AUTOINSTALL_ITEM_PIPE:-}" "${AUTOINSTALL_ITEM_COMPLETIONS:-}"
|
||||
_handle_entry "$entry" || true # ignore errors
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue