Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- GLOBALPASS=/etc/passwd
- LOCALPASS=/tank/shell01/root/etc/passwd
- NEW=1
- declare -a varray
- for aline in `sort -t\: -k3 -n ${LOCALPASS} | cut -d\: -f 1,3,4,6,7`
- do
- varray=(`echo $aline | awk '{ split($0, ulist, ":"); for(i=1; i<=11; i++) printf ulist[i] " "; }'`)
- aname=${varray[0]}
- auid=${varray[1]}
- agid=${varray[2]}
- ahd=${varray[3]}
- ashell=${varray[4]}
- ggrep -i ^${aname}: ${GLOBALPASS} > /dev/null 2>&1
- if [ $? -eq "$NEW" ] ; then # New User
- cut -d\: -f3 ${GLOBALPASS} | ggrep ^${auid}$ > /dev/null 2>&1
- if [ $? -eq "$NEW" ]; then #uid not in use, add em
- unset pline
- unset sline
- pline=${aname}:x:${auid}:65534::/:/bin/false
- sline=${aname}:*LK*:::::::
- echo -e "\r\nNew User: $aname"
- echo $pline
- echo $sline
- echo -n "Import user? [N/y]: "
- read response
- if ! test $response; then
- response="n"
- fi
- if ([ $response = "y" ] || [ $response = "Y" ]); then
- echo $pline >> /etc/passwd
- echo $sline >> /etc/shadow
- echo "ADDED"
- fi
- fi
- fi
- done
Add Comment
Please, Sign In to add comment