Skip to content

Instantly share code, notes, and snippets.

@opensvn
Last active September 2, 2017 07:17
Show Gist options
  • Save opensvn/aead3d125c33a87e40707cddf7cc2e7f to your computer and use it in GitHub Desktop.
Save opensvn/aead3d125c33a87e40707cddf7cc2e7f to your computer and use it in GitHub Desktop.
If a file in local git repository has no write permission, nutstore will stuck in analyzing that file. This script add write permission to the files modified in a day, so nutstore can upload those files.
#!/usr/bin/env bash
today=`date +%Y-%m-%d`
check_modify_time() {
file=$1
modify_date=`stat $file | grep -i Modify | awk -F. '{print $1}' | awk '{print $2}'`
if [ ${today} = ${modify_date} ]; then
return 0
fi
return 1
}
process_file() {
file=$1
if [ -w $file ]; then
return
fi
if check_modify_time $file; then
echo $file
chmod u+w $file
fi
}
check_directory() {
for file in $1/*
do
if [ -d $file ]; then
if [[ $file != "." && $file != ".." ]]; then
check_directory $file
fi
elif [ -f $file ]; then
process_file $file
fi
done
}
if [[ "x$1" == 'x' ]]; then
echo "You need to specify a directory."
else
check_directory "$1"
fi
@albertofwb
Copy link

hey man nice shell scripts
--- comes from nutstore bbs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment