@@ -1,117 +0,0 @@
1−from fabric.api import cd, run, sudo, put
2−from io import StringIO
3−
4−
5−base_dir = '/usr/local'
6−hostname = 'searx.me'
7−searx_dir = base_dir + '/searx'
8−searx_ve_dir = searx_dir + '/searx-ve'
9−current_user = run('whoami').stdout.strip()
10−
11−uwsgi_file = '''
12−[uwsgi]
13−# Who will run the code
14−uid = {user}
15−gid = {user}
16−
17−# Number of workers
18−workers = 8
19−
20−# The right granted on the created socket
21−chmod-socket = 666
22−
23−# Plugin to use and interpretor config
24−single-interpreter = true
25−master = true
26−plugin = python
27−
28−# Module to import
29−module = searx.webapp
30−
31−# Virtualenv and python path
32−virtualenv = {searx_ve_dir}
33−pythonpath = {searx_dir}
34−chdir = {searx_dir}/searx
35−'''.format(user=current_user,
36− searx_dir=searx_dir,
37− searx_ve_dir=searx_ve_dir)
38−
39−nginx_config = '''
40−server {{
41− listen 80;
42− server_name {hostname};
43− server_name www.{hostname};
44− root /usr/local/searx;
45−
46− location / {{
47− include uwsgi_params;
48− uwsgi_pass unix:/run/uwsgi/app/searx/socket;
49− }}
50−}}
51−'''.format(hostname=hostname)
52−
53−
54−def stop():
55− sudo('/etc/init.d/uwsgi stop')
56−
57−
58−def start():
59− sudo('/etc/init.d/uwsgi start')
60−
61−
62−def restart():
63− sudo('/etc/init.d/uwsgi restart')
64−
65−
66−def init():
67− if not run('test -d ' + searx_dir, warn_only=True).failed:
68− return
69−
70− sudo('apt-get update')
71−
72− sudo('apt-get install git'
73− ' build-essential'
74− ' libxslt-dev'
75− ' python-dev'
76− ' python-virtualenv'
77− ' python-pybabel'
78− ' zlib1g-dev'
79− ' uwsgi'
80− ' uwsgi-plugin-python'
81− ' nginx')
82−
83− sudo('mkdir -p ' + base_dir)
84−
85− put(StringIO(nginx_config), '/etc/nginx/sites-enabled/searx', use_sudo=True)
86− sudo('/etc/init.d/nginx restart')
87−
88− with cd(base_dir):
89− sudo('git clone https://github.com/searx/searx')
90−
91− sudo('chown -R {user}:{user} {searx_dir}'.format(user=current_user, searx_dir=searx_dir))
92− put(StringIO(uwsgi_file), searx_dir + '/uwsgi.ini')
93− sudo('ln -s {0}/uwsgi.ini /etc/uwsgi/apps-enabled/searx.ini'.format(searx_dir))
94−
95− run('virtualenv {0}'.format(searx_ve_dir))
96−
97− with cd(searx_dir):
98− run('source {0}/bin/activate && pip install -r requirements.txt'.format(searx_ve_dir))
99−
100− start()
101−
102−
103−def deploy():
104− init()
105−
106− with cd(searx_dir):
107− run("git stash", warn_only=True)
108− run("git pull origin master")
109− run("git stash pop", warn_only=True)
110−
111− restart()
112−
113−
114−def clean():
115− sudo('rm -rf {searx_dir}'.format(searx_dir=searx_dir), warn_only=True)
116− sudo('rm /etc/uwsgi/apps-enabled/searx.ini', warn_only=True)
117− sudo('rm /etc/nginx/sites-enabled/searx', warn_only=True)