forked from basecamp/pow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
99 lines (64 loc) · 2.66 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
99
#!/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 Rack server
# for Mac OS X -- http://pow.cx/
#
#
# You're reading the installation script for Pow.
# See the full annotated source: http://pow.cx/docs/
#
# Install Pow by running this command:
# curl get.pow.cx | sh
#
# Uninstall Pow: :'(
# curl get.pow.cx/uninstall.sh | sh
# Set up the environment. Respect $VERSION if it's set.
set -e
POW_ROOT="$HOME/Library/Application Support/Pow"
POW_BIN="$POW_ROOT/Current/bin"
[[ -z "$VERSION" ]] && VERSION=0.2.2
# Fail fast if we're not on OS X >= 10.6.0.
if [ "$(uname -s)" != "Darwin" ]; then
echo "Sorry, Pow requires Mac OS X to run." >&2
exit 1
elif [ "$(expr "$(sw_vers -productVersion | cut -f 2 -d .)" \>= 6)" = 0 ]; then
echo "Pow requires Mac OS X 10.6 or later." >&2
exit 1
fi
echo "*** Installing Pow $VERSION..."
# Create the Pow directory structure if it doesn't already exist.
mkdir -p "$POW_ROOT/Hosts" "$POW_ROOT/Versions"
# If the requested version of Pow is already installed, remove it first.
cd "$POW_ROOT/Versions"
rm -rf "$POW_ROOT/Versions/$VERSION"
# Download the requested version of Pow and unpack it.
curl -s http://get.pow.cx/versions/$VERSION.tar.gz | tar xzf -
# Update the Current symlink to point to the new version.
cd "$POW_ROOT"
rm -f Current
ln -s Versions/$VERSION Current
# Create the ~/.pow symlink if it doesn't exist.
cd "$HOME"
[[ -a .pow ]] || ln -s "$POW_ROOT/Hosts" .pow
# Install local configuration files.
echo "*** Installing local configuration files..."
"$POW_BIN/pow" --install-local
# Check to see whether we need root privileges.
"$POW_BIN/pow" --install-system --dry-run >/dev/null && NEEDS_ROOT=0 || NEEDS_ROOT=1
# Install system configuration files, if necessary. (Avoid sudo otherwise.)
if [ $NEEDS_ROOT -eq 1 ]; then
echo "*** Installing system configuration files as root..."
sudo "$POW_BIN/pow" --install-system
sudo launchctl load /Library/LaunchDaemons/cx.pow.firewall.plist 2>/dev/null
fi
# Start (or restart) powd.
echo "*** Starting the Pow server..."
launchctl unload "$HOME/Library/LaunchAgents/cx.pow.powd.plist" 2>/dev/null || true
launchctl load "$HOME/Library/LaunchAgents/cx.pow.powd.plist" 2>/dev/null
echo "*** Installed"