Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 108 lines (75 sloc) 3.894 kB
ed2590e @sstephenson Uninstall script
sstephenson authored
1 #!/bin/sh
69ab71c @sstephenson New art
sstephenson authored
2 # W
3 # R RW W.
4 # RW::::RW DR::R
5 # :RRRRRWWWWRt:::::::RRR::::::E jR
6 # R.::::::::::::::::::::::::::Ri jiR:::R
7 # R:::::::.RERRRRWWRERR,::::::Efi:::::::R GjRRR Rj
8 # R::::::.R R:::::::::::::;G RRj WWR RjRRRRj
9 # Rt::::WR RRWR R::::::::::::::::fWR::R; WRW RW R
10 # WWWWRR:::EWR E::W WRRW:::EWRRR::::::::: RRED WR RRW RR
11 # 'R:::::::RRR RR DWW R::::::::RW LRRR WR R
12 # RL:::::WRR GRWRR RR R::WRiGRWW RRR RRR R
13 # Ri:::WWD RWRRRWW WWR LR R W RR RRRR RR R
14 # RRRWWWWRE;,:::WW R:::RW RR:W RR ERE RR RRR RRR R
15 # RR:::::::::::RR tR:::WR Wf:R RW R R RRR RR R
16 # WR::::::::tRR WR::RW ER.R RRR R RRRR RR R
17 # WE:::::RR R:::RR :RW E RR RW; GRRR RR R
18 # R.::::,WR R:::GRW E::RR WiWW RRWR LRRWWRR
19 # WR::::::RRRRWRG::::::RREWDWRj::::RW ,WR::WR iRWWWWWRWW R
20 # LR:::::::::::::::::::::::::::::::::EWRR::::::RRRDi:::W RR R
21 # R:::::::::::::::::::::::::::::::::::::::::::::::::::tRW RRRWWWW
22 # RRRRRRRRRRR::::::::::::::::::::::::::::::::::::,:::DE RRWRWW,
23 # R::::::::::::: RW::::::::R::::::::::RRWRRR
24 # R::::::::::WR. ;R::::;R RWi:::::ER
25 # R::::::.RR Ri:iR RR:,R
26 # E::: RE RW Y
27 # ERRR
28 # G Zero-configuration Rack server for Mac OS X
29 # http://pow.cx/
ed2590e @sstephenson Uninstall script
sstephenson authored
30 #
69ab71c @sstephenson New art
sstephenson authored
31 # This is the uninstallation script for Pow.
ed2590e @sstephenson Uninstall script
sstephenson authored
32 # See the full annotated source: http://pow.cx/docs/
33 #
34 # Uninstall Pow by running this command:
35 # curl get.pow.cx/uninstall.sh | sh
36
37
38 # Set up the environment.
39
40 set -e
41 POW_ROOT="$HOME/Library/Application Support/Pow"
42 POW_CURRENT_PATH="$POW_ROOT/Current"
43 POW_VERSIONS_PATH="$POW_ROOT/Versions"
44 POWD_PLIST_PATH="$HOME/Library/LaunchAgents/cx.pow.powd.plist"
45 FIREWALL_PLIST_PATH="/Library/LaunchDaemons/cx.pow.firewall.plist"
46
47
48 # Fail fast if Pow isn't present.
49
50 if [[ ! -d "$POW_CURRENT_PATH" ]] && [[ ! -a "$POWD_PLIST_PATH" ]] && [[ ! -a "$FIREWALL_PLIST_PATH" ]]; then
51 echo "error: can't find Pow" >&2
52 exit 1
53 fi
54
55
539a681 @sstephenson Fix uninstallation from curl
sstephenson authored
56 # Find the tty so we can prompt for confirmation even if we're being piped from curl.
57
bb91285 @cjolly set TTY more reliably in uninstall.sh
cjolly authored
58 TTY="/dev/$( ps -p$$ -o tty | tail -1 | awk '{print$1}' )"
539a681 @sstephenson Fix uninstallation from curl
sstephenson authored
59
60
ed2590e @sstephenson Uninstall script
sstephenson authored
61 # Make sure we really want to uninstall.
62
539a681 @sstephenson Fix uninstallation from curl
sstephenson authored
63 read -p "Sorry to see you go. Uninstall Pow [y/n]? " ANSWER < $TTY
64 [[ $ANSWER == "y" ]] || exit 1
65 echo "*** Uninstalling Pow..."
ed2590e @sstephenson Uninstall script
sstephenson authored
66
67
68 # Remove the Versions directory and the Current symlink.
69
70 rm -fr "$POW_VERSIONS_PATH"
71 rm -f "$POW_CURRENT_PATH"
72
73
74 # Unload cx.pow.powd from launchctl and remove the plist.
75
76 launchctl unload "$POWD_PLIST_PATH" 2>/dev/null || true
77 rm -f "$POWD_PLIST_PATH"
78
79
80 # Read the firewall plist, if possible, to figure out what ports are in use.
81
82 if [[ -a "$FIREWALL_PLIST_PATH" ]]; then
83 ports=($(ruby -e'puts $<.read.scan(/fwd .*?,([\d]+).*?dst-port ([\d]+)/)' "$FIREWALL_PLIST_PATH"))
84
85 HTTP_PORT=${ports[0]}
86 DST_PORT=${ports[1]}
87 fi
88
89
90 # Assume reasonable defaults otherwise.
91
92 [[ -z "$HTTP_PORT" ]] && HTTP_PORT=20559
93 [[ -z "$DST_PORT" ]] && DST_PORT=80
94
95
96 # Try to find the ipfw rule and delete it.
97
98 RULE=$(sudo ipfw show | (grep ",$HTTP_PORT .* dst-port $DST_PORT in" || true) | cut -f 1 -d " ")
99 [[ -n "$RULE" ]] && sudo ipfw del "$RULE"
100
101
102 # Unload the firewall plist and remove it.
103
104 sudo launchctl unload "$FIREWALL_PLIST_PATH" 2>/dev/null || true
105 sudo rm -f "$FIREWALL_PLIST_PATH"
106
107 echo "*** Uninstalled"
Something went wrong with that request. Please try again.