Simplified script
This commit is contained in:
parent
368c261a4c
commit
8434e41877
1 changed files with 16 additions and 34 deletions
50
script.sh
50
script.sh
|
|
@ -4,6 +4,7 @@
|
||||||
update_debian_based() {
|
update_debian_based() {
|
||||||
echo "Updating $1..."
|
echo "Updating $1..."
|
||||||
sudo apt-get update && sudo apt-get upgrade -y
|
sudo apt-get update && sudo apt-get upgrade -y
|
||||||
|
sudo apt install -y sudo curl gnupg rsync
|
||||||
echo "Upgrade completed!"
|
echo "Upgrade completed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -11,6 +12,7 @@ update_debian_based() {
|
||||||
update_fedora() {
|
update_fedora() {
|
||||||
echo "Updating Fedora..."
|
echo "Updating Fedora..."
|
||||||
sudo dnf update -y
|
sudo dnf update -y
|
||||||
|
sudo dnf install -y sudo curl gnupg rsync
|
||||||
echo "Upgrade completed!"
|
echo "Upgrade completed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -18,6 +20,7 @@ update_fedora() {
|
||||||
update_centos() {
|
update_centos() {
|
||||||
echo "Updating CentOS..."
|
echo "Updating CentOS..."
|
||||||
sudo yum update -y
|
sudo yum update -y
|
||||||
|
sudo yum install -y sudo curl gnupg rsync
|
||||||
echo "Upgrade completed!"
|
echo "Upgrade completed!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,44 +52,23 @@ case "$DISTRO" in
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Function to create a new user
|
# Ask if user wants to add a new user
|
||||||
create_new_user() {
|
read -p "Do you want to add a new user? (y/n): " add_new_user
|
||||||
echo "Enter the username for the new user: "
|
if [ "$add_new_user" == "y" ]; then
|
||||||
read USERNAME
|
read -p "Enter the username for the new user: " username
|
||||||
|
read -s -p "Enter the password for the new user: " password
|
||||||
# Check if the username already exists
|
echo
|
||||||
if id "$USERNAME" &>/dev/null; then
|
adduser --disabled-password --gecos "" $username
|
||||||
echo "User $USERNAME already exists!"
|
echo "$username:$password" | chpasswd
|
||||||
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
|
|
||||||
else
|
else
|
||||||
echo "No new user will be created."
|
echo "No new user will be created."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Asking if the user wants to install Docker
|
# Ask if user wants to install Docker
|
||||||
echo "Do you want to install Docker & Docker Compose? (y/n): "
|
read -p "Do you want to install Docker? (y/n): " install_docker
|
||||||
read INSTALL_DOCKER
|
if [ "$install_docker" == "y" ]; then
|
||||||
|
|
||||||
if [ "$INSTALL_DOCKER" = "y" ]; then
|
|
||||||
curl -sSL https://get.docker.com | sh
|
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
|
newgrp docker
|
||||||
else
|
|
||||||
echo "Docker won't be installed."
|
|
||||||
fi
|
fi
|
||||||
Loading…
Reference in a new issue