Last active
November 29, 2019 10:01
-
-
Save mcindea/11c21a6c9600438877c8f07a982fb13e to your computer and use it in GitHub Desktop.
This script converts DB files created for NSS makedb command while you upgrade from RHEL6 to RHEL7 or 8.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script converts DB files created for NSS while you upgrade from RHEL6 to RHEL7 or RHEL8. | |
# It only happens when you upgrade from RHEL6 | |
# Fixes a problem where the groups are not properly added to the file like the following: | |
# :john john 2001,2500,4 | |
# First copy the old file to a new file | |
cp group.tdb group_test.tdb | |
for line in `grep ^= group.tdb | grep :$ | awk '{print $2}'`; do | |
GID=`echo $line | cut -d : -f 3` | |
USER=`echo $line | cut -d : -f 1` | |
GIDS="$(grep $USER group.tdb | grep : | cut -d : -f 3 | grep ^[0-9] | sort | uniq | tr '\n' , | sed 's/,$//')" | |
ADD=":$USER $USER $GIDS" | |
sed -i group_test.tdb -e "/=$GID $line/ a\ | |
$ADD" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment