Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- while [ x$username = "x" ]; do
- read -p "Podaj nazwę nowego użytkownika : " username
- if id -u $username >/dev/null 2>&1; then
- echo "Taki użytkownik już istnieje"
- username=""
- fi
- done
- while [ x$group = "x" ]; do
- read -p "Podaj grupę domyślną, jeżeli grupa nie istnieje, zostanie utworzona : " group
- if id -g $group >/dev/null 2>&1; then
- echo "Grupa istnieje"
- else
- groupadd $group
- fi
- done
- read -p "Podaj katalog domowy [/home/$group/$username] : " homedir
- if [ x"$homedir" = "x" ]; then
- homedir="/home/$group/$username"
- fi
- read -p "Podaj powłokę [/bin/bash] : " bash
- if [ x"$bash" = "x" ]; then
- bash="/bin/bash"
- fi
- read -p "Podaj UID :" ajdi
- read -p "Domyślne hasło dla użytkownika login: $username pass: $username - Potwierdź [y/n]" confirm
- if [ "$confirm" = "y" ]; then
- useradd -u $ajdi -g $group -s $bash -d $homedir -m $username -f 1
- echo -e "$username\n$username" | passwd $username
- passwd -e -w 5 -x 60 $username
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement