views:

254

answers:

2

Here is my rc.local for an autoscaling amazon ec2 instance based on ubuntu: (Note that user names, domains, and paths have been changed for security purposes)

logger "Begin rc.local startup script:"

logger "svn checkout"
sudo -u nonRootUser /usr/bin/svn co svn+ssh://[email protected]/path/to/repo /var/www/html | logger

logger "chown writeable folder"
chown www-data /var/www/html/writeableFolder

logger "restart apache"
/etc/init.d/apache2 restart | logger

exit 0

And here is the output of sudo tail -n 40 /var/log/syslog

Mar 10 22:05:20 ubuntu logger: Begin rc.local startup script:
Mar 10 22:05:20 ubuntu logger: svn checkout
Mar 10 22:05:20 ubuntu logger: chown writeable folder

Of course its not getting to apache2 restart because it error'd on the chown. I did find however that if I do a checkout beforehand, and set the rc.local svn command to an svn update, that it still does not run the svn command but does output apache2 restart successfully.

These same svn commands work perfectly when I run them manually, tho it's strange that within rc.local they do not produce any output whatsoever to logger yet apache2 restart does.

I've also tried running the svn co and svn update both with sudo -u and without.

How do I get the svn command to run? Either a full checkout or an update. At this point either would be better than nothing!

A: 

Try using the full path to chown.

/bin/chown
flaxeater
Actually that is not why chown is not running. chown can only change what is there, and since svn did not do a checkout, the files I'm trying to chown do not exist.
talentedmrjones
+1  A: 

I don't know why sudo is causing problems here, but you can also use su, which would work like this:

su nonRootUser -c "/usr/bin/svn co svn+ssh://[email protected]/path/to/repo /var/www/html | logger"
R. Bemrose
That did it! Thank you for halting my hair loss! :)
talentedmrjones