-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy pathnewuser.ksh
73 lines (58 loc) · 1.34 KB
/
newuser.ksh
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
#!/bin/ksh
# Script Name : newuser.ksh
# Author : Craig Richards
# Created : 10th December 2008
# Last Modified :
# Version : 1.0
# Modifications :
# Description : A simple script to create a new OS account
#################################
# Start of procedures/functions #
#################################
funct_check_user()
{
if [ `/usr/ucb/whoami` != root ]
then echo 'You Must be root to execute this script !!!'
exit 99
fi
}
funct_get_info()
{
clear
print -n "Please enter username of the user to be created : ";
read username
print -n "Please enter a comment for the User : ";
read comment
print -n "Please enter the FULL path for the home directory : ";
read dir
print -n "Please enter the full shell you would like to use eg /bin/ksh for Korn Shell : ";
read shell
}
funct_create_user()
{
useradd -c "$comment" -m -d $dir -s $shell $username
echo ' ';
echo "User $username has been created on $DATE\n\n";
echo "You will have to set the password for $username !!!\n\n";
}
funct_permission()
{
chmod 700 $dir
}
funct_password_expiry()
{
passwd -x 90 -n 7 $username
}
################
# Main Program #
################
# Variable Settings
DATE=`date +"%d-%B-%Y"` ; export DATE
{
funct_check_user;
funct_get_info;
funct_create_user;
funct_permission;
funct_password_expiry;
}
## End of Program