Created
December 3, 2014 09:38
-
-
Save VuokkoVuorinnen/c434ec6e5a65d0e469cf to your computer and use it in GitHub Desktop.
Remove corrupt graphite carbon whisper files
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 | |
options=('find' 'delete') | |
PS3='state your wish: ' | |
echo -e "\nfind/delete corrupt whisper-files" | |
select opt in "${options[@]}"; do | |
case $REPLY in | |
[12] ) option=$opt; break;; | |
* ) exit;; | |
esac | |
done | |
if [ $option ]; then | |
matches=() | |
directory='/var/lib/carbon/whisper' | |
for file in $(find $directory -type f -name '*.wsp' -print); do | |
/usr/bin/whisper-info $file > /dev/null 2>&1 | |
retval=$? | |
echo -en "\r\033[Kchecking $file" | |
[ $retval -ne 0 ] && matches+=($file) | |
done | |
if [ $option == 'find' ]; then | |
echo -en "\r\033[Klisting ${#matches[@]} corrupt files:\n" | |
for file in "${matches[@]}"; do | |
echo -e "- $file" | |
done | |
else | |
echo -en "\r\033[Kdeleting ${#matches[@]} corrupt files:\n" | |
for file in "${matches[@]}"; do | |
sudo rm $file && echo -e "- $file" | |
done | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment