forked from basecamp/pow
/
install.sh
98 lines (87 loc) · 2.42 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
#
# 8b,dPPYba, ,adPPYba, 8b db d8
# 88P' "8a a8" "8a `8b d88b d8'
# 88 d8 8b d8 `8b d8'`8b d8'
# 88b, ,a8" "8a, ,a8" `8bd8' `8bd8'
# 88`YbbdP"' `"YbbdP"' YP YP
# 88
# 88
#
# Zero-configuration development server for Rack applications
#
# Requires Mac OS X 10.6
# To install, run this command in a Terminal window:
#
# curl get.pow.cx | sh -
#
set -e
POW_ROOT="$HOME/Library/Application Support/Pow"
[[ -z "$VERSION" ]] && VERSION=0.1.4
echo "*** Installing Pow $VERSION..."
mkdir -p "$POW_ROOT"
cd "$POW_ROOT"
mkdir -p Hosts
mkdir -p Versions
cd Versions
rm -rf "$POW_ROOT/Versions/$VERSION"
curl -s http://get.pow.cx.s3-website-us-east-1.amazonaws.com/versions/$VERSION.tar.gz | tar xzf -
cd ..
rm -f Current
ln -s Versions/$VERSION Current
cd
[[ -a .pow ]] || ln -s "$POW_ROOT/Hosts" .pow
mkdir -p Library/LaunchAgents
cat > Library/LaunchAgents/cx.pow.powd.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>cx.pow.powd</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-i</string>
<string>-c</string>
<string>\$SHELL --login -c "'$POW_ROOT/Current/bin/pow'"</string>
</array>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
TMP=/tmp/pow-install.$$
mkdir -p $TMP
cat > $TMP/cx.pow.firewall.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>cx.pow.firewall</string>
<key>ProgramArguments</key>
<array>
<string>$POW_ROOT/Current/bin/pow_firewall</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
</dict>
</plist>
EOF
cat > $TMP/test <<EOF
nameserver 127.0.0.1
port 20560
EOF
sudo mv $TMP/cx.pow.firewall.plist /Library/LaunchDaemons
sudo chown root:wheel /Library/LaunchDaemons/cx.pow.firewall.plist
sudo mkdir -p /etc/resolver
sudo mv $TMP/test /etc/resolver
sudo launchctl load /Library/LaunchDaemons/cx.pow.firewall.plist 2>/dev/null
launchctl unload ~/Library/LaunchAgents/cx.pow.powd.plist 2>/dev/null || true
launchctl load ~/Library/LaunchAgents/cx.pow.powd.plist 2>/dev/null
echo "*** Installed"