Revamp debugging

This commit is contained in:
Muhammad Rivan 2021-06-03 07:52:55 +07:00
parent eb5075aab5
commit 340cf9848f
No known key found for this signature in database
GPG key ID: C56A200FD936FAAA

View file

@ -260,6 +260,29 @@ operation_aborted() {
rm -rf "${WHITESUR_TMP_DIR}"; exit 1 rm -rf "${WHITESUR_TMP_DIR}"; exit 1
} }
rootify() {
trap true SIGINT
prompt -w "Executing '$(echo "${@}" | cut -c -35 )...' as root"
if ! sudo "${@}"; then
error_snippet="${*}"
operation_aborted
fi
trap signal_exit SIGINT
}
userify() {
trap true SIGINT
if ! sudo -u "${MY_USERNAME}" "${@}"; then
error_snippet="${*}"
operation_aborted
fi
trap signal_exit SIGINT
}
trap 'operation_aborted' ERR trap 'operation_aborted' ERR
trap 'signal_exit' INT EXIT TERM trap 'signal_exit' INT EXIT TERM
@ -558,21 +581,9 @@ remind_relative_path() {
} }
############################################################################### ###############################################################################
# SYSTEMS # # MISC #
############################################################################### ###############################################################################
rootify() {
trap true SIGINT
prompt -w "Executing '$(echo "${@}" | cut -c -35 )...' as root"
if ! sudo "${@}"; then
error_snippet="${*}"
operation_aborted
fi
trap signal_exit SIGINT
}
full_rootify() { full_rootify() {
if [[ ! -w "/" ]]; then if [[ ! -w "/" ]]; then
prompt -e "ERROR: '${1}' needs a root priviledge. Please run this '${0}' as root" prompt -e "ERROR: '${1}' needs a root priviledge. Please run this '${0}' as root"
@ -580,17 +591,6 @@ full_rootify() {
fi fi
} }
userify() {
trap true SIGINT
if ! sudo -u "${MY_USERNAME}" "${@}"; then
error_snippet="${*}"
operation_aborted
fi
trap signal_exit SIGINT
}
usage() { usage() {
prompt -e "Usage function is not implemented"; exit 1 prompt -e "Usage function is not implemented"; exit 1
} }