Parcourir la source

Deprecate searx

It's not likely to be useful
Bob Mottram il y a 8 ans
Parent
révision
e898de4e21
1 fichiers modifiés avec 0 ajouts et 291 suppressions
  1. 0
    291
      src/freedombone-app-searx

+ 0
- 291
src/freedombone-app-searx Voir le fichier

@@ -1,291 +0,0 @@
1
-#!/bin/bash
2
-#
3
-# .---.                  .              .
4
-# |                      |              |
5
-# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
-# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
-# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
-#
9
-#                    Freedom in the Cloud
10
-#
11
-# Searx engine application
12
-#
13
-# License
14
-# =======
15
-#
16
-# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
17
-#
18
-# This program is free software: you can redistribute it and/or modify
19
-# it under the terms of the GNU Affero General Public License as published by
20
-# the Free Software Foundation, either version 3 of the License, or
21
-# (at your option) any later version.
22
-#
23
-# This program is distributed in the hope that it will be useful,
24
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
-# GNU Affero General Public License for more details.
27
-#
28
-# You should have received a copy of the GNU Affero General Public License
29
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30
-
31
-VARIANTS=''
32
-
33
-IN_DEFAULT_INSTALL=0
34
-SHOW_ON_ABOUT=1
35
-
36
-SEARX_REPO="https://github.com/asciimoo/searx"
37
-SEARX_COMMIT='fee556c9904637051a9ba874ba7e71cd9f10789f'
38
-SEARX_PATH=/etc
39
-SEARX_ONION_PORT=8094
40
-SEARX_ONION_HOSTNAME=
41
-SEARX_LOGIN_TEXT=$"Search engine login"
42
-SEARX_PASSWORD=
43
-
44
-searx_variables=(SEARX_REPO
45
-                 SEARX_COMMIT
46
-                 SEARX_PATH
47
-                 SEARX_LOGIN_TEXT
48
-                 MY_USERNAME
49
-                 SYSTEM_TYPE)
50
-
51
-function install_interactive_searx {
52
-    echo -n ''
53
-    APP_INSTALLED=1
54
-}
55
-
56
-function change_password_searx {
57
-    echo -n ''
58
-}
59
-
60
-function reconfigure_searx {
61
-    echo -n ''
62
-}
63
-
64
-function upgrade_searx {
65
-    set_repo_commit $SEARX_PATH/searx "Search engine commit" "$SEARX_COMMIT" $SEARX_REPO
66
-    if grep "Search engine key" $COMPLETION_FILE; then
67
-        if [ -f ${SEARX_PATH}/searx/searx/settings.yml ]; then
68
-            # note: this might change to a --tor option in a later version
69
-            if ! grep 'socks5://127.0.0.1:9050' ${SEARX_PATH}/searx/searx/settings.yml; then
70
-                echo 'outgoing: # communication with search engines' >> ${SEARX_PATH}/searx/searx/settings.yml
71
-                echo '    proxies:' >> ${SEARX_PATH}/searx/searx/settings.yml
72
-                echo '        http : socks5://127.0.0.1:9050' >> ${SEARX_PATH}/searx/searx/settings.yml
73
-                echo '        https: socks5://127.0.0.1:9050' >> ${SEARX_PATH}/searx/searx/settings.yml
74
-            fi
75
-            SEARX_SECRET_KEY=$(get_completion_param "searx key")
76
-            sed -i "s|secret_key.*|secret_key : \"${SEARX_SECRET_KEY}\"|g" ${SEARX_PATH}/searx/searx/settings.yml
77
-            if [ -f /var/lib/tor/hidden_service_searx/hostname ]; then
78
-                SEARX_ONION_HOSTNAME=$(echo /var/lib/tor/hidden_service_searx/hostname)
79
-                sed -i '0,/RE/s/base_url.*/base_url : \"http://${SEARX_ONION_HOSTNAME}\/' ${SEARX_PATH}/searx/searx/settings.yml
80
-            fi
81
-        fi
82
-    fi
83
-}
84
-
85
-function backup_local_searx {
86
-    echo -n ''
87
-}
88
-
89
-function restore_local_searx {
90
-    echo -n ''
91
-}
92
-
93
-function backup_remote_searx {
94
-    echo -n ''
95
-}
96
-
97
-function restore_remote_searx {
98
-    echo -n ''
99
-}
100
-
101
-function remove_searx {
102
-    systemctl stop searx
103
-    systemctl disable searx
104
-    rm /etc/systemd/system/searx.service
105
-    function_check remove_onion_service
106
-    remove_onion_service searx ${SEARX_ONION_PORT}
107
-    userdel -r searx
108
-    nginx_dissite searx
109
-    if [ -f /etc/nginx/sites-available/searx ]; then
110
-        rm /etc/nginx/sites-available/searx
111
-    fi
112
-    if [ -d ${SEARX_PATH}/searx ]; then
113
-        rm -rf ${SEARX_PATH}/searx
114
-    fi
115
-    remove_completion_param install_searx
116
-    sed -i '/Search engine /d' $COMPLETION_FILE
117
-    sed -i '/Search Engine /d' /home/$MY_USERNAME/README
118
-    sed -i '/Search engine /d' /home/$MY_USERNAME/README
119
-    sed -i '/search engine /d' /home/$MY_USERNAME/README
120
-}
121
-
122
-function install_searx {
123
-    # Note: currently socks5 outgoing proxies to other search engines does not work
124
-    if [ ! -d /etc/nginx ]; then
125
-        echo $'Webserver is not installed'
126
-        exit 62429
127
-    fi
128
-
129
-    apt-get -yq install python-pip libyaml-dev python-werkzeug python-babel python-lxml apache2-utils
130
-    apt-get -yq install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev uwsgi uwsgi-plugin-python libapache2-mod-uwsgi
131
-
132
-    pip install --upgrade pip
133
-
134
-    pip install certifi
135
-    if [ ! "$?" = "0" ]; then
136
-        echo $'Failed to install certifi'
137
-        exit 737692
138
-    fi
139
-
140
-    pip install pyyaml
141
-    if [ ! "$?" = "0" ]; then
142
-        echo $'Failed to install pyyaml'
143
-        exit 469242
144
-    fi
145
-
146
-    pip install flask --upgrade
147
-    if [ ! "$?" = "0" ]; then
148
-        echo $'Failed to install flask'
149
-        exit 888575
150
-    fi
151
-
152
-    pip install flask_restless --upgrade
153
-    if [ ! "$?" = "0" ]; then
154
-        echo $'Failed to install flask_restless'
155
-        exit 54835
156
-    fi
157
-
158
-    pip install flask_babel --upgrade
159
-    if [ ! "$?" = "0" ]; then
160
-        echo $'Failed to install flask_babel'
161
-        exit 63738
162
-    fi
163
-
164
-    if [ ! -d $SEARX_PATH ]; then
165
-        mkdir -p $SEARX_PATH
166
-    fi
167
-
168
-    # clone the repo
169
-    cd $SEARX_PATH
170
-    function_check git_clone
171
-    git_clone $SEARX_REPO searx
172
-    git checkout $SEARX_COMMIT -b $SEARX_COMMIT
173
-    set_completion_param "searx commit" "$SEARX_COMMIT"
174
-
175
-    # create an onion service
176
-    SEARX_ONION_HOSTNAME=$(add_onion_service searx 80 ${SEARX_ONION_PORT})
177
-
178
-    # an unprivileged user to run as
179
-    useradd -d ${SEARX_PATH}/searx/ -s /bin/false searx
180
-    adduser searx debian-tor
181
-
182
-    # daemon
183
-    echo '[Unit]' > /etc/systemd/system/searx.service
184
-    echo 'Description=Searx (search engine)' >> /etc/systemd/system/searx.service
185
-    echo 'After=syslog.target' >> /etc/systemd/system/searx.service
186
-    echo 'After=network.target' >> /etc/systemd/system/searx.service
187
-    echo '' >> /etc/systemd/system/searx.service
188
-    echo '[Service]' >> /etc/systemd/system/searx.service
189
-    echo 'Type=simple' >> /etc/systemd/system/searx.service
190
-    echo 'User=searx' >> /etc/systemd/system/searx.service
191
-    echo 'Group=searx' >> /etc/systemd/system/searx.service
192
-    echo "WorkingDirectory=${SEARX_PATH}/searx" >> /etc/systemd/system/searx.service
193
-    echo "ExecStart=/usr/bin/python ${SEARX_PATH}/searx/searx/webapp.py" >> /etc/systemd/system/searx.service
194
-    echo 'Restart=always' >> /etc/systemd/system/searx.service
195
-    echo 'Environment="USER=searx"' >> /etc/systemd/system/searx.service
196
-    echo '' >> /etc/systemd/system/searx.service
197
-    echo '[Install]' >> /etc/systemd/system/searx.service
198
-    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/searx.service
199
-
200
-    # create a webserver file
201
-    echo 'server {' > /etc/nginx/sites-available/searx
202
-    echo "    listen 127.0.0.1:${SEARX_ONION_PORT} default_server;" >> /etc/nginx/sites-available/searx
203
-    echo "    root ${SEARX_PATH}/searx;" >> /etc/nginx/sites-available/searx
204
-    echo "    server_name ${SEARX_ONION_HOSTNAME};" >> /etc/nginx/sites-available/searx
205
-    echo '    access_log /dev/null;' >> /etc/nginx/sites-available/searx
206
-    echo "    error_log /var/log/searx_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/searx
207
-    echo '' >> /etc/nginx/sites-available/searx
208
-    function_check nginx_disable_sniffing
209
-    nginx_disable_sniffing searx
210
-    echo '    add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/searx
211
-    echo '' >> /etc/nginx/sites-available/searx
212
-    echo '    location / {' >> /etc/nginx/sites-available/searx
213
-    function_check nginx_limits
214
-    nginx_limits searx '1M'
215
-    echo '        proxy_pass http://localhost:8888;' >> /etc/nginx/sites-available/searx
216
-    echo '        proxy_set_header Host $host;' >> /etc/nginx/sites-available/searx
217
-    echo '        proxy_set_header X-Real-IP $remote_addr;' >> /etc/nginx/sites-available/searx
218
-    echo '        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;' >> /etc/nginx/sites-available/searx
219
-    echo '        proxy_set_header X-Remote-Port $remote_port;' >> /etc/nginx/sites-available/searx
220
-    echo '        proxy_set_header X-Forwarded-Proto $scheme;' >> /etc/nginx/sites-available/searx
221
-    echo '        proxy_redirect off;' >> /etc/nginx/sites-available/searx
222
-
223
-    echo "        auth_basic \"${SEARX_LOGIN_TEXT}\";" >> /etc/nginx/sites-available/searx
224
-    echo '        auth_basic_user_file /etc/nginx/.htpasswd;' >> /etc/nginx/sites-available/searx
225
-    echo '    }' >> /etc/nginx/sites-available/searx
226
-    echo '' >> /etc/nginx/sites-available/searx
227
-    echo '    fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/searx
228
-    echo '' >> /etc/nginx/sites-available/searx
229
-    echo '    error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/searx
230
-    echo '    error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/searx
231
-    echo '' >> /etc/nginx/sites-available/searx
232
-    echo '    location = /robots.txt {' >> /etc/nginx/sites-available/searx
233
-    echo '        allow all;' >> /etc/nginx/sites-available/searx
234
-    echo '        log_not_found off;' >> /etc/nginx/sites-available/searx
235
-    echo '        access_log /dev/null;' >> /etc/nginx/sites-available/searx
236
-    echo '    }' >> /etc/nginx/sites-available/searx
237
-    echo '}' >> /etc/nginx/sites-available/searx
238
-
239
-    # replace the secret key
240
-    if ! grep "searx key" $COMPLETION_FILE; then
241
-        SEARX_SECRET_KEY="$(create_password 30)"
242
-    fi
243
-    set_completion_param "searx key" "${SEARX_SECRET_KEY}"
244
-    sed -i "s|secret_key.*|secret_key : \"${SEARX_SECRET_KEY}\"|g" ${SEARX_PATH}/searx/searx/settings.yml
245
-    sed -i "s|secret_key.*|secret_key : \"${SEARX_SECRET_KEY}\"|g" ${SEARX_PATH}/searx/searx/settings_robot.yml
246
-    sed -i '0,/RE/s/base_url.*/base_url : \"http://${SEARX_ONION_HOSTNAME}\/' ${SEARX_PATH}/searx/searx/settings.yml
247
-    sed -i '0,/RE/s/base_url.*/base_url : \"http://${SEARX_ONION_HOSTNAME}\/' ${SEARX_PATH}/searx/searx/settings_robot.yml
248
-
249
-    # note: this might change to a --tor option in a later version
250
-    if ! grep 'socks5://127.0.0.1:9050' ${SEARX_PATH}/searx/searx/settings.yml; then
251
-        echo 'outgoing: # communication with search engines' >> ${SEARX_PATH}/searx/searx/settings.yml
252
-        echo '    proxies:' >> ${SEARX_PATH}/searx/searx/settings.yml
253
-        echo '        http : socks5://127.0.0.1:9050' >> ${SEARX_PATH}/searx/searx/settings.yml
254
-        echo '        https: socks5://127.0.0.1:9050' >> ${SEARX_PATH}/searx/searx/settings.yml
255
-    fi
256
-
257
-    chown -R searx:searx ${SEARX_PATH}/searx
258
-
259
-    # enable the site
260
-    nginx_ensite searx
261
-
262
-    # restart the web server
263
-    systemctl restart php5-fpm
264
-    systemctl restart nginx
265
-
266
-    # start the daemon
267
-    systemctl enable searx.service
268
-    systemctl daemon-reload
269
-    systemctl start searx.service
270
-
271
-    if ! grep -q "Your search engine password is" /home/$MY_USERNAME/README; then
272
-        if [ ${#SEARX_PASSWORD} -lt 8 ]; then
273
-            if [ -f $IMAGE_PASSWORD_FILE ]; then
274
-                SEARX_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
275
-            else
276
-                SEARX_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
277
-            fi
278
-        fi
279
-        echo "$SEARX_PASSWORD" | htpasswd -i -s -c /etc/nginx/.htpasswd $MY_USERNAME
280
-        echo '' >> /home/$MY_USERNAME/README
281
-        echo '' >> /home/$MY_USERNAME/README
282
-        echo $'# Search Engine' >> /home/$MY_USERNAME/README
283
-        echo $"Search engine onion domain: ${SEARX_ONION_HOSTNAME}" >> /home/$MY_USERNAME/README
284
-        echo $"Your search engine password is: $SEARX_PASSWORD" >> /home/$MY_USERNAME/README
285
-        chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
286
-        chmod 600 /home/$MY_USERNAME/README
287
-    fi
288
-    APP_INSTALLED=1
289
-}
290
-
291
-# NOTE: deliberately no exit 0