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 1 commit
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
Prev Previous commit
Next Next commit
task: add condition for ci use and add user prompt for install.sh no …
…root warning
  • Loading branch information
LvckyAPI committed May 21, 2024
commit 7ad18eb02190c99e0f41a0934caf992f9f13e5af
15 changes: 12 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ if [[ -n "$MSYSTEM" ]]; then
fi

# Check if script was executed with root/sudo
if [ `id -u` -ne 0 ]
then echo Please run this script as root or using sudo!
exit
if [ "$(id -u)" -ne 0 ]; then
if [ "$CI" != "true" ]; then
echo "You should be using sudo, are you sure you want to continue? [y/n]"
LvckyAPI marked this conversation as resolved.
Show resolved Hide resolved
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