Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
fix the root check function
Browse files Browse the repository at this point in the history
  • Loading branch information
snwh committed May 21, 2018
1 parent f6f8e22 commit ebdc1ba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions data/gnome-apps.list
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ gnome-software
gnome-system-monitor
gnome-terminal
gnome-todo
gnome-usage
gnome-weather
2 changes: 0 additions & 2 deletions data/purge.list
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
activity-log-manager
aisleriot
deja-dup
gnome-mahjongg
gnome-mines
gnome-sudoku
Expand All @@ -12,6 +11,5 @@ shotwell
thunderbird
ubuntu-web-launchers
unity-*
usb-creator-gtk
webbrowser-app
xdiagnose
31 changes: 26 additions & 5 deletions functions/check_functions
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function check_dependencies {
# Positive action
[Yy]* )
echo_message warning "Requires root privileges"
sudo dnf -y install $PACKAGE
sudo apt -y install $PACKAGE
echo_message success "Package '$PACKAGE' installed."
;;
# Negative action
Expand Down Expand Up @@ -172,11 +172,32 @@ function check_privileges {
echo_message success "Current user has sudo privileges. :)"
fi
else
if (whiptail --title "Root User" --yesno "You are logged in as the root user. This is not recommended.\n\nAre you sure you want to proceed?" 8 56) then
echo_message warning "You are logged in as the root user. This is not recommended. :/"
# if dependency whiptail is installed
if command -v whiptail 2>&1 >/dev/null; then
# draw window
if (whiptail --title "Root User" --yesno "You are logged in as the root user. This is not recommended.\n\nAre you sure you want to proceed?" 12 56) then
echo_message warning "You are logged in as the root user. This is not recommended. :/"
else
echo_message info "Exiting..."
exit 99
fi
else
echo_message info "Exiting..."
exit 99
# text-based warning
echo_message warning "You are logged in as the root user. This is not recommended. :/"
read -p "Are you sure you want to proceed? [y/N] " REPLY
REPLY=${REPLY:-n}
case $REPLY in
[Yy]* )
echo_message info "Proceeding..."
;;
[Nn]* )
echo_message info "Exiting..."
exit 99
;;
* )
echo_message error 'Sorry, try again.' && check_privileges
;;
esac
fi
fi
}
Expand Down
2 changes: 1 addition & 1 deletion ubuntu-post-install-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function quit {
echo_message header "Starting 'quit' function"
echo_message title "Exiting $TITLE..."
# Draw window
if (whiptail --title "Quit" --yesno "Are you sure you want quit?" 10 60) then
if (whiptail --title "Quit" --yesno "Are you sure you want quit?" 8 56) then
echo_message welcome 'Thanks for using!'
exit 99
else
Expand Down

0 comments on commit ebdc1ba

Please sign in to comment.