Skip to content

Commit

Permalink
chore: update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
janosmiko committed Oct 25, 2024
1 parent d6f0af0 commit d7cac15
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,30 @@ error() {
# color red
printf "\033[1;31m%s ERROR: %s\033[0m\n" "$(date --iso-8601=seconds)" "$*" >&2

stacktrace 2

if [[ "${exitcode}" -eq 0 ]]; then exit 1; fi
exit "${exitcode}"
}

stacktrace() {
local i=1 line file func
if [[ ${1:-0} -gt 0 ]]; then
i=$1
fi

counter=1
while read -r line func file < <(caller $i); do
echo >&2 "[${counter}] ${file}:${line} ${func}(): $(sed -n ${line}p ${file})"
((counter++))
((i++))
done
}

# Print error messages and exit with the command that failed
trapinfo() {
IFS=":"
# shellcheck disable=SC2145
error "A command has failed. Exiting the script. STATUS=($?) COMMAND=($BASH_COMMAND) BASH_LINENO=($0:${@:1:$(($# - 1))}) $(sed -n "$1p" "${BASH_SOURCE[0]}")"
error "A command has failed. Exiting the script. COMMAND=($BASH_COMMAND) STATUS=($?)"
}

lock_acquire() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,30 @@ error() {
# color red
printf "\033[1;31m%s ERROR: %s\033[0m\n" "$(date --iso-8601=seconds)" "$*" >&2

stacktrace 2

if [[ "${exitcode}" -eq 0 ]]; then exit 1; fi
exit "${exitcode}"
}

stacktrace() {
local i=1 line file func
if [[ ${1:-0} -gt 0 ]]; then
i=$1
fi

counter=1
while read -r line func file < <(caller $i); do
echo >&2 "[${counter}] ${file}:${line} ${func}(): $(sed -n ${line}p ${file})"
((counter++))
((i++))
done
}

# Print error messages and exit with the command that failed
trapinfo() {
IFS=":"
# shellcheck disable=SC2145
error "A command has failed. Exiting the script. STATUS=($?) COMMAND=($BASH_COMMAND) BASH_LINENO=($0:${@:1:$(($# - 1))}) $(sed -n "$1p" "${BASH_SOURCE[0]}")"
error "A command has failed. Exiting the script. COMMAND=($BASH_COMMAND) STATUS=($?)"
}

lock_acquire() {
Expand Down
19 changes: 17 additions & 2 deletions images/php-fpm-rootless/wordpress-web/context/rootfs/home/www-data/.local/bin/functions.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,30 @@ error() {
# color red
printf "\033[1;31m%s ERROR: %s\033[0m\n" "$(date --iso-8601=seconds)" "$*" >&2

stacktrace 2

if [[ "${exitcode}" -eq 0 ]]; then exit 1; fi
exit "${exitcode}"
}

stacktrace() {
local i=1 line file func
if [[ ${1:-0} -gt 0 ]]; then
i=$1
fi

counter=1
while read -r line func file < <(caller $i); do
echo >&2 "[${counter}] ${file}:${line} ${func}(): $(sed -n ${line}p ${file})"
((counter++))
((i++))
done
}

# Print error messages and exit with the command that failed
trapinfo() {
IFS=":"
# shellcheck disable=SC2145
error "A command has failed. Exiting the script. STATUS=($?) COMMAND=($BASH_COMMAND) BASH_LINENO=($0:${@:1:$(($# - 1))}) $(sed -n "$1p" "${BASH_SOURCE[0]}")"
error "A command has failed. Exiting the script. COMMAND=($BASH_COMMAND) STATUS=($?)"
}

lock_acquire() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,30 @@ error() {
# color red
printf "\033[1;31m%s ERROR: %s\033[0m\n" "$(date --iso-8601=seconds)" "$*" >&2

stacktrace 2

if [[ "${exitcode}" -eq 0 ]]; then exit 1; fi
exit "${exitcode}"
}

stacktrace() {
local i=1 line file func
if [[ ${1:-0} -gt 0 ]]; then
i=$1
fi

counter=1
while read -r line func file < <(caller $i); do
echo >&2 "[${counter}] ${file}:${line} ${func}(): $(sed -n ${line}p ${file})"
((counter++))
((i++))
done
}

# Print error messages and exit with the command that failed
trapinfo() {
IFS=":"
# shellcheck disable=SC2145
error "A command has failed. Exiting the script. STATUS=($?) COMMAND=($BASH_COMMAND) BASH_LINENO=($0:${@:1:$(($# - 1))}) $(sed -n "$1p" "${BASH_SOURCE[0]}")"
error "A command has failed. Exiting the script. COMMAND=($BASH_COMMAND) STATUS=($?)"
}

lock_acquire() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,30 @@ error() {
# color red
printf "\033[1;31m%s ERROR: %s\033[0m\n" "$(date --iso-8601=seconds)" "$*" >&2

stacktrace 2

if [[ "${exitcode}" -eq 0 ]]; then exit 1; fi
exit "${exitcode}"
}

stacktrace() {
local i=1 line file func
if [[ ${1:-0} -gt 0 ]]; then
i=$1
fi

counter=1
while read -r line func file < <(caller $i); do
echo >&2 "[${counter}] ${file}:${line} ${func}(): $(sed -n ${line}p ${file})"
((counter++))
((i++))
done
}

# Print error messages and exit with the command that failed
trapinfo() {
IFS=":"
# shellcheck disable=SC2145
error "A command has failed. Exiting the script. STATUS=($?) COMMAND=($BASH_COMMAND) BASH_LINENO=($0:${@:1:$(($# - 1))}) $(sed -n "$1p" "${BASH_SOURCE[0]}")"
error "A command has failed. Exiting the script. COMMAND=($BASH_COMMAND) STATUS=($?)"
}

lock_acquire() {
Expand Down
19 changes: 17 additions & 2 deletions images/php-fpm/wordpress-web/context/rootfs/usr/local/bin/functions.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,30 @@ error() {
# color red
printf "\033[1;31m%s ERROR: %s\033[0m\n" "$(date --iso-8601=seconds)" "$*" >&2

stacktrace 2

if [[ "${exitcode}" -eq 0 ]]; then exit 1; fi
exit "${exitcode}"
}

stacktrace() {
local i=1 line file func
if [[ ${1:-0} -gt 0 ]]; then
i=$1
fi

counter=1
while read -r line func file < <(caller $i); do
echo >&2 "[${counter}] ${file}:${line} ${func}(): $(sed -n ${line}p ${file})"
((counter++))
((i++))
done
}

# Print error messages and exit with the command that failed
trapinfo() {
IFS=":"
# shellcheck disable=SC2145
error "A command has failed. Exiting the script. STATUS=($?) COMMAND=($BASH_COMMAND) BASH_LINENO=($0:${@:1:$(($# - 1))}) $(sed -n "$1p" "${BASH_SOURCE[0]}")"
error "A command has failed. Exiting the script. COMMAND=($BASH_COMMAND) STATUS=($?)"
}

lock_acquire() {
Expand Down

0 comments on commit d7cac15

Please sign in to comment.