Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
grouper/container_files/usr-local-bin/changeGid.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
23 lines (21 sloc)
891 Bytes
This file contains 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 | |
if [[ $EUID -ne 0 ]]; then | |
echo "grouperContainer; ERROR: (changeGid.sh) This script must be run as root" | |
exit 1 | |
fi | |
if [ "$#" -ne 2 ]; then | |
echo "grouperContainer; ERROR: (changeGid.sh) You must enter exactly 2 command line arguments: groupname, and gid to change to" | |
exit 1 | |
fi | |
groupname=$1 | |
newGid=$2 | |
getentOutput="$(getent group "$groupname")" | |
oldGid="$( echo "$getentOutput" |cut -d\: -f3 )" | |
groupmod -g "$newGid" "$groupname" | |
returnCode=$? | |
echo "grouperContainer; INFO: (changeGid.sh) groupmod -g \"$newGid\" \"$groupname\" , result: $returnCode" | |
if [ $returnCode != 0 ]; then exit $returnCode; fi | |
find / -xdev -group "$oldGid" -exec chgrp -h "$groupname" {} \; | |
returnCode=$? | |
echo "grouperContainer; INFO: (changeGid.sh) find / -xdev -group \"$oldGid\" -exec chgrp -h \"$groupname\" {} \; , result: $returnCode" | |
if [ $returnCode != 0 ]; then exit $returnCode; fi |