Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #This shell script is moving uids and gids to new server without grabbing the system accounts
- #The one caveat with this script is confirming the UID start limit and upper limit for your distro
- #This can be confirmed by checking the /etc/libuser.conf it is denoted there in RHEL distros
- #This script is to be ran from the /tmp directory as denoted in BASE
- #This script is valid for 6.5 RHEL and down as is. Change UGIDLIMIT to 1000 for v7.0
- #Create directory for migration files
- BASE=/tmp
- if [ -d ${BASE}/move ]
- then
- echo “The move directory exists.”
- else
- echo “Creating the move directory.”
- mkdir ${BASE}/move
- fi
- #Setup UID filter limit to setup UID start limit for normal user account.
- #RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 /etc/libuser.conf
- #This should filter out the system accounts
- export UGIDLIMIT=500
- #Now copy /etc/passwd accounts to /tmp/move/passwd.mig using awk to filter out system account i.e. only copy user accounts
- awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' ${BASE}/passwd > ${BASE}/move/passwd.mig
- #Copy /etc/group file
- awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' ${BASE}/group > ${BASE}/move/group.mig
- #Copy Shadow File
- awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' ${BASE}/passwd | tee - |egrep -f - ${BASE}/shadow > ${BASE}/move/shadow.mig
- #Append the files in etc from the filtering above on new server
- #cat ${BASE}/move/passwd.mig >> /etc/passwd
- #cat ${BASE}/move/group.mig >> /etc/group
- #cat ${BASE}/move/shadow.mig >> /etc/shadow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement