-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinspire_fresh.sh
executable file
·255 lines (231 loc) · 7.59 KB
/
inspire_fresh.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
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/bash
# v0.0.1
# Install fresh Inspire pu instance
# Tested on Ubuntu 13.04
# Pedro Gaudêncio <[email protected]>
configfile=fresh.cfg
BRANCH=pu
#set -e
usage="$(basename "$0") [-h] [-v] [-d] -- install fresh Inspire pu instance
where:
-h show this help text
-v set name for the virtualenv (default: invenio)
-d set name for the database (default: pu)"
while getopts ':hvd:' option; do
case "${option}" in
h) echo "$usage"; exit;;
v) VIRTUALENV=${OPTARG};;
d) DATABASE_NAME=${OPTARG};;
esac
done
shift $((OPTIND - 1))
activate_venvwrapper () {
echo "Activating virtualenvwrapper..."
source `which virtualenvwrapper.sh` || source "/usr/local/bin/virtualenvwrapper.sh"
}
source_cfg_file() {
# check if the file contains something we don't want
if egrep -q -v '^#|^[^ ]*=[^;]*' "$configfile"; then
echo "Config file is unclean, cleaning it..." >&2
# filter the original to a new file
egrep '^#|^[^ ]*=[^;&]*' "$configfile" > "$configfile_secured"
configfile="$configfile_secured"
fi
# now source it, either the original or the filtered variant
source "$configfile"
}
create_vars() {
echo "Creating path variables..."
if [ ! $VIRTUALENV ]; then
if [ ! $virtual_env ]; then
VIRTUALENV="invenio"
else
VIRTUALENV=$virtual_env
fi
fi
if [ $use_previous_db ]; then
DATABASE_NAME=$use_previous_db
else
if [ ! $DATABASE_NAME ]; then
DATABASE_NAME=$BRANCH
fi
fi
}
create_workdirs() {
if [ ! -d $HOME/bin ]; then
echo "Creating script directories $HOME/bin..."
mkdir -p $HOME/bin
fi
if [ ! -f $HOME/bin/git-new-workdir ]; then
echo "Setting up git-new-workdir..."
wget https://raw.github.com/git/git/master/contrib/workdir/git-new-workdir \
-O $HOME/bin/git-new-workdir
chmod +x $HOME/bin/git-new-workdir
fi
}
create_workenv() {
if [ ! -d $HOME/src ]; then
echo "Creating working environment $HOME/src..."
mkdir -p $HOME/src; cd $HOME/src/
else
cd $HOME/src/
fi
if [ $repo_invenio ] && [ $branch_invenio ] && [ $repo_invenio_remote_name ]; then
if [ ! -d $HOME/src/invenio ]; then
git clone --branch $branch_invenio $repo_invenio
else
cd $HOME/src/invenio
# if remote exists
if [[ "$(git remote | grep $repo_invenio_remote_name)" ]]; then
# if wanted repo is the current one and branch exists
branch_exists=`git show-ref refs/heads/$branch_invenio`
if [[ $repo_invenio == "$(git ls-remote --get-url)" ]] && [ -n "$branch_exists" ]; then
if [[ $branch_invenio != "$(git symbolic-ref --short HEAD 2>/dev/null)" ]]; then
git checkout $branch_invenio
fi
else
git fetch $repo_invenio_remote_name $branch_invenio
git checkout $repo_invenio_remote_name/$branch_invenio
git checkout -b $branch_invenio
fi
else
git remote add $repo_invenio_remote_name $repo_invenio
git fetch $repo_invenio_remote_name $branch_invenio
git checkout $repo_invenio_remote_name/$branch_invenio
git checkout -b $branch_invenio
fi
fi
else
if [ ! -d $HOME/src/invenio ]; then
git clone --branch $BRANCH git://github.com/inveniosoftware/invenio.git
fi
fi
if [ ! -d $WORKON_HOME/$VIRTUALENV ]; then
mkvirtualenv $VIRTUALENV
else
echo "$VIRTUALENV virtualenv already exists, proceeding work on $VIRTUALENV."
fi
workon $VIRTUALENV || source $WORKON_HOME/$VIRTUALENV/bin/activate
cdvirtualenv
mkdir -p var/run/
mkdir src; cd src
if [ $branch_invenio ]; then
$HOME/bin/git-new-workdir $HOME/src/invenio/ invenio $branch_invenio
else
$HOME/bin/git-new-workdir $HOME/src/invenio/ invenio $BRANCH
fi
}
install_invenio() {
echo "Installing Invenio..."
cd invenio
pip install -r requirements.txt
pip install -e .
if [ $install_ipython == true ]; then
pip install ipython
fi
if [ $unit_tests == true ]; then
pip install nose Flask-Testing httpretty
fi
python setup.py compile_catalog
}
install_inspire() {
echo "Installing Inspire..."
cd $HOME/src
if [ $repo_inspire ] && [ $branch_inspire ] && [ $repo_inspire_remote_name ]; then
if [ ! -d $HOME/src/invenio ]; then
git clone --branch $branch_inspire $repo_inspire
else
cd $HOME/src/inspire-next
# if remote exists
if [[ "$(git remote | grep $repo_inspire_remote_name)" ]]; then
# if wanted repo is the current one and branch exists
branch_exists=`git show-ref refs/heads/$branch_inspire`
if [[ $repo_inspire == "$(git ls-remote --get-url)" ]] && [ -n "$branch_exists" ]; then
if [[ $branch_inspire != "$(git symbolic-ref --short HEAD 2>/dev/null)" ]]; then
git checkout $branch_inspire
fi
else
git fetch $repo_inspire_remote_name $branch_inspire
git checkout $repo_inspire_remote_name/$branch_inspire
git checkout -b $branch_inspire
fi
else
git remote add $repo_inspire_remote_name $repo_inspire
git fetch $repo_inspire_remote_name $branch_inspire
git checkout $repo_inspire_remote_name/$branch_inspire
git checkout -b $branch_inspire
fi
fi
else
if [ ! -d $HOME/src/inspire-next ]; then
git clone [email protected]:inspirehep/inspire-next.git
fi
fi
cdvirtualenv src/
$HOME/bin/git-new-workdir $HOME/src/inspire-next/ inspire-next
cd inspire-next
pip install -r requirements.txt --exists-action i
inveniomanage bower -i bower-base.json > bower.json
bower install
}
config_invenio() {
echo "Configuring Invenio..."
inveniomanage config create secret-key
inveniomanage config set CFG_EMAIL_BACKEND flask.ext.email.backends.console.Mail
inveniomanage config set CFG_BIBSCHED_PROCESS_USER $USER
inveniomanage config set CFG_DATABASE_NAME $DATABASE_NAME
inveniomanage config set CFG_DATABASE_USER $BRANCH
inveniomanage config set CFG_SITE_URL http://0.0.0.0:4000
inveniomanage config set CFG_SITE_SECURE_URL http://0.0.0.0:4000
inveniomanage config set CFG_BIBSCHED_NON_CONCURRENT_TASKS "[]"
inveniomanage config set COLLECT_STORAGE invenio.ext.collect.storage.link
npm install less clean-css requirejs uglify-js
inveniomanage config set LESS_BIN `find $PWD/node_modules -iname lessc | head -1`
inveniomanage config set CLEANCSS_BIN `find $PWD/node_modules -iname cleancss | head -1`
inveniomanage config set REQUIREJS_BIN `find $PWD/node_modules -iname r.js | head -1`
inveniomanage config set UGLIFYJS_BIN `find $PWD/node_modules -iname uglifyjs | head -1`
inveniomanage config set REQUIREJS_RUN_IN_DEBUG False
inveniomanage config set DEBUG True
inveniomanage config set ASSETS_DEBUG True
inveniomanage config set DEBUG_TB_INTERCEPT_REDIRECTS False
inveniomanage config set DOI_SEARCH_PREFIX "u'doi:'"
inveniomanage config set ARXIV_SEARCH_PREFIX "u'035__a:oai:arXiv.org:'"
#TODO: add extensions:
#from invenio.base.config import EXTENSIONS as _EXTENSIONS
#inveniomanage config set EXTENSIONS "_EXTENSIONS + ['invenio.ext.arxiv:Arxiv', 'invenio.ext.crossref:CrossRef']"
}
populate_inspire() {
echo "Configuring Inspire..."
inveniomanage collect
if [ ! $use_previous_db ]; then
if [ $mysql_root_passwd ]; then
inveniomanage database init --yes-i-know --user=root --password=$mysql_root_passwd
else
inveniomanage database init --yes-i-know --user=root --password=mysql
fi
#inveniomanage database create
inveniomanage demosite populate -p inspire.base -f inspire/testsuite/data/demo-records.xml
fi
}
config_git() {
if [ $git_mail ]; then
cdvirtualenv src/invenio
git config user.email "$git_mail"
cdvirtualenv src/inspire-next
git config user.email "$git_mail"
fi
}
install_fresh_inspire() {
activate_venvwrapper
source_cfg_file
create_vars
create_workdirs
create_workenv
install_invenio
install_inspire
config_invenio
populate_inspire
config_git
printf "\n\nFinished. Enjoy your Inspire instalation!\n\n"
}
install_fresh_inspire