I wrote a little and mundane script long time back to solve my purpose to create bunch of user accounts on specific host.
Here is the script:
If you feel ,you can suggest me the enhancement.
Hope this will help.
Cheers!
Bhaskar
Here is the script:
#!/bin/bash
# This script is meant to run when we create a bunch of user account of any specified host.
#Backup important file before doing anything.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2,
# or at your option any later version, as published by the
# Free Software Foundation
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
PASSWDFILE="/etc/password"
GROUPFILE="/etc/group"
SHADOWFILE="/etc/shadow"
DATE=`date`
USERFILE="THis file should have the form of password file like username:password:UID:GID:gecos:shell"
cd /etc ;pwd
cp -v $PASSWDFILE $PASSWDFILE.$DATE
echo " Password file backed up.."
cp -v $GROUPFILE $GROUPFILE.$DATE
echo " group file backed up.."
cp -v $SHADOWFILE $SHADOWFILE.$DATE
echo "shadow file backed .."
/usr/sbin/newusers $USERFILE
echo " Done"
echo " Forcing user to change their password upon first login.."
for i in $USERFILE
do
/usr/sbin/chage -d 0
echo $i
done
If you feel ,you can suggest me the enhancement.
Hope this will help.
Cheers!
Bhaskar
No comments:
Post a Comment