diff --git a/script.sh b/script.sh index 0da5f3f..a3bc497 100644 --- a/script.sh +++ b/script.sh @@ -4,6 +4,7 @@ update_debian_based() { echo "Updating $1..." sudo apt-get update && sudo apt-get upgrade -y + sudo apt install -y sudo curl gnupg rsync echo "Upgrade completed!" } @@ -11,6 +12,7 @@ update_debian_based() { update_fedora() { echo "Updating Fedora..." sudo dnf update -y + sudo dnf install -y sudo curl gnupg rsync echo "Upgrade completed!" } @@ -18,6 +20,7 @@ update_fedora() { update_centos() { echo "Updating CentOS..." sudo yum update -y + sudo yum install -y sudo curl gnupg rsync echo "Upgrade completed!" } @@ -49,44 +52,23 @@ case "$DISTRO" in exit 1 esac -# Function to create a new user -create_new_user() { - echo "Enter the username for the new user: " - read USERNAME - - # Check if the username already exists - if id "$USERNAME" &>/dev/null; then - echo "User $USERNAME already exists!" - create_new_user - else - echo "Enter the password for the new user: " - read -s PASSWORD - - # Create the user and set the password - sudo useradd -m "$USERNAME" - echo "$USERNAME:$PASSWORD" | sudo chpasswd - echo "User $USERNAME created successfully!" - fi -} - -# Asking if the user wants to create a new user -echo "Do you want to create a new user? (y/n): " -read CREATE_USER - -if [ "$CREATE_USER" = "y" ]; then - create_new_user +# Ask if user wants to add a new user +read -p "Do you want to add a new user? (y/n): " add_new_user +if [ "$add_new_user" == "y" ]; then + read -p "Enter the username for the new user: " username + read -s -p "Enter the password for the new user: " password + echo + adduser --disabled-password --gecos "" $username + echo "$username:$password" | chpasswd else echo "No new user will be created." fi -# Asking if the user wants to install Docker -echo "Do you want to install Docker & Docker Compose? (y/n): " -read INSTALL_DOCKER - -if [ "$INSTALL_DOCKER" = "y" ]; then +# Ask if user wants to install Docker +read -p "Do you want to install Docker? (y/n): " install_docker +if [ "$install_docker" == "y" ]; then curl -sSL https://get.docker.com | sh - sudo usermod -aG docker $(whoami) + echo "Docker has been installed. Adding newly created user to Docker group..." + usermod -aG docker $username newgrp docker -else - echo "Docker won't be installed." fi \ No newline at end of file