mirror of
https://github.com/the-sane/lug-helper.git
synced 2025-01-16 05:20:38 +00:00
Compare commits
No commits in common. "2dd9b51ab15b5ba04de7a3c5007192aedbd39732" and "0de4032a41fd2397f2d4ecbb8ef8885884bb7f3b" have entirely different histories.
2dd9b51ab1
...
0de4032a41
@ -233,7 +233,7 @@ debug_print() {
|
|||||||
# Try to execute a supplied command as root
|
# Try to execute a supplied command as root
|
||||||
# Expects one string argument
|
# Expects one string argument
|
||||||
try_exec() {
|
try_exec() {
|
||||||
# This function expects one string argument
|
# This function expects one string arguments
|
||||||
if [ "$#" -lt 1 ]; then
|
if [ "$#" -lt 1 ]; then
|
||||||
printf "\nScript error: The try_exec() function expects an argument. Aborting.\n"
|
printf "\nScript error: The try_exec() function expects an argument. Aborting.\n"
|
||||||
read -n 1 -s -p "Press any key..."
|
read -n 1 -s -p "Press any key..."
|
||||||
@ -245,25 +245,19 @@ try_exec() {
|
|||||||
if [ -x "$(command -v pkexec)" ]; then
|
if [ -x "$(command -v pkexec)" ]; then
|
||||||
pkexec sh -c "$1"
|
pkexec sh -c "$1"
|
||||||
|
|
||||||
# Check the exit status
|
# Check the return value
|
||||||
statuscode="$?"
|
if [ "$?" -eq 126 ] || [ "$?" -eq 127 ]; then
|
||||||
if [ "$statuscode" -eq 126 ] || [ "$statuscode" -eq 127 ]; then
|
|
||||||
# User cancel or error
|
# User cancel or error
|
||||||
retval=1
|
retval=1
|
||||||
fi
|
fi
|
||||||
elif [ -x "$(command -v sudo)" ]; then
|
else
|
||||||
sudo sh -c "$1"
|
sudo sh -c "$1"
|
||||||
|
|
||||||
# Check the exit status
|
# Check the return value
|
||||||
statuscode="$?"
|
if [ "$?" -eq 1 ]; then
|
||||||
if [ "$statuscode" -eq 1 ]; then
|
|
||||||
# Error
|
# Error
|
||||||
retval=1
|
retval=1
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# We don't know how to perform this operation with elevated privileges
|
|
||||||
printf "\nNeither Polkit nor sudo appear to be installed. Unable to execute the command with the required privileges.\n"
|
|
||||||
retval=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return "$retval"
|
return "$retval"
|
||||||
@ -2080,7 +2074,7 @@ eac_workaround() {
|
|||||||
# Try to modify /etc/hosts as root
|
# Try to modify /etc/hosts as root
|
||||||
try_exec "printf '\n$eac_hosts #Star Citizen EAC workaround\n' >> /etc/hosts"
|
try_exec "printf '\n$eac_hosts #Star Citizen EAC workaround\n' >> /etc/hosts"
|
||||||
if [ "$?" -eq 1 ]; then
|
if [ "$?" -eq 1 ]; then
|
||||||
message info "Authentication failed or there was an error modifying /etc/hosts.\nSee terminal for more information.\n\nReturning to main menu."
|
message info "Something went wrong. Unable to modify /etc/hosts.\n\nReturning to main menu."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user