Hello
I've managed to create an adduser script, but it seems that UID cannot
be written to /etc/passwd
I've tried any ways I could think of, but I still cannot find the way to
solve the problem....
anybody can help me out of this mess??
thanx
Steve
#!/bin/sh
echo
echo -n "Please insert login name (max 8 character): "
read LGN
if [ -z "$LGN" ]
then
echo "Error, You must fill the login field...";
exit
fi
pass="/etc/passwd"
cat $pass | awk -F: '{print $1}' >pass.1
if cat pass.1 | grep "\<"$LGN"\>"; then
echo "Login is already exist";
exit
fi
rm pass.1
echo
echo -n "Please insert User ID : "
read ID
GUID="-u $ID"
if [ -z "$ID" ]
then
GUID=""
fi
echo
echo -n "Please insert Group ID : "
read GID
if [ -z "$GID" ]
then
GID="users"
fi
GGID="-g $GID"
echo
echo -n "Please specify $LGN's home directory [eg. /home/$LGN]: "
read HMD
if [ -z "$HMD" ]; then
HMD="/home/$LGN"
fi
GHMD="-d $HMD"
echo
echo -n "Please specify $LGN's shell [eg. /bin/bash]: "
read SHL
GSHL="-s $SHL"
if [ -z "$SHL" ]
then
GSHL="-s /bin/bash"
SHL="/bin/bash"
fi
echo
echo "Creating new account for $LGN"
echo "Adding username $LGN"
echo "Creating User ID for $LGN"
echo "Creating Group ID for $LGN"
echo "Creating Home Directory : $HMD"
echo "Creating Shell : $SHL"
echo
echo New login name: $LGN
if [ -z "$GUID" ]
then echo New UID: [Next available]
else echo New UID: $UID
fi
if [ -z "$GGID" ]
then echo Initial group: Users
else echo Initial group: $GID
fi
if [ -z "$GHME" ]
then echo Home directory: /home/$LGN
else echo Home directory: $HME
fi
if [ -z "$GSHL" ]
then echo Shell: /bin/bash
else echo Shell: $SHL
fi
echo
echo $LGN ":x:" $UID ":" $GID ":" $AGID ":" $HMD ":" $SHL>>$pass
echo
mkdir $HMD
chown $UID $HMD
chgrp $GID $HMD
Received on Sun Oct 15 2000 - 11:07:53 NZDT