Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@ches /pow
Created Apr 14, 2011

A quick script to switch between running Pow and Apache on OS X
#!/bin/sh -e
#/ Usage: pow [on|off]
#/ Toggle between running Pow ( and Apache on Mac OS X.
# Show Usage
function usage {
grep '^#/' "$0" | cut -c4-
exit 2
[ -z "$1" -o "$1" = "--help" ] && usage
# Fail fast if we're on OS X
if [ "$(uname -s)" != "Darwin" ]; then
echo "You're not on OS X, so methinks you're not running Pow." 1>&2
exit 1
# Quick and dirty. Feel free to contribute nicer error handling, etc.
case "$toggle" in
sudo launchctl unload $APACHE_LAUNCHDAEMON
sudo launchctl load $POW_FIREWALL_LAUNCHDAEMON
launchctl load $POWD_LAUNCHAGENT && launchctl list | grep pow
launchctl unload $POWD_LAUNCHAGENT
sudo launchctl unload $POW_FIREWALL_LAUNCHDAEMON
sudo ipfw show | grep ",20559 .* dst-port 80 in" | cut -d' ' -f1 | xargs sudo ipfw delete
sudo launchctl load $APACHE_LAUNCHDAEMON &&
sudo launchctl list | grep apache
javve commented Jun 26, 2011

I get error
launchctl: Error unloading: cx.pow.powd
when writing
pow off

ches commented Jun 26, 2011

@Javve, that would happen if pow wasn't already running -- are you sure it was? Try pow on, see if pow is working as expected, then pow off. If you have any trouble, run the commands in the script one-by-one, and/or check for any issues launchd may be complaining about.

ches commented Aug 27, 2011

I should note that this is quick and dirty -- folks can feel free to add some ps-grep-checking or other error handling to avoid hitting insignificant errors like @javve saw. I'd also be remiss not to point out powify or powder if you want a more full-featured solution -- they're great, they're just overkill for me in this simplest of use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.