forked from cfpb/github-wiki-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.py
executable file
·44 lines (34 loc) · 1.35 KB
/
provision.py
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
#! /usr/bin/python
import os
from os.path import join
from os import path
from subprocess import call, Popen
import settings
DIR = path.dirname(path.realpath(__file__))
try:
# update and upgrade all packages
call('sudo apt-get update -y'.split())
call('sudo apt-get upgrade -y'.split())
# install java
call('sudo apt-get install curl openjdk-7-jre-headless -y'.split())
# install python developer packages
call('sudo apt-get install python-dev python-pip libxml2-dev libxslt1-dev -y'.split())
pass
except OSError:
# if apt isn't installed, need to run yum commands
pass
#install elastic search
if 'elasticsearch-1.0.0.tar.gz' not in os.listdir(DIR):
call(['wget', 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.0.tar.gz'])
call(['tar', '-xvzf', join(DIR, 'elasticsearch-1.0.0.tar.gz')])
# install git river
# call([join(DIR, 'elasticsearch-1.0.0/bin/plugin')] + '--install com.bazoud.elasticsearch/elasticsearch-river-git/0.0.3'.split())
# start elasticsearch
Popen(join(DIR, 'elasticsearch-1.0.0/bin/elasticsearch'))
# install python dependencies
call('sudo pip install -r requirements.txt'.split())
# create wiki index with schema
import requests
with open(join(DIR, 'wiki_page_schema.json')) as f:
schema = f.read()
requests.put(settings.ES_HOST + '/wiki', data=schema)