Ubuntu Pastebin

Paste from ezethnesthrown at Sat, 13 May 2017 02:28:08 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# This is not the first line
# The problem here is at prompting for passwords
# After agreeing to reenter password, it auto-agree the next reenter
# It doesn't happen with reentering username

#!/bin/bash
#if [[ $EUID -ne 0 ]]; then
#   echo "This script must be run as root"
#   exit 1
#fi

username=""
group=""
passworda="a"
passwordb="b"

echo "This script is only for creating an account"
echo ""
echo "Creating a user for Samba"
until [ "$username" != "" ]; do
   read -p "Username: " username
   if getent passwd $username > /dev/null; then
      echo ""
      echo "That username has been taken"
      echo -e "Would you like to reenter another username? [y/n] "
      until [[ $REPLY =~ ^[Yy]$ || $REPLY =~ ^[Nn]$ ]]; do
         read -rs -n 1 
         if [[ $REPLY =~ ^[Yy]$ ]]; then
            echo ""
            username=""
         elif [[ $REPLY =~ ^[Nn]$ ]]; then
            exit 1
         fi
      done
   fi
done


until [ "$passworda" == "$passwordb" ]; do
   read -s -p "Password: " passworda
   echo ""
   read -s -p "Retype password: " passwordb
   echo ""
   if [ "$passworda" != "$passwordb" ]; then
      echo ""
      echo "Password mismatched"
      echo -e "Would you like to reenter your password? [y/n] "
      until [[ $REPLY =~ ^[Yy]$ || $REPLY =~ ^[Nn]$ ]]; do
         read -rs -n 1 
         if [[ $REPLY =~ ^[Yy]$ ]]; then
            echo ""
            unset $REPLY
         elif [[ $REPLY =~ ^[Nn]$ ]]; then
            exit 1
         fi
      done
   fi
done

echo ""
echo ""
echo "Username entered $username"
echo "Password entered $passworda"
echo "Password entered $passwordb"
Download as text