Improve stability

This commit is contained in:
Muhammad Rivan 2021-06-12 10:25:56 +07:00
parent 9dd112f1b0
commit fd2c80cc89
No known key found for this signature in database
GPG key ID: C56A200FD936FAAA
2 changed files with 9 additions and 11 deletions

View file

@ -21,7 +21,7 @@ WHITESUR_SOURCE=("lib-core.sh")
#--------------System--------------#
export WHITESUR_PID=$$
MY_USERNAME="$(logname || echo ${SUDO_USER:-${USER}})"
MY_USERNAME="$(logname 2> /dev/null || echo ${SUDO_USER:-${USER}})"
if command -v gnome-shell &> /dev/null; then
if (( $(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f 1) >= 4 )); then
@ -629,13 +629,11 @@ sudo() {
fi
if [[ -p /dev/stdin ]]; then
${SUDO_BIN} "${@}" < /dev/stdin
${SUDO_BIN} "${@}" < /dev/stdin || result="${?}"
else
${SUDO_BIN} "${@}"
${SUDO_BIN} "${@}" || result="${?}"
fi
result="${?}"
[[ "${result}" != "0" ]] && WHITESUR_COMMAND="${*}"
return "${result}"
@ -651,13 +649,11 @@ udo() {
fi
if [[ -p /dev/stdin ]]; then
${SUDO_BIN} -u "${MY_USERNAME}" "${@}" < /dev/stdin
${SUDO_BIN} -u "${MY_USERNAME}" "${@}" < /dev/stdin || result="${?}"
else
${SUDO_BIN} -u "${MY_USERNAME}" "${@}"
${SUDO_BIN} -u "${MY_USERNAME}" "${@}" || result="${?}"
fi
result="${?}"
[[ "${result}" != "0" ]] && WHITESUR_COMMAND="${*}"
return "${result}"

View file

@ -112,9 +112,11 @@ install_swupd_packages() {
}
prepare_install_apt_packages() {
sudo apt update -y; sudo apt install -y "${@}"
local status="1"
if [[ "${?}" == "100" ]]; then
sudo apt update -y; sudo apt install -y "${@}" || status="${?}"
if [[ "${status}" == "100" ]]; then
prompt -w "\n APT: Your repo lists might be broken"
prompt -i "APT: Full-cleaning your repo lists and try again...\n"
sudo apt clean -y; sudo rm -rf /var/lib/apt/lists