mirror of
https://github.com/bckelley/mybash.git
synced 2026-08-24 03:24:09 -05:00
delete grant_sudo_permissions -> for check_root
This commit is contained in:
@@ -9,31 +9,13 @@ command_exists() {
|
|||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
## Function to grant sudo permissions to the current user
|
check_root() {
|
||||||
grant_sudo_permissions() {
|
if [ "$(id -u)" != "0" ]; then
|
||||||
echo "Granting sudo permissions to user ${USER}"
|
echo -e "${RED}This script must be run as root.${RC}" 1>&2
|
||||||
sudo usermod -aG sudo "${USER}"
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
echo -e "${GREEN}Sudo permissions granted to user ${USER}.${RC}"
|
|
||||||
else
|
|
||||||
echo -e "${RED}Failed to grant sudo permissions.${RC}"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if the user is in the sudo group
|
|
||||||
if ! id -nG "${USER}" | grep -qw "sudo"; then
|
|
||||||
if [ "$EUID" -ne 0 ]; then
|
|
||||||
echo "This script needs sudo privileges to add the user to the sudo group."
|
|
||||||
echo "Please enter the sudo password to proceed."
|
|
||||||
grant_sudo_permissions
|
|
||||||
else
|
|
||||||
echo "User ${USER} is already in the sudo group."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "User ${USER} is already in the sudo group."
|
|
||||||
fi
|
|
||||||
|
|
||||||
checkEnv() {
|
checkEnv() {
|
||||||
## Check for requirements.
|
## Check for requirements.
|
||||||
REQUIREMENTS='curl groups sudo'
|
REQUIREMENTS='curl groups sudo'
|
||||||
|
|||||||
Reference in New Issue
Block a user