Advertisement
Guest User

script

a guest
Dec 28th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.14 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.     while [ x$username = "x" ]; do
  4.  
  5.     read -p "Podaj nazwę nowego użytkownika : " username
  6.  
  7.     if id -u $username >/dev/null 2>&1; then
  8.  
  9.     echo "Taki użytkownik już istnieje"
  10.  
  11.     username=""
  12.  
  13.     fi
  14.  
  15.     done
  16.    
  17.     while [ x$group = "x" ]; do
  18.  
  19.     read -p "Podaj grupę domyślną, jeżeli grupa nie istnieje, zostanie utworzona : " group
  20.  
  21.     if id -g $group >/dev/null 2>&1; then
  22.  
  23.     echo "Grupa istnieje"
  24.  
  25.     else
  26.  
  27.     groupadd $group
  28.  
  29.     fi
  30.  
  31.     done
  32.  
  33.     read -p "Podaj katalog domowy [/home/$group/$username] : " homedir
  34.  
  35.     if [ x"$homedir" = "x" ]; then
  36.  
  37.     homedir="/home/$group/$username"
  38.  
  39.     fi
  40.    
  41.     read -p "Podaj powłokę [/bin/bash] : " bash
  42.  
  43.     if [ x"$bash" = "x" ]; then
  44.    
  45.     bash="/bin/bash"
  46.  
  47.     fi
  48.    
  49.     read -p "Podaj UID :" ajdi
  50.  
  51.     read -p "Domyślne hasło dla użytkownika login: $username pass: $username - Potwierdź [y/n]" confirm
  52.    
  53.     if [ "$confirm" = "y" ]; then
  54.    
  55.     useradd -u $ajdi -g $group -s $bash -d $homedir -m $username -f 1
  56.     echo -e "$username\n$username" | passwd $username  
  57.     passwd -e -w 5 -x 60 $username
  58.    
  59.     fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement