-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·239 lines (213 loc) · 8.66 KB
/
install
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#!/bin/bash
set -e
# expects to run as root
# TODO: tes th
# /**
# * <div id="Default-Values" class="section">
# * <div class="section-header"><span>Default Values</span></div>
# */
GITHUB_REF=DogFoodSoftware/conveyor-core
PLAYGROUND="$HOME/playground"
CONVEYOR_DATA="$HOME/data"
CONVEYOR_VER="master"
PROJECT_HOME="${PLAYGROUND}/${GITHUB_REF}"
# /**
# * </div><!-- #Default-Values.section -->
# *
# * <div id="Option-Processing" class="section">
# * <div class="section-header"><span>Option Processing</span></div>
# */
function usage() {
echo "Installs and initializes a Conveyor environment on the host."
echo
echo "install [--force]"
echo
echo "Options:"
echo
echo "--force"
echo " Normally, we check that the target system is supported and there is no existing"
echo " installation. Forcing the install skips these particular checks. It can be used"
echo " to install on self-supported or experimental distros as well as to attempt (a"
echo " rather simple) repair of a broken or incomplete install."
echo
echo "--checkout-version|-c"
echo " Specifies the version to use. Note, the nix and git install each use independent"
echo " versions; even for two that would produce the same runtime."
echo
echo "--playground|-p <dir>"
echo " Specifies the location of playground."
echo
}
FORCE_CORE=false
FORCE_DISTRO=false
TMP=`getopt --name=$0 -a --longoptions=force -o f -- $@`
eval set -- $TMP
until [ $1 == -- ]; do
case "$1" in
-f|--force)
FORCE_CORE=true;;
-c|--checkout-version)
CHECKOUT_VERSION="$2"
shift;;
esac
shift
done
shift
PREREQUISITES_GOOD=true
# Need to be able to 'sudo' root for certain operations. TODO: with
# the adoption of nix, some of the original motives for this are no
# longer true. For SOME use cases it is necessary, but not for basic
# operation. Before release, let's be sure and do test with this
# restriction removed to see how easy it is.
if [[ `sudo -n echo foo 2>/dev/null` != 'foo' ]]; then
echo "Conveyor expects user to have full 'sudo' no-password privileges." >&2
PREREQUISITES_GOOD='false'
fi
if [[ $PREREQUISITES_GOOD != 'true' ]]; then
echo "Consider using using the Conveyor vagrant VM:".
echo " curl -o Vagrantfile -fsSL https://raw.githubusercontent.com/DogFoodSoftware/conveyor-core/master/Vagrantfile"
echo " vagrant up"
exit 1
fi
# TODO: do a dry run to check whether we can connect to the git repo.
# /**
# * </div><!-- #Prerequisite-Checks.section -->
# */
source /etc/environment
if [ -z $CON_USER ]; then # Assume none of the conveyor vars are set.
# Note that variable expansion does NOT work in /etc/environment.
# https://help.ubuntu.com/community/EnvironmentVariables#A.2Fetc.2Fenvironment
PLAYGROUND=/home/$USER/playground
sudo bash -c "echo 'export CON_USER=$USER' >> /etc/environment"
sudo bash -c "echo 'export PLAYGROUND=/home/$USER/playground' >> /etc/environment"
sudo bash -c "echo 'export RUNTIME_HOME=/home/$USER/runtime' >> /etc/environment"
sudo bash -c "echo 'export DOCUMENTATION_HOME=/home/$USER/documentation' >> /etc/environment"
sudo bash -c "echo 'export CONVEYOR_CORE=$PLAYGROUND/DogFoodSoftware/conveyor-core' >> /etc/environment"
source /etc/environment
fi
for i in "$PLAYGROUND" \
"$CONVEYOR_DATA/files/css" \
"$CONVEYOR_DATA/files/js" \
"$CONVEYOR_DATA/files/fonts" \
"$CONVEYOR_DATA/files/svg" \
"$CONVEYOR_DATA/conf/html/ui" \
"$CONVEYOR_DATA/apps"; do
if [ ! -d "$i" ]; then
mkdir -p "$i"
fi
done
echo "Updating and installing node..."
# Add repo for node 0.12
INSTALL_TRY=0
MAX_TRY=3
NODE_12_SETUP=1 # false in bash
set +e
# Appearently 'apt-get update' can get tripped up on a race condition.
# http://askubuntu.com/questions/553765/failed-to-fetch-update-on-ubuntu-14-04-lts-trusty-tahr
while [ ! $NODE_12_SETUP ]; do
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
if [ ! $? ]; then
INSTALL_TRY=$(($INSTALL_TRY + 1))
# Yes, this 'if' makes the while check redundant, but we keep
# for readability.
if [ $INSTALL_TRY -ge $MAX_TRY ]; then
echo "Could not install nodesource." >&2
exit 1
else
sudo rm /var/lib/apt/lists/* -vf
fi
else
NODE_12_SETUP=0 # bash for true
fi
done
set -e
sudo apt-get update
# 'build-essential' and 'g++' are used in some npm installs.
WEB_SERVICES="build-essential g++ nodejs nginx npm php5-fpm git unzip"
sudo apt-get install -y $WEB_SERVICES
# Create symbolic link between nodejs and node
# This is done because some older programs still
# call nodejs with an older syntax
sudo ln -s /usr/bin/nodejs /usr/bin/node
cd "$PLAYGROUND"
# We checkout via HTTPS in case the 'ssh-agent' isn't available when
# the script is run; such as when the script is run with an alternate
# user using 'sudo'.
git clone -b $CONVEYOR_VER --depth 1 https://github.com/${GITHUB_REF}.git $GITHUB_REF
# But then swtich to SSH for easy updates for those with authorized keys.
cd "$GITHUB_REF"
git remote set-url origin [email protected]:${GITHUB_REF}.git
source $CONVEYOR_CORE/src/lib/conveyor-libs.sh
con_safe_mkdir \
$DOCUMENTATION_HOME \
$RUNTIME_HOME \
$RUNTIME_HOME/logs \
$RUNTIME_HOME/logs/environment \
/home/$CON_USER/bin
# Link in the HTML template pages.
for i in `ls ${PROJECT_HOME}/conf/html/template-page-*.php`; do
ln -s "$i" $HOME/data/conf/html/
done
# Link in the REST service configurations.
sudo mkdir -p /etc/nginx/services
sudo chown -R vagrant:vagrant /etc/nginx/services
for i in `ls ${PROJECT_HOME}/conf/service-*.nginx.conf`; do
ln -s "$i" /etc/nginx/services
done
ln -s "${PROJECT_HOME}/conf/default.minify.php" "$HOME/data/conf/html/"
sudo patch /etc/nginx/fastcgi_params $HOME/playground/DogFoodSoftware/conveyor-core/conf/fastcgi_params.nginx.patch
sudo service nginx restart
# TODO: Really, we should process the file for the directive and append...
sudo patch /etc/php5/fpm/php.ini $HOME/playground/DogFoodSoftware/conveyor-core/conf/php5-fpm-ini.patch
sudo service php5-fpm restart
# not sure why, but direct install not working (2015-09-16)
# bash -c $(curl -fsSL https://raw.githubusercontent.com/DogFoodSoftware/conveyor-minify/master/install)
curl -fsSL https://raw.githubusercontent.com/DogFoodSoftware/conveyor-minify/master/install > minify-install.tmp
bash minify-install.tmp
rm minify-install.tmp
# Grab default JS.
cd "$CONVEYOR_DATA/files/js"
curl -fsSL http://code.jquery.com/jquery-2.1.4.js > jquery-2.1.4.js
curl -fsSL https://raw.githubusercontent.com/HenrikJoreteg/ICanHaz.js/9b40b59d7ace192741546a2399da3de0cb5ba44f/ICanHaz.js > ICanHaz-0.10.2.js
curl -fsSL https://raw.githubusercontent.com/garand/sticky/7136048f53d11bd2f483fb912e40fda68d99c44a/jquery.sticky.js > jquery.sticky-1.0.3.js
# Setting up jquery UI is a bit more involved
mkdir -p ~/tmp
cd ~/tmp
curl -fsSL http://jqueryui.com/resources/download/jquery-ui-1.11.4.zip > jquery-ui-1.11.4.zip
unzip jquery-ui-1.11.4.zip
cd jquery-ui-1.11.4
cp jquery-ui.js "$CONVEYOR_DATA/files/js/jquery-ui-1.11.4.js"
cp jquery-ui.css "$CONVEYOR_DATA/files/css/jquery-ui-1.11.4.css"
# Setup Bootstrap
cd "$CONVEYOR_DATA/apps"
if [ -d 'bootstrap' ]; then
rm -rf bootstrap
fi
BOOTSTRAP_REV="v3.3.5"
git clone -b ${BOOTSTRAP_REV} --depth 1 https://github.com/twbs/bootstrap.git bootstrap
ln -s "$CONVEYOR_DATA/apps/bootstrap/dist/js/bootstrap.js" "$CONVEYOR_DATA/files/js/bootstrap-3.3.5.js"
# Setup default style, Liquid-Labs/bi-curious
cd "$PLAYGROUND"
# BI_CURIOUS_REV="master"
# git clone -b ${BI_CURIOUS_REV} --depth 1 https://github.com/Liquid-Labs/bi-curious.git bi-curious
git clone https://github.com/Liquid-Labs/bi-curious.git Liquid-Labs/bi-curious
cd Liquid-Labs/bi-curious
git remote set-url origin [email protected]:Liquid-Labs/bi-curious.git
sudo npm install -g less
lessc src/less/master.less > $HOME/data/files/css/master.css
mkdir -p $HOME/data/files/images
# TODO: should go ahead and add root-level project for name spacing?
ln -s $HOME/playground/Liquid-Labs/bi-curious/files/images/* $HOME/data/files/images
mkdir -p $HOME/data/fonts
ln -s $CONVEYOR_DATA/apps/bootstrap/fonts/* $CONVEYOR_DATA/files/fonts
# Setup third party PHP lib... TODO: pretty sure we will want to
# switch to composer and drop this stuff.
cd "$CONVEYOR_DATA/apps"
if [ -d 'parsedown' ]; then
rm -rf parsedown
fi
mkdir parsedown
curl -f https://raw.githubusercontent.com/erusev/parsedown/3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7/Parsedown.php > parsedown/Parsedown.php
con_doc_link $CONVEYOR_CORE/documentation /DogFoodSoftware.conveyor-core
ln -s $HOME/playground/DogFoodSoftware/conveyor-core $DOCUMENTATION_HOME/DogFoodSoftware.conveyor-core/src
ln -s $CONVEYOR_CORE/src/documentation/global_intro $DOCUMENTATION_HOME/_intro