Created
August 14, 2012 10:44
-
-
Save mitio/3348120 to your computer and use it in GitHub Desktop.
Quick sync tool to be run in "Set UID" mode for a specific purpose
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
#include <stdio.h> | |
int main() | |
{ | |
setuid(0); | |
printf("Starting...\n"); | |
// Create directories | |
system("find /wow/deian/BFF -type d | sed -e 's/\\/deian//' | while read folder; do echo Creating folder $folder; mkdir -p $folder; done"); | |
// Move files | |
system("find /wow/deian/BFF -type f | sed -e 's/\\/wow\\/deian\\///' | while read file; do echo Moving file $file; mv -f /wow/deian/$file /wow/$file; done"); | |
// Remove empty source directories | |
system("find /wow/deian/BFF/*/* -type d 2>/dev/null | sort -r | while read folder; do echo Removing empty folder $folder; rmdir $folder; done"); | |
// Set ownership of target files | |
system("chown -R nobody:nogroup /wow/BFF"); | |
printf("Done.\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment