SVN UP, Recursive CHMOD and CHOWN for user passed via STDIN

If you want to be able to run a script to quickly perform a svn up, chmod and chown of your site files, the following command will accept the username from stdin (standard input [command parameter]).

#!/bin/bash
svn up /home/$1/public_html/
find /home/$1/public_html/ -type f -exec chmod 644 {} ; && find /home/$1/public_html/ -type d -exec chmod 755 {} ;
chown -Rv $1:$1 /home/$1/public_html/*
echo “The public_html/ direcotry for $1 has been updated.”

If you want a more portable version that will only effect the current directory recursively, use the following.

#!/bin/bash
svn up ./
find ./ -type f -exec chmod 644 {} ; && find ./ -type d -exec chmod 755 {} ;
chown -Rv $1:$1 ./*
echo “The current direcotry for $1 has been updated.”

CHMOD the script file to 700 to allow execution. Then call the script like so…

[user@host ~]# /path/to/script/scriptname username

Enjoy! 🙂

Share This!

Leave a Reply

Your email address will not be published. Required fields are marked *