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

[utils/common] Warning when root user is used #241

Merged
merged 1 commit into from
Jan 13, 2025
Merged
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
16 changes: 15 additions & 1 deletion utils/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function delete_log() {
# "root" or "sudo" can run this script, we need to know whom.
function detect_user() {
if [ "$USER_ID" -ne 0 ]; then
echo -e "[$fail_format] This script must be run as root or with sudo\n"
echo -e "[$fail_format] This script must be run as root (not recommended) or with sudo\n"
exit 1
fi

Expand All @@ -61,6 +61,20 @@ function detect_user() {
export RUN_AS="$SUDO_USER"
export RUN_AS_UID="$SUDO_UID"
else
while true; do
echo -e "Best pratices don't recommend running the installer as root user!"
read -rp "Do you really want to continue as you will be on your own? (yes/no) " yn
case $yn in
[Yy]*)
return 0
;;
[Nn]*)
echo -e "\nSmart choice! Exiting the installer..."
exit 1
;;
*) echo -e "Please answer (y)es or (n)o." ;;
esac
done
# root user
export RUN_AS="$USER"
export RUN_AS_UID="$EUID"
Expand Down
Loading