Created
January 15, 2014 21:44
-
-
Save mplscorwin/8445328 to your computer and use it in GitHub Desktop.
fix ownership of cassandra's files when someone goes and runs it other than from "service start cassandra" (CentOS 6)
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 | |
################################################################################ | |
# | |
# shell script to fix ownership of all files under each entry in SEARCH_PATH | |
# | |
# Change SEARCH_PATH as needed. | |
# NOTE: script has no output if it does no work. | |
# | |
################################################################################ | |
# space seperated list of paths | |
SEARCH_PATHS='/home/cassandra/data /clogs/processlog /clogs/commitlog' | |
# incorrect user for which we are searching | |
SEARCH_USER=root | |
# correct user/group | |
CHOWN_ARGS=cassandra.cassandra | |
### work happens here | |
CHANGE_COUNT=0 | |
for DIR in $SEARCH_PATHS; do | |
CHANGE_COUNT=$(( $CHANGE_COUNT + `find $DIR -user $SEARCH_USER -exec chown $CHOWN_ARGS {} \; -print | wc -l`)) | |
done | |
if [[ $CHANGE_COUNT -gt 0 ]]; then | |
echo [WARNING] ownership of $CHANGE_COUNT files changed from root.\? to $CHOWN_ARGS | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment