bin/powder in powder-0.3.0.pre4 vs bin/powder in powder-0.3.0
- old
+ new
@@ -74,45 +74,35 @@
if MAC_OS_X_MINOR_VERSION >= 10
start_on_yosemite
else
start_on_mavericks
end
+ say "Pow has been started."
end
desc "start", "An alias to up"
alias :start :up
desc "down", "Disable pow"
def down
if File.exists? POW_FIREWALL_PLIST_PATH
if not %x{sudo launchctl list | grep cx.pow.firewall}.empty?
- %x{sudo launchctl unload #{POW_FIREWALL_PLIST_PATH}}
+ %x{sudo launchctl unload #{POW_FIREWALL_PLIST_PATH} 2>/dev/null}
end
end
if File.exists? POW_DAEMON_PLIST_PATH
- %x{launchctl unload #{POW_DAEMON_PLIST_PATH}}
+ %x{launchctl unload #{POW_DAEMON_PLIST_PATH} 2>/dev/null}
end
- if MAC_OS_X_MINOR_VERSION < 10
- if File.exists? POW_FIREWALL_PLIST_PATH
- if ports = File.open(POW_FIREWALL_PLIST_PATH).read.match(/fwd .*?,([\d]+).*?dst-port ([\d]+)/)
- http_port, dst_port = ports[1..2]
- end
- end
-
- http_port ||= 20559
- dst_port ||= 80
-
- if rule = %x{sudo ipfw show | grep ",#{http_port} .* dst-port #{dst_port} in"}.split.first
- %x{sudo ipfw delete #{rule} && sudo sysctl -w net.inet.ip.forwarding=0}
- end
- end
-
if MAC_OS_X_MINOR_VERSION >= 10
- %{sudo pfctl -a "com.apple/250.PowFirewall" -F all}
+ stop_on_yosemite
+ else
+ stop_on_mavericks
end
+
+ say "Pow has been stopped."
end
desc "stop", "An alias to down"
alias :stop :down
@@ -533,21 +523,40 @@
http.request(request).body
end
def start_on_yosemite
return say "Pow daemon configuration missing." unless File.exists?(POW_DAEMON_PLIST_PATH)
- %x{launchctl bootstrap gui/"$UID" #{POW_DAEMON_PLIST_PATH}}
+ %x{launchctl bootstrap gui/"$UID" #{POW_DAEMON_PLIST_PATH} 2>/dev/null}
- %x{launchctl enable gui/"$UID"/cx.pow.powd}
- %x{launchctl kickstart -k gui/"$UID"/cx.pow.powd}
+ %x{launchctl enable gui/"$UID"/cx.pow.powd 2>/dev/null}
+ %x{launchctl kickstart -k gui/"$UID"/cx.pow.powd 2>/dev/null}
end
+ def stop_on_yosemite
+ %{sudo pfctl -a "com.apple/250.PowFirewall" -F all 2>/dev/null}
+ end
+
def start_on_mavericks
return say "Pow firewall configuration missing." unless File.exists?(POW_FIREWALL_PLIST_PATH)
- %x{launchctl load #{POW_FIREWALL_PLIST_PATH}}
+ %x{launchctl load #{POW_FIREWALL_PLIST_PATH} 2>/dev/null}
return say "Pow daemon configuration missing." unless File.exists?(POW_DAEMON_PLIST_PATH)
- %x{launchctl load #{POW_DAEMON_PLIST_PATH}}
+ %x{launchctl load #{POW_DAEMON_PLIST_PATH} 2>/dev/null}
+ end
+
+ def stop_on_mavericks
+ if File.exists? POW_FIREWALL_PLIST_PATH
+ if ports = File.open(POW_FIREWALL_PLIST_PATH).read.match(/fwd .*?,([\d]+).*?dst-port ([\d]+)/)
+ http_port, dst_port = ports[1..2]
+ end
+ end
+
+ http_port ||= 20559
+ dst_port ||= 80
+
+ if rule = %x{sudo ipfw show | grep ",#{http_port} .* dst-port #{dst_port} in"}.split.first
+ %x{sudo ipfw delete #{rule} && sudo sysctl -w net.inet.ip.forwarding=0}
+ end
end
end
end