[Linux] Owner Changer
Posted: May 15th, 2012, 4:09 pm
Hi there!
For those who run SABnzbd as root, for some reason, but want to change the owner and permissions of files downloaded, here is a very simple script I wrote.
It changes the owner and group of all downloaded folders and files, permissions of all folders and sub-folders and permissions of all files, even those with spaces.
It works with BusyBox too, which is shipped with every NAS, i.e. without the -exec or -print0 and -0 arguments of the find and xargs commands.
Enjoy! :-)
For those who run SABnzbd as root, for some reason, but want to change the owner and permissions of files downloaded, here is a very simple script I wrote.
It changes the owner and group of all downloaded folders and files, permissions of all folders and sub-folders and permissions of all files, even those with spaces.
It works with BusyBox too, which is shipped with every NAS, i.e. without the -exec or -print0 and -0 arguments of the find and xargs commands.
Code: Select all
#!/bin/sh
# Owner Changer for SABnzbd 0.2
# By Mohinder <mohinder@no-log.org>
# Define the username, group and permissions to apply here
USER="romain"
GROUP="everyone"
FOLDERS="755"
FILES="644"
# Human readable variables
DESTINATION=$1
# Running the script
chown -R $USER:$GROUP "$DESTINATION"
find "$DESTINATION" -type d | while read i; do chmod $FOLDERS "$i"; done
find "$DESTINATION" -type f | while read i; do chmod $FILES "$i"; done
echo "Owner and permissions changed successfully."