Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task: add check if install.sh was run with root privileges #3069

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ if [[ -n "$MSYSTEM" ]]; then
exit 1
fi

# Check if script was executed with root/sudo
if [ "$(id -u)" -ne 0 ]; then
if [ "$CI" != "true" ]; then
echo "It is recommended to run the script as the root user (by using sudo or as a direct root user) to avoid permission issues. Are you sure you want to continue? [y/n]"
read -r answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
echo "Continuing without sudo. This might cause issues later on."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking of adding something along the lines of "You should know what you're doing as this might cause issues later on". But that might sound a bit demeaning for some people.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, into line 16?

Copy link
Collaborator

@aldy505 aldy505 May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but I don't think that's the proper wording 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to know what you're doing, because this could cause issues later on. ?

else
echo "The script execution was stopped. Please run it again with sudo."
exit
fi
fi
fi


source install/_lib.sh

# Pre-flight. No impact yet.
Expand Down
Loading