-
Notifications
You must be signed in to change notification settings - Fork 1
/
netminUser
117 lines (108 loc) · 2.49 KB
/
netminUser
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
clear
tput cup 1 20
echo '-----------------------------------------------------'
tput cup 2 20
echo '| 1. Users List |'
tput cup 3 20
echo '| 2. Edit User |'
tput cup 4 20
echo '| 3. Change Password |'
tput cup 5 20
echo '| 4. Create User |'
tput cup 6 20
echo '| 5. Delete User |'
tput cup 7 20
echo '-----------------------------------------------------'
tput cup 8 20
echo
tput cup 9 20
echo -n 'Enter Choice : '
read choice
case $choice in
1) clear
cat /etc/passwd | more
sleep 3
clear
tput cup 10 20
echo 'Press Enter to return to Main menu . . .'
read ;;
2) clear
tput cup 10 20
echo 'First press Esc, then type :wq to Exit !'
vim /etc/passwd
tput cup 10 20
echo 'Press Enter to Return to Main menu . . .'
read ;;
3) clear
tput cup 10 20
echo -n 'Enter User Name : '
read name
tput cup 11 20
echo -n 'Enter New password for $name : '
stty -echo
read pass
stty sane
tput cup 12 20
echo $pass | passwd -S --stdin $name
tput cup 14 30
echo 'Press Enter to return Main menu . . .'
read ;;
4) clear
tput cup 10 20
echo -n 'Enter User Name : '
read user
if `grep $user /etc/passwd >> /dev/null`
then
tput cup 11 20
echo 'User already exists !'
else
tput cup 11 20
read -s -p "Enter Password : " pass
useradd -p $pass $user
tput cup 12 20
echo "$user was added successfully :) "
fi
tput cup 14 20
echo 'Press Enter to return to Main menu . . .'
read ;;
5) clear
tput cup 10 20
echo -n 'Enter User Name : '
read name
if `grep $name /etc/passwd >> /dev/null`
then
tput cup 11 20
echo '---------------------------------------------'
tput cup 12 20
echo '| 1. With Home Directory |'
tput cup 13 20
echo '| 2. Without Home Directory |'
tput cup 14 20
echo '---------------------------------------------'
tput cup 15 20
echo -n 'Enter Choice : '
read opt
case $opt in
1) userdel -r $name
tput cup 16 20
echo "User $name deleted with Home . . ." ;;
2) userdel $name
tput cup 17 20
echo "User $name deleted without Home . . ." ;;
*) tput cup 18 20
echo 'Invalid Option !' ;;
esac
else
tput cup 11 20
echo "User $name don't exist !"
fi
tput cup 19 20
echo 'Press Enter to return to Main menu . . .'
read ;;
*) tput cup 10 20
echo 'Invalid Choice !'
tput cup 11 20
echo "Press Enter to return to Main menu . . ."
read ;;
esac