Skip to content

Commit bb8d795

Browse files
committed
A simple script to create a new OS account
1 parent 5b04150 commit bb8d795

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

newuser.ksh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/ksh
2+
3+
# Script Name : newuser.ksh
4+
# Author : Craig Richards
5+
# Created : 10th December 2008
6+
# Last Modified :
7+
# Version : 1.0
8+
9+
# Modifications :
10+
11+
# Description : A simple script to create a new OS account
12+
13+
#################################
14+
# Start of procedures/functions #
15+
#################################
16+
17+
funct_check_user()
18+
{
19+
if [ `/usr/ucb/whoami` != root ]
20+
then echo 'You Must be root to execute this script !!!'
21+
exit 99
22+
fi
23+
}
24+
25+
funct_get_info()
26+
{
27+
clear
28+
print -n "Please enter username of the user to be created : ";
29+
read username
30+
print -n "Please enter a comment for the User : ";
31+
read comment
32+
print -n "Please enter the FULL path for the home directory : ";
33+
read dir
34+
print -n "Please enter the full shell you would like to use eg /bin/ksh for Korn Shell : ";
35+
read shell
36+
}
37+
38+
funct_create_user()
39+
{
40+
useradd -c "$comment" -m -d $dir -s $shell $username
41+
echo ' ';
42+
echo "User $username has been created on $DATE\n\n";
43+
echo "You will have to set the password for $username !!!\n\n";
44+
}
45+
46+
funct_permission()
47+
{
48+
chmod 700 $dir
49+
}
50+
51+
funct_password_expiry()
52+
{
53+
passwd -x 90 -n 7 $username
54+
}
55+
56+
################
57+
# Main Program #
58+
################
59+
60+
# Variable Settings
61+
62+
DATE=`date +"%d-%B-%Y"` ; export DATE
63+
64+
{
65+
funct_check_user;
66+
funct_get_info;
67+
funct_create_user;
68+
funct_permission;
69+
funct_password_expiry;
70+
}
71+
72+
73+
## End of Program

0 commit comments

Comments
 (0)