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! 🙂

Like this post? Share it with others!

James Morris

My game is SERPs and Web Dev. I read rankings and code like Gamers play RPGs. I do a little bit of everything online: SysAdmin, Design, Code, SEO & SMO. I love all things web.

I love meeting new people and sharing knowledge. Join me as I frolic on the playground that is the Internet and experience all that this wonderful world has to offer.

Leave a Comment