mirror of
https://github.com/the-sane/lug-helper.git
synced 2025-01-16 05:40:37 +00:00
Compare commits
5 Commits
0de4032a41
...
2dd9b51ab1
Author | SHA1 | Date | |
---|---|---|---|
|
2dd9b51ab1 | ||
|
dd9bfc3351 | ||
|
b009265951 | ||
|
394cfa9392 | ||
|
5b2e202b4f |
@ -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 arguments
|
# This function expects one string argument
|
||||||
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,19 +245,25 @@ try_exec() {
|
|||||||
if [ -x "$(command -v pkexec)" ]; then
|
if [ -x "$(command -v pkexec)" ]; then
|
||||||
pkexec sh -c "$1"
|
pkexec sh -c "$1"
|
||||||
|
|
||||||
# Check the return value
|
# Check the exit status
|
||||||
if [ "$?" -eq 126 ] || [ "$?" -eq 127 ]; then
|
statuscode="$?"
|
||||||
|
if [ "$statuscode" -eq 126 ] || [ "$statuscode" -eq 127 ]; then
|
||||||
# User cancel or error
|
# User cancel or error
|
||||||
retval=1
|
retval=1
|
||||||
fi
|
fi
|
||||||
else
|
elif [ -x "$(command -v sudo)" ]; then
|
||||||
sudo sh -c "$1"
|
sudo sh -c "$1"
|
||||||
|
|
||||||
# Check the return value
|
# Check the exit status
|
||||||
if [ "$?" -eq 1 ]; then
|
statuscode="$?"
|
||||||
|
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"
|
||||||
@ -2074,7 +2080,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 "Something went wrong. Unable to modify /etc/hosts.\n\nReturning to main menu."
|
message info "Authentication failed or there was an error modifying /etc/hosts.\nSee terminal for more information.\n\nReturning to main menu."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user