I'm trying to create a shell script that ask for user input. If the user exist it lets you know; if the user doesn't exist it creates the user and password and adds them to a group. However, I am stuck and am hoping someone can assist. It seems to stop after it reads the response and doesn't execute the if/then
Here is what I have so far:
#!/bin/bash
echo "Which user would you like to use docker? "
read -r user
getent passwd "$user" > /dev/null 2&>1 && echo yes || echo no
read -r response
if [ "$response" == "yes" ];then
echo " User already exist"
if [ "$response" == "no" ];then
useradd -m $user
passwd $user
usermod -aG docker $user
fi
fi
Aucun commentaire:
Enregistrer un commentaire