Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #!/bin/bash
  2. #This shell script is moving uids and gids to new server without grabbing the system accounts
  3. #The one caveat with this script is confirming the UID start limit and upper limit for your distro
  4. #This can be confirmed by checking the /etc/libuser.conf it is denoted there in RHEL distros
  5. #This script is to be ran from the /tmp directory as denoted in BASE
  6. #This script is valid for 6.5 RHEL and down as is. Change UGIDLIMIT to 1000 for v7.0
  7. #Create directory for migration files
  8. BASE=/tmp
  9.  
  10. if [ -d ${BASE}/move ]
  11. then
  12. echo “The move directory exists.”
  13. else
  14. echo “Creating the move directory.”
  15. mkdir ${BASE}/move
  16. fi
  17.  
  18. #Setup UID filter limit to setup UID start limit for normal user account.
  19. #RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 /etc/libuser.conf
  20. #This should filter out the system accounts
  21.  
  22. export UGIDLIMIT=500
  23.  
  24. #Now copy /etc/passwd accounts to /tmp/move/passwd.mig using awk to filter out system account i.e. only copy user accounts
  25. awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' ${BASE}/passwd > ${BASE}/move/passwd.mig
  26.  
  27. #Copy /etc/group file
  28. awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' ${BASE}/group > ${BASE}/move/group.mig
  29.  
  30. #Copy Shadow File
  31. awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' ${BASE}/passwd | tee - |egrep -f - ${BASE}/shadow > ${BASE}/move/shadow.mig
  32.  
  33. #Append the files in etc from the filtering above on new server
  34. #cat ${BASE}/move/passwd.mig >> /etc/passwd
  35. #cat ${BASE}/move/group.mig >> /etc/group
  36. #cat ${BASE}/move/shadow.mig >> /etc/shadow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement