This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
127 lines (91 loc) · 3.73 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh
# Most of this script is shamelessly stolen from Pow's install script.
# Then again, the whole concept is shamelessly stolen as well.
# 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
# Ask for some configuration variables
printenv
echo "## _ _ "
echo "## _ __ ___ __ _ _ __ __ _| |_| |__ ___ _ __ "
echo "## | '_ \` _ \ / _\` | '__/ _\` | __| '_ \ / _ \| '_ \ "
echo "## | | | | | | (_| | | | (_| | |_| | | | (_) | | | |"
echo "## |_| |_| |_|\__,_|_| \__,_|\__|_| |_|\___/|_| |_|"
echo "##"
echo ""
echo ""
echo "Before we get started, I've just a couple quick questions."
echo "The default answers are in parentheses - if you like what's"
echo "there, just hit enter to move on!"
echo ""
# Configure project directory
echo ""
echo "Where would you like to link your projects from?"
echo "(~/.marathon) \c"
read projects
if [ -z "$projects" ]; then
projects="~/.marathon"
fi
sed -i '' -e "s#PROJECTS#$projects#g" ./config.json
# Configure log directory
echo ""
echo "Where do you want to keep logs?"
echo "(~/.marathon/logs) \c"
read logs
if [ -z "$logs" ]; then
logs="~/.marathon/logs"
fi
sed -i '' -e "s#LOGS#$logs#g" ./config.json
# Configure tld for dns resolver
echo ""
echo "What tld do you want to access your apps at? (i.e. http://my-project.dev)?"
echo "(dev) \c"
read tld
if [ -z "$tld" ]; then
tld="dev"
fi
sed -i '' -e "s#TLD#$tld#g" ./config.json
# Configure the edit command
echo ""
echo "What command do you use to open your editor?"
echo "($EDITOR) \c"
read editor
if [ -z "$editor" ]; then
editor=$EDITOR
fi
sed -i '' -e "s#EDITOR#$editor#g" ./config.json
# Configuration complete!
echo ""
echo "*** Configuration complete"
# Expand ~ in the configuration file
echo ""
echo "*** Expanding configuration paths ..."
sed -i '' -e "s#~#$HOME#g" ./config.json
logs=`echo $logs | sed s#~#$HOME#g`
# Install configuration files.
echo "*** Installing configuration files..."
sudo cp ./dns/resolver "/etc/resolver/$tld"
sudo cp ./dns/davewasmer.marathon.forwarding.plist /Library/LaunchDaemons/
cp ./web/davewasmer.marathon.marathond.plist "$HOME/Library/LaunchAgents/"
modulepath=`pwd`
execpath=$modulepath"/index.js"
nodepath=$npm_config_prefix"/bin/node"
# setup our launch daemon with the right paths
sed -i '' -e "s#EXEC#$execpath#g" "$HOME/Library/LaunchAgents/davewasmer.marathon.marathond.plist"
sed -i '' -e "s#NODE#$nodepath#g" "$HOME/Library/LaunchAgents/davewasmer.marathon.marathond.plist"
sed -i '' -e "s#LOG#$logs/marathon.log#g" "$HOME/Library/LaunchAgents/davewasmer.marathon.marathond.plist"
sed -i '' -e "s#WORKINGDIR#$modulepath#g" "$HOME/Library/LaunchAgents/davewasmer.marathon.marathond.plist"
sed -i '' -e "s#PATHEXPORT#$PATH#g" "$HOME/Library/LaunchAgents/davewasmer.marathon.marathond.plist"
echo "*** Installing system configuration files as root..."
sudo launchctl load -Fw /Library/LaunchDaemons/davewasmer.marathon.forwarding.plist 2>/dev/null
launchctl load -Fw "$HOME/Library/LaunchAgents/davewasmer.marathon.marathond.plist" 2>/dev/null
# All done!
echo "*** Installed"
echo ""
echo "Marathon is now installed. To get started, symlink your node"
echo "projects into $projects, and check out http://marathon.$tld"