-
Notifications
You must be signed in to change notification settings - Fork 3
/
install
executable file
·142 lines (125 loc) · 2.51 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
#!/bin/bash
set -eu
prog_name=$(basename $0)
DBUSER=openspending
DBNAME=openspending
DBPASS=openspending
GIT_REPO=http://github.com/openspending/openspending.git
JS_REPO=http://github.com/openspending/openspendingjs.git
TARGET_DIR=openspending
VIRTUALENV=virtualenv
CREATEDBOPTS="-E utf-8"
SOLR_DIR=solr
NO_VIRTUALENV='true'
CLONE='true'
while [ $# -gt 0 ];
do
case "$1" in
--git-repo)
GIT_REPO=$2
shift 2
;;
--js-repo)
JS_REPO=$2
shift 2
;;
--target-dir)
TARGET_DIR=$2
shift 2
;;
--db-user)
DBUSER=$2
shift 2
;;
--db-name)
DBNAME=$2
shift 2
;;
--db-pass)
DBPASS=$2
shift 2
;;
--virtualenv)
VIRTUALENV=$2
shift 2
;;
--solr-dir)
SOLR_DIR=$2
shift 2
;;
--no-virtualenv)
NO_VIRTUALENV=''
shift 1
;;
--no-clone)
CLONE=''
shift 1
;;
*)
echo ${prog_name}: unrecognised option: $1
exit 1
;;
esac
done
setup_virtualenv () {
# should explicitly use python2.7
$VIRTUALENV ./pyenv
set +u
source ./pyenv/bin/activate
set -u
}
install_requirements () {
pip install nose==1.1.2
pip install paste
pip install pastedeploy
pip install PasteScript==1.7.5
pip install -r requirements.txt -e .
pip install psycopg2
}
clone_js () {
git clone $JS_REPO
PWD=`pwd`
ln -s "$PWD/openspendingjs" openspending/ui/public/static/openspendingjs
}
setup_dev_ini () {
cp development.ini_tmpl development.ini
cat development.ini_tmpl | \
sed "s/^openspending.db.url = .*$/openspending.db.url = postgresql:\/\/${DBUSER}:${DBPASS}@localhost\/${DBNAME}/" > \
development.ini
}
setup_db () {
local CREATEDBOPTS=""
if [ $DBUSER ]; then
CREATEDBOPTS="$CREATEDBOPTS --owner $DBUSER"
fi
env PGPASSWORD="$DBPASS" createdb -U "$DBUSER" $CREATEDBOPTS $DBNAME
ostool development.ini db init
}
setup_docs () {
git submodule init && git submodule update
(cd doc && make clean html)
}
setup_solr () {
PWD=`pwd`
CONFIG="$PWD/solr/openspending_schema.xml"
mv $SOLR_DIR/example/solr/collection1/conf/schema.xml \
$SOLR_DIR/example/solr/collection1/conf/schema.xml.back
ln -sfT $CONFIG $SOLR_DIR/example/solr/collection1/conf/schema.xml
}
if [ -n "$CLONE" ]; then
if [ -d $TARGET_DIR ]; then
echo ${prog_name}: Directory openspending already exists
exit 1
fi
git clone $GIT_REPO $TARGET_DIR
cd $TARGET_DIR
fi
if [ -n "$NO_VIRTUALENV" ]; then
setup_virtualenv
fi
install_requirements
clone_js
setup_dev_ini # $DBUSER $DBNAME
setup_db # $DBUSER $DBNAME
setup_docs
setup_solr