Created
April 8, 2011 21:20
-
-
Save dhrrgn/910759 to your computer and use it in GitHub Desktop.
Quickly and easily change the port that Pow is running on. This allows you too run Apache and Pow side-by-side (on different ports of course).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Pow Port | |
# | |
# Quickly and easily change the port that Pow is running on. This allows | |
# you too run Apache and Pow side-by-side (on different ports of course). | |
# | |
# WARNING: This will OVERWRITE your ~/.powconfig file. If you have custom | |
# configurations in there, please back it up first. | |
# | |
# This file must be executable (chmod +x pow_port.rb) | |
# This must be ran with administrative privelages (sudo). | |
# | |
# Usage: | |
# sudo ./pow_port.rb <new_port> | |
# | |
# Author: Dan Horrigan <http://dhorrigan.com> | |
# Copyright: 2011 Dan Horrigan | |
# License: MIT License | |
if ARGV[0].nil? | |
puts 'Usage: sudo ./pow_port.rb <new_port>' | |
exit | |
end | |
new_port = ARGV[0] | |
rule_num = nil | |
fw_rules = `sudo ipfw list` | |
fw_rules.split("\n").each do |rule| | |
unless rule.index(",20559 ").nil? | |
rule_num = rule.split(" ")[0] | |
break | |
end | |
end | |
if rule_num.nil? | |
puts "Could not find the firewall rule. Are you sure you have Pow installed?" | |
exit | |
end | |
system("sudo ipfw delete #{rule_num}") | |
system("sudo ipfw add fwd 127.0.0.1,20559 tcp from any to me dst-port #{new_port} in 1> /dev/null") | |
File.open(File.expand_path("~/.powconfig"), 'w+') {|f| f.write("export POW_DST_PORT=#{new_port}") } | |
puts "Pow is now running on port #{new_port}! You may need to restart your browser to see the results." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any idea how to get this working on Yosemite? Apparently they removed ipfw...