denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)
Denise ([staff profile] denise) wrote in [site community profile] dw_dev_training2011-08-20 10:49 pm

Useful scripts

(Can you tell I've been coding lately? Like the last four posts here have been from me ...)

I was talking with [personal profile] rb this evening about useful scripts I have put together for my dreamhack -- some of which I came up with myself, and some of which I stole from other people, such as [staff profile] mark -- and figured it would be a good idea to post them and ask everybody else to post their own useful scripts!

(If you want to install these to your own 'hack, put them in ~/bin and then chmod +x filename to make them executable.)



1. sl -- syncs the live code (in ~/dw) to the code in cvs (~/dw/cvs/dw-{non}free)




2. sc -- syncs the code in cvs (~/dw/cvs/dw-{non}free) to the code in live (~/dw), and cleans up any .orig or .rej files lying around from previous reversions or failed patch attempts. (Might produce a "rm: missing arguments" if there are none of those files.)



3. tidy -- cleans up any .orig or .rej files lying around. Will produce a "rm: missing argument" if there are none of these files.



4. dbu -- runs the database update commands. does NOT pull most recent code first -- use this when you've made styles changes or made changes to the db schema in order to see your changes reflected on the live site.



5. bap: for Bounce APache. stops and starts apache (need to do this if you've changed any .pm files in order for your changes to be reflected on your 'hack -- if you're making changes and they aren't being reflected in the browser when you reload the page, and you're positive you're working in live and not in cvs, bounce the apache.) I totally stole the name from [staff profile] mark.



6. upgrade: does all the steps necessary to upgrade your 'hack to the most recent code. (don't run this if you have any changes in either your live or cvs directory -- it will error. pop your patches off the stack, or revert everything, and then run the upgrade commands.)



So, what other useful scripts do you have?
eagle: Me at the Adobe in Yachats, Oregon (Default)

[personal profile] eagle 2011-08-21 04:08 am (UTC)(link)

If you want to suppress the rm error in 3:

#!/bin/sh
find -name \*.orig -o -name \*.rej -print0 | xargs -0r rm

This also still works correctly if you have a file in the current directory ending in .orig or .rej (by escaping the wildcards so that the shell doesn't try to expand them), and uses -print0 and -0 to xargs so that it properly handles filenames containing spaces.

This assumes GNU or GNU-compatible find and xargs, but that's a fairly safe bet at this point, I think, at least for those features.

[personal profile] andy 2011-08-21 01:04 pm (UTC)(link)
* bash aliases work better for one-liners

* Mark totally ganked bap from LJ, lol. I do wonder how your ops restarts the web tier servers every release, though.
alierak: (Default)

[personal profile] alierak 2011-08-22 02:12 am (UTC)(link)
restart-webs from the admin box; sorry about the yawn-worthy name...