Skip to content

Commit

Permalink
Corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Lord-Grey committed Jan 20, 2024
1 parent 2df171e commit 0a42cdc
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,22 @@ function get_distro() {
function sudocmd() {
reason="$1"; shift
if command -v sudo >/dev/null; then
echo
echo "About to use 'sudo' to run the following command as root:"
echo " $@"
echo "in order to $reason."
echo
sudo "$@"
# Check if sudo is required for the command
sudoRequired=$(sudo -l "$@" 2>/dev/null)
if [ $? -eq 0 ]; then
echo
echo "About to use 'sudo' to run the following command as root:"
echo " $@"
echo "in order to $reason."
echo
sudo "$@"
else
echo
echo "Running the following command without 'sudo' since elevated privileges are not required:"
echo " $@"
echo
"$@"
fi
else
"$@"
fi
Expand Down Expand Up @@ -177,7 +187,7 @@ Suites: ${suites}
Architectures: ${architectures}
Signed-By: /etc/apt/keyrings/hyperion.pub.gpg"

if ! sudocmd "add Hyperion Project repository to the system" tee "/etc/apt/sources.list.d/hyperion.sources" <<< "$DEB822"; then
if ! sudocmd "add Hyperion Project repository to the system" echo "$DEB822" | sudo tee "/etc/apt/sources.list.d/hyperion.sources"; then
error "Failed to add the Hyperion Project Repository. Please run 'apt-get update' and try again."
fi

Expand Down

0 comments on commit 0a42cdc

Please sign in to comment.