Wait for user input if run_elevated fails
* This is a workaround for su/sudo timeouts * Should help with issue #17
This commit is contained in:
parent
d82ad55113
commit
51f9f91195
1 changed files with 13 additions and 3 deletions
16
Build Linux
16
Build Linux
|
|
@ -32,7 +32,7 @@ fi
|
|||
|
||||
function ask() {
|
||||
while :; do
|
||||
read -p "$1 " -r answer
|
||||
read -p "$1 [Y/N] " -r answer
|
||||
if echo "$answer" | egrep -iq '^(y|yes|sure)$'; then
|
||||
return 0
|
||||
elif echo "$answer" | egrep -iq '^(n|no|nope)$'; then
|
||||
|
|
@ -122,10 +122,20 @@ function run_elevated() {
|
|||
prog="$1"
|
||||
shift
|
||||
if which sudo >/dev/null 2>&1; then
|
||||
sudo "$prog" $*
|
||||
if ! sudo "$prog" $*; then
|
||||
echo "ERROR: Failed to run '$prog'"
|
||||
if ask "Retry?"; then
|
||||
sudo "$prog" $*
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -n "Root "
|
||||
su -c "export REAL_USER=$USER && '$prog' $*"
|
||||
if ! su -c "export REAL_USER=$USER && '$prog' $*"; then
|
||||
echo "ERROR: Failed to run '$prog'"
|
||||
if ask "Retry?"; then
|
||||
su -c "export REAL_USER=$USER && '$prog' $*"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue