freedombone-app-searx 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  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-2017 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. VARIANTS='full full-vim'
  31. IN_DEFAULT_INSTALL=0
  32. SHOW_ON_ABOUT=1
  33. SHOW_ICANN_ADDRESS_ON_ABOUT=0
  34. SEARX_REPO="https://github.com/asciimoo/searx"
  35. SEARX_COMMIT='46a2c63f8e1c3819cceff2d61fe9106051e8ecee'
  36. SEARX_PATH=/etc
  37. SEARX_ONION_PORT=8094
  38. SEARX_ONION_HOSTNAME=
  39. SEARX_LOGIN_TEXT=$"Search engine login"
  40. SEARX_PASSWORD=
  41. SEARX_BACKGROUND_IMAGE_URL=
  42. searx_variables=(SEARX_REPO
  43. SEARX_COMMIT
  44. SEARX_PATH
  45. SEARX_LOGIN_TEXT
  46. MY_USERNAME
  47. SEARX_BACKGROUND_IMAGE_URL
  48. SYSTEM_TYPE)
  49. function searx_set_default_background {
  50. if [ -f ~/freedombone/img/backgrounds/searx.jpg ]; then
  51. cp ~/freedombone/img/backgrounds/searx.jpg /etc/searx/searx/static/themes/courgette/img/bg-body-index.jpg
  52. chown -R searx:searx ${SEARX_PATH}/searx
  53. else
  54. if [ -f /home/$MY_USERNAME/freedombone/img/backgrounds/searx.jpg ]; then
  55. cp /home/$MY_USERNAME/freedombone/img/backgrounds/searx.jpg /etc/searx/searx/static/themes/courgette/img/bg-body-index.jpg
  56. chown -R searx:searx ${SEARX_PATH}/searx
  57. fi
  58. fi
  59. # remove the github ribbon icon
  60. if [ -f /etc/searx/searx/static/themes/courgette/img/github_ribbon.png ]; then
  61. mv /etc/searx/searx/static/themes/courgette/img/github_ribbon.png /etc/searx/searx/static/themes/courgette/img/github_ribbon.png.old
  62. fi
  63. }
  64. function searx_set_background_image_from_url {
  65. url="$1"
  66. ext=
  67. if [ ${#url} -gt 0 ]; then
  68. if [[ "$url" == *".jpeg" || "$url" == *".jpg" ]]; then
  69. ext="jpg"
  70. fi
  71. if [[ "$url" == *".png" ]]; then
  72. ext="png"
  73. fi
  74. if [[ "$url" == *".gif" ]]; then
  75. ext="gif"
  76. fi
  77. fi
  78. if [ ${#ext} -gt 0 ]; then
  79. if [ -d /etc/searx/searx/static/themes/courgette/img ]; then
  80. cd /etc/searx/searx/static/themes/courgette/img
  81. # remove any existing image
  82. if [ -f bg-body-index.jpg ]; then
  83. rm bg-body-index.jpg
  84. fi
  85. # get the new image
  86. if [[ "$ext" != 'jpg' ]]; then
  87. if [ -f bg-body-index.${ext} ]; then
  88. rm bg-body-index.${ext}
  89. fi
  90. wget "$url" -O bg-body-index.${ext}
  91. convert bg-body-index.${ext} bg-body-index.jpg
  92. else
  93. wget "$url" -O bg-body-index.jpg
  94. fi
  95. if [ ! -f bg-body-index.jpg ]; then
  96. echo "$url"
  97. echo $'Custom background image for SearX could not be downloaded'
  98. echo "1"
  99. return
  100. fi
  101. chown -R searx:searx ${SEARX_PATH}/searx
  102. fi
  103. else
  104. echo "2"
  105. return
  106. fi
  107. echo "0"
  108. }
  109. function searx_set_background_image {
  110. data=$(tempfile 2>/dev/null)
  111. trap "rm -f $data" 0 1 2 5 15
  112. dialog --title $"SearX Metasearch" \
  113. --backtitle $"Freedombone Control Panel" \
  114. --inputbox $'Set a background image URL' 10 60 2>$data
  115. sel=$?
  116. case $sel in
  117. 0)
  118. temp_background=$(<$data)
  119. if [ ${#temp_background} -gt 0 ]; then
  120. SEARX_BACKGROUND_IMAGE_URL="$temp_background"
  121. write_config_param "SEARX_BACKGROUND_IMAGE_URL" "$SEARX_BACKGROUND_IMAGE_URL"
  122. if [[ $(searx_set_background_image_from_url "$SEARX_BACKGROUND_IMAGE_URL" | tail -n 1) == "0" ]]; then
  123. dialog --title $"Set SearX background" \
  124. --msgbox $"The background image has been set" 6 60
  125. fi
  126. fi
  127. ;;
  128. esac
  129. }
  130. function configure_interactive_searx {
  131. while true
  132. do
  133. data=$(tempfile 2>/dev/null)
  134. trap "rm -f $data" 0 1 2 5 15
  135. dialog --backtitle $"Freedombone Control Panel" \
  136. --title $"SearX Metasearch" \
  137. --radiolist $"Choose an operation:" 11 70 2 \
  138. 1 $"Set a background image" off \
  139. 2 $"Exit" on 2> $data
  140. sel=$?
  141. case $sel in
  142. 1) return;;
  143. 255) return;;
  144. esac
  145. case $(cat $data) in
  146. 1) searx_set_background_image;;
  147. 2) break;;
  148. esac
  149. done
  150. }
  151. function remove_user_searx {
  152. remove_username="$1"
  153. ${PROJECT_NAME}-pass -u $remove_username --rmapp searx
  154. if grep -q "$remove_username:" /etc/nginx/.htpasswd; then
  155. sed -i "/$remove_username:/d" /etc/nginx/.htpasswd
  156. fi
  157. }
  158. function add_user_searx {
  159. if [[ $(app_is_installed searx) == "0" ]]; then
  160. echo '0'
  161. return
  162. fi
  163. new_username="$1"
  164. new_user_password="$2"
  165. ${PROJECT_NAME}-pass -u $new_username -a searx -p "$new_user_password"
  166. if grep -q "$new_username:" /etc/nginx/.htpasswd; then
  167. sed -i "/$new_username:/d" /etc/nginx/.htpasswd
  168. fi
  169. echo "$new_user_password" | htpasswd -i -s -c /etc/nginx/.htpasswd $new_username
  170. echo '0'
  171. }
  172. function install_interactive_searx {
  173. echo -n ''
  174. APP_INSTALLED=1
  175. }
  176. function change_password_searx {
  177. echo -n ''
  178. }
  179. function reconfigure_searx {
  180. echo -n ''
  181. }
  182. function create_searx_config {
  183. settings_file=${SEARX_PATH}/searx/searx/settings.yml
  184. SEARX_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_searx/hostname)
  185. SEARX_SECRET_KEY=$(get_completion_param "searx key")
  186. echo 'general:' > $settings_file
  187. echo ' debug : False' >> $settings_file
  188. echo ' instance_name : "Freedombone Metasearch"' >> $settings_file
  189. echo '' >> $settings_file
  190. echo 'search:' >> $settings_file
  191. echo ' safe_search : 0 # Filter results. 0: None, 1: Moderate, 2: Strict' >> $settings_file
  192. echo ' autocomplete : "" # Existing autocomplete backends: "dbpedia", "duckduckgo", "startpage", "wikipedia" - leave blank to turn it off by default' >> $settings_file
  193. echo ' language : "all"' >> $settings_file
  194. echo '' >> $settings_file
  195. echo 'server:' >> $settings_file
  196. echo ' port : 8888' >> $settings_file
  197. echo ' bind_address : "127.0.0.1" # address to listen on' >> $settings_file
  198. echo " secret_key : \"${SEARX_SECRET_KEY}\"" >> $settings_file
  199. echo " base_url : http://${SEARX_ONION_HOSTNAME}/" >> $settings_file
  200. echo ' image_proxy : True # Proxying image results through searx' >> $settings_file
  201. echo ' http_protocol_version : "1.1" # 1.0 and 1.1 are supported' >> $settings_file
  202. echo '' >> $settings_file
  203. echo 'ui:' >> $settings_file
  204. echo ' themes_path : "" # Custom ui themes path' >> $settings_file
  205. echo ' default_theme : courgette # ui theme' >> $settings_file
  206. echo ' default_locale : "" # Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section' >> $settings_file
  207. echo '' >> $settings_file
  208. echo 'outgoing: # communication with search engines' >> $settings_file
  209. echo ' request_timeout : 10.0 # seconds' >> $settings_file
  210. echo ' useragent_suffix : "" # suffix of searx_useragent, could contain informations like an email address to the administrator' >> $settings_file
  211. echo ' pool_connections : 100 # Number of different hosts' >> $settings_file
  212. echo ' pool_maxsize : 10 # Number of simultaneous requests by host' >> $settings_file
  213. echo ' proxies :' >> $settings_file
  214. echo ' http : socks5://127.0.0.1:9050' >> $settings_file
  215. echo '' >> $settings_file
  216. echo 'engines:' >> $settings_file
  217. echo ' - name : arch linux wiki' >> $settings_file
  218. echo ' engine : archlinux' >> $settings_file
  219. echo ' categories : general' >> $settings_file
  220. echo ' shortcut : al' >> $settings_file
  221. echo '' >> $settings_file
  222. echo ' - name : archive is' >> $settings_file
  223. echo ' engine : xpath' >> $settings_file
  224. echo ' search_url : https://archive.is/{query}' >> $settings_file
  225. echo ' url_xpath : (//div[@class="TEXT-BLOCK"]/a)/@href' >> $settings_file
  226. echo ' title_xpath : (//div[@class="TEXT-BLOCK"]/a)' >> $settings_file
  227. echo ' content_xpath : //div[@class="TEXT-BLOCK"]/ul/li' >> $settings_file
  228. echo ' categories : general' >> $settings_file
  229. echo ' timeout : 7.0' >> $settings_file
  230. echo ' disabled : True' >> $settings_file
  231. echo ' shortcut : ai' >> $settings_file
  232. echo '' >> $settings_file
  233. echo ' - name : base' >> $settings_file
  234. echo ' engine : base' >> $settings_file
  235. echo ' shortcut : bs' >> $settings_file
  236. echo '' >> $settings_file
  237. echo ' - name : wikipedia' >> $settings_file
  238. echo ' engine : wikipedia' >> $settings_file
  239. echo ' shortcut : wp' >> $settings_file
  240. echo ' categories : general' >> $settings_file
  241. echo ' base_url : "https://{language}.wikipedia.org/"' >> $settings_file
  242. echo '' >> $settings_file
  243. echo ' - name : bitbucket' >> $settings_file
  244. echo ' engine : xpath' >> $settings_file
  245. echo ' paging : True' >> $settings_file
  246. echo ' search_url : https://bitbucket.org/repo/all/{pageno}?name={query}' >> $settings_file
  247. echo ' url_xpath : //article[@class="repo-summary"]//a[@class="repo-link"]/@href' >> $settings_file
  248. echo ' title_xpath : //article[@class="repo-summary"]//a[@class="repo-link"]' >> $settings_file
  249. echo ' content_xpath : //article[@class="repo-summary"]/p' >> $settings_file
  250. echo ' categories : code' >> $settings_file
  251. echo ' timeout : 4.0' >> $settings_file
  252. echo ' disabled : True' >> $settings_file
  253. echo ' shortcut : bb' >> $settings_file
  254. echo '' >> $settings_file
  255. echo ' - name : ccc-tv' >> $settings_file
  256. echo ' engine : xpath' >> $settings_file
  257. echo ' paging : False' >> $settings_file
  258. echo ' search_url : https://media.ccc.de/search/?q={query}' >> $settings_file
  259. echo ' url_xpath : //div[@class="caption"]/h3/a/@href' >> $settings_file
  260. echo ' title_xpath : //div[@class="caption"]/h3/a/text()' >> $settings_file
  261. echo ' content_xpath : //div[@class="caption"]/h4/@title' >> $settings_file
  262. echo ' categories : videos' >> $settings_file
  263. echo ' shortcut : c3tv' >> $settings_file
  264. echo '' >> $settings_file
  265. echo ' - name : crossref' >> $settings_file
  266. echo ' engine : json_engine' >> $settings_file
  267. echo ' paging : True' >> $settings_file
  268. echo ' search_url : http://search.crossref.org/dois?q={query}&page={pageno}' >> $settings_file
  269. echo ' url_query : doi' >> $settings_file
  270. echo ' title_query : title' >> $settings_file
  271. echo ' content_query : fullCitation' >> $settings_file
  272. echo ' categories : science' >> $settings_file
  273. echo ' shortcut : cr' >> $settings_file
  274. echo '' >> $settings_file
  275. echo ' - name : currency' >> $settings_file
  276. echo ' engine : currency_convert' >> $settings_file
  277. echo ' categories : general' >> $settings_file
  278. echo ' shortcut : cc' >> $settings_file
  279. echo '' >> $settings_file
  280. echo ' - name : deezer' >> $settings_file
  281. echo ' engine : deezer' >> $settings_file
  282. echo ' shortcut : dz' >> $settings_file
  283. echo '' >> $settings_file
  284. echo ' - name : deviantart' >> $settings_file
  285. echo ' engine : deviantart' >> $settings_file
  286. echo ' shortcut : da' >> $settings_file
  287. echo ' timeout: 3.0' >> $settings_file
  288. echo '' >> $settings_file
  289. echo ' - name : ddg definitions' >> $settings_file
  290. echo ' engine : duckduckgo_definitions' >> $settings_file
  291. echo ' shortcut : ddd' >> $settings_file
  292. echo ' weight : 2' >> $settings_file
  293. echo ' disabled : True' >> $settings_file
  294. echo '' >> $settings_file
  295. echo ' - name : digbt' >> $settings_file
  296. echo ' engine : digbt' >> $settings_file
  297. echo ' shortcut : dbt' >> $settings_file
  298. echo ' timeout : 6.0' >> $settings_file
  299. echo ' disabled : True' >> $settings_file
  300. echo '' >> $settings_file
  301. echo ' - name : erowid' >> $settings_file
  302. echo ' engine : xpath' >> $settings_file
  303. echo ' paging : True' >> $settings_file
  304. echo ' first_page_num : 0' >> $settings_file
  305. echo ' page_size : 30' >> $settings_file
  306. echo ' search_url : https://www.erowid.org/search.php?q={query}&s={pageno}' >> $settings_file
  307. echo ' url_xpath : //dl[@class="results-list"]/dt[@class="result-title"]/a/@href' >> $settings_file
  308. echo ' title_xpath : //dl[@class="results-list"]/dt[@class="result-title"]/a/text()' >> $settings_file
  309. echo ' content_xpath : //dl[@class="results-list"]/dd[@class="result-details"]' >> $settings_file
  310. echo ' categories : general' >> $settings_file
  311. echo ' shortcut : ew' >> $settings_file
  312. echo ' disabled : True' >> $settings_file
  313. echo '' >> $settings_file
  314. echo ' - name : wikidata' >> $settings_file
  315. echo ' engine : wikidata' >> $settings_file
  316. echo ' shortcut : wd' >> $settings_file
  317. echo ' weight : 2' >> $settings_file
  318. echo '' >> $settings_file
  319. echo ' - name : duckduckgo' >> $settings_file
  320. echo ' engine : duckduckgo' >> $settings_file
  321. echo ' shortcut : ddg' >> $settings_file
  322. echo ' categories : general' >> $settings_file
  323. echo '' >> $settings_file
  324. echo ' - name : etymonline' >> $settings_file
  325. echo ' engine : xpath' >> $settings_file
  326. echo ' paging : True' >> $settings_file
  327. echo ' search_url : http://etymonline.com/?search={query}&p={pageno}' >> $settings_file
  328. echo ' url_xpath : //dt/a[1]/@href' >> $settings_file
  329. echo ' title_xpath : //dt' >> $settings_file
  330. echo ' content_xpath : //dd' >> $settings_file
  331. echo ' suggestion_xpath : //a[@class="crossreference"]' >> $settings_file
  332. echo ' first_page_num : 0' >> $settings_file
  333. echo ' shortcut : et' >> $settings_file
  334. echo ' disabled : True' >> $settings_file
  335. echo '' >> $settings_file
  336. echo ' - name : 500px' >> $settings_file
  337. echo ' engine : www500px' >> $settings_file
  338. echo ' shortcut : px' >> $settings_file
  339. echo '' >> $settings_file
  340. echo ' - name : 1x' >> $settings_file
  341. echo ' engine : www1x' >> $settings_file
  342. echo ' shortcut : 1x' >> $settings_file
  343. echo ' disabled : True' >> $settings_file
  344. echo '' >> $settings_file
  345. echo ' - name : fdroid' >> $settings_file
  346. echo ' engine : fdroid' >> $settings_file
  347. echo ' shortcut : fd' >> $settings_file
  348. echo ' disabled : True' >> $settings_file
  349. echo '' >> $settings_file
  350. echo ' - name : flickr' >> $settings_file
  351. echo ' categories : images' >> $settings_file
  352. echo ' shortcut : fl' >> $settings_file
  353. echo '# You can use the engine using the official stable API, but you need an API key' >> $settings_file
  354. echo '# See : https://www.flickr.com/services/apps/create/' >> $settings_file
  355. echo '# engine : flickr' >> $settings_file
  356. echo '# api_key: 'apikey' # required!' >> $settings_file
  357. echo '# Or you can use the html non-stable engine, activated by default' >> $settings_file
  358. echo ' engine : flickr_noapi' >> $settings_file
  359. echo '' >> $settings_file
  360. echo ' - name : frinkiac' >> $settings_file
  361. echo ' engine : frinkiac' >> $settings_file
  362. echo ' shortcut : frk' >> $settings_file
  363. echo ' disabled : True' >> $settings_file
  364. echo '' >> $settings_file
  365. echo ' - name : gigablast' >> $settings_file
  366. echo ' engine : gigablast' >> $settings_file
  367. echo ' shortcut : gb' >> $settings_file
  368. echo ' timeout : 3.0' >> $settings_file
  369. echo ' disabled: True' >> $settings_file
  370. echo '' >> $settings_file
  371. echo ' - name : gitlab' >> $settings_file
  372. echo ' engine : xpath' >> $settings_file
  373. echo ' paging : True' >> $settings_file
  374. echo ' search_url : https://gitlab.com/search?page={pageno}&search={query}' >> $settings_file
  375. echo ' url_xpath : //li[@class="project-row"]//a[@class="project"]/@href' >> $settings_file
  376. echo ' title_xpath : //li[@class="project-row"]//span[contains(@class, "project-full-name")]' >> $settings_file
  377. echo ' content_xpath : //li[@class="project-row"]//div[@class="description"]/p' >> $settings_file
  378. echo ' categories : code' >> $settings_file
  379. echo ' shortcut : gl' >> $settings_file
  380. echo ' timeout : 5.0' >> $settings_file
  381. echo ' disabled : True' >> $settings_file
  382. echo '' >> $settings_file
  383. echo ' - name : github' >> $settings_file
  384. echo ' engine : github' >> $settings_file
  385. echo ' shortcut : gh' >> $settings_file
  386. echo ' categories : code' >> $settings_file
  387. echo '' >> $settings_file
  388. echo ' - name : geektimes' >> $settings_file
  389. echo ' engine : xpath' >> $settings_file
  390. echo ' paging : True' >> $settings_file
  391. echo ' search_url : https://geektimes.ru/search/page{pageno}/?q={query}' >> $settings_file
  392. echo ' url_xpath : //div[@class="search_results"]//a[@class="post__title_link"]/@href' >> $settings_file
  393. echo ' title_xpath : //div[@class="search_results"]//a[@class="post__title_link"]' >> $settings_file
  394. echo ' content_xpath : //div[@class="search_results"]//div[contains(@class, "content")]' >> $settings_file
  395. echo ' categories : code' >> $settings_file
  396. echo ' timeout : 4.0' >> $settings_file
  397. echo ' disabled : True' >> $settings_file
  398. echo ' shortcut : gt' >> $settings_file
  399. echo '' >> $settings_file
  400. echo ' - name : habrahabr' >> $settings_file
  401. echo ' engine : xpath' >> $settings_file
  402. echo ' paging : True' >> $settings_file
  403. echo ' search_url : https://habrahabr.ru/search/page{pageno}/?q={query}' >> $settings_file
  404. echo ' url_xpath : //div[@class="search_results"]//a[contains(@class, "post__title_link")]/@href' >> $settings_file
  405. echo ' title_xpath : //div[@class="search_results"]//a[contains(@class, "post__title_link")]' >> $settings_file
  406. echo ' content_xpath : //div[@class="search_results"]//div[contains(@class, "content")]' >> $settings_file
  407. echo ' categories : code' >> $settings_file
  408. echo ' timeout : 4.0' >> $settings_file
  409. echo ' disabled : True' >> $settings_file
  410. echo ' shortcut : habr' >> $settings_file
  411. echo '' >> $settings_file
  412. echo ' - name : hoogle' >> $settings_file
  413. echo ' engine : json_engine' >> $settings_file
  414. echo ' paging : True' >> $settings_file
  415. echo ' search_url : https://www.haskell.org/hoogle/?mode=json&hoogle={query}&start={pageno}' >> $settings_file
  416. echo ' results_query : results' >> $settings_file
  417. echo ' url_query : location' >> $settings_file
  418. echo ' title_query : self' >> $settings_file
  419. echo ' content_query : docs' >> $settings_file
  420. echo ' page_size : 20' >> $settings_file
  421. echo ' categories : code' >> $settings_file
  422. echo ' shortcut : ho' >> $settings_file
  423. echo '' >> $settings_file
  424. echo ' - name : ina' >> $settings_file
  425. echo ' engine : ina' >> $settings_file
  426. echo ' shortcut : in' >> $settings_file
  427. echo ' timeout : 6.0' >> $settings_file
  428. echo ' disabled : True' >> $settings_file
  429. echo '' >> $settings_file
  430. echo ' - name: kickass' >> $settings_file
  431. echo ' engine : kickass' >> $settings_file
  432. echo ' shortcut : kc' >> $settings_file
  433. echo ' timeout : 4.0' >> $settings_file
  434. echo ' disabled : True' >> $settings_file
  435. echo '' >> $settings_file
  436. echo ' - name : library genesis' >> $settings_file
  437. echo ' engine : xpath' >> $settings_file
  438. echo ' search_url : http://libgen.io/search.php?req={query}' >> $settings_file
  439. echo ' url_xpath : //a[contains(@href,"bookfi.net")]/@href' >> $settings_file
  440. echo ' title_xpath : //a[contains(@href,"book/")]/text()[1]' >> $settings_file
  441. echo ' content_xpath : //td/a[1][contains(@href,"=author")]/text()' >> $settings_file
  442. echo ' categories : general' >> $settings_file
  443. echo ' timeout : 7.0' >> $settings_file
  444. echo ' disabled : True' >> $settings_file
  445. echo ' shortcut : lg' >> $settings_file
  446. echo '' >> $settings_file
  447. echo ' - name : lobste.rs' >> $settings_file
  448. echo ' engine : xpath' >> $settings_file
  449. echo ' search_url : https://lobste.rs/search?utf8=%E2%9C%93&q={query}&what=stories&order=relevance' >> $settings_file
  450. echo ' results_xpath : //li[contains(@class, "story")]' >> $settings_file
  451. echo ' url_xpath : .//span[@class="link"]/a/@href' >> $settings_file
  452. echo ' title_xpath : .//span[@class="link"]/a' >> $settings_file
  453. echo ' content_xpath : .//a[@class="domain"]' >> $settings_file
  454. echo ' categories : code' >> $settings_file
  455. echo ' shortcut : lo' >> $settings_file
  456. echo '' >> $settings_file
  457. echo ' - name : mixcloud' >> $settings_file
  458. echo ' engine : mixcloud' >> $settings_file
  459. echo ' shortcut : mc' >> $settings_file
  460. echo '' >> $settings_file
  461. echo ' - name : nyaa' >> $settings_file
  462. echo ' engine : nyaa' >> $settings_file
  463. echo ' shortcut : nt' >> $settings_file
  464. echo ' disabled : True' >> $settings_file
  465. echo '' >> $settings_file
  466. echo ' - name : openstreetmap' >> $settings_file
  467. echo ' engine : openstreetmap' >> $settings_file
  468. echo ' shortcut : osm' >> $settings_file
  469. echo '' >> $settings_file
  470. echo ' - name : openrepos' >> $settings_file
  471. echo ' engine : xpath' >> $settings_file
  472. echo ' paging : True' >> $settings_file
  473. echo ' search_url : https://openrepos.net/search/node/{query}?page={pageno}' >> $settings_file
  474. echo ' url_xpath : //li[@class="search-result"]//h3[@class="title"]/a/@href' >> $settings_file
  475. echo ' title_xpath : //li[@class="search-result"]//h3[@class="title"]/a' >> $settings_file
  476. echo ' content_xpath : //li[@class="search-result"]//div[@class="search-snippet-info"]//p[@class="search-snippet"]' >> $settings_file
  477. echo ' categories : files' >> $settings_file
  478. echo ' timeout : 4.0' >> $settings_file
  479. echo ' disabled : True' >> $settings_file
  480. echo ' shortcut : or' >> $settings_file
  481. echo '' >> $settings_file
  482. echo ' - name : pdbe' >> $settings_file
  483. echo ' engine : pdbe' >> $settings_file
  484. echo ' shortcut : pdb' >> $settings_file
  485. echo '' >> $settings_file
  486. echo ' - name : photon' >> $settings_file
  487. echo ' engine : photon' >> $settings_file
  488. echo ' shortcut : ph' >> $settings_file
  489. echo '' >> $settings_file
  490. echo ' - name : piratebay' >> $settings_file
  491. echo ' engine : piratebay' >> $settings_file
  492. echo ' shortcut : tpb' >> $settings_file
  493. echo ' url: https://pirateproxy.red/' >> $settings_file
  494. echo ' timeout : 3.0' >> $settings_file
  495. echo '' >> $settings_file
  496. echo ' - name : qwant' >> $settings_file
  497. echo ' engine : qwant' >> $settings_file
  498. echo ' shortcut : qw' >> $settings_file
  499. echo ' categories : general' >> $settings_file
  500. echo ' disabled : True' >> $settings_file
  501. echo '' >> $settings_file
  502. echo ' - name : qwant images' >> $settings_file
  503. echo ' engine : qwant' >> $settings_file
  504. echo ' shortcut : qwi' >> $settings_file
  505. echo ' categories : images' >> $settings_file
  506. echo '' >> $settings_file
  507. echo ' - name : qwant news' >> $settings_file
  508. echo ' engine : qwant' >> $settings_file
  509. echo ' shortcut : qwn' >> $settings_file
  510. echo ' categories : news' >> $settings_file
  511. echo '' >> $settings_file
  512. echo ' - name : qwant social' >> $settings_file
  513. echo ' engine : qwant' >> $settings_file
  514. echo ' shortcut : qws' >> $settings_file
  515. echo ' categories : social media' >> $settings_file
  516. echo '' >> $settings_file
  517. echo ' - name : reddit' >> $settings_file
  518. echo ' engine : reddit' >> $settings_file
  519. echo ' shortcut : re' >> $settings_file
  520. echo ' page_size : 25' >> $settings_file
  521. echo ' timeout : 10.0' >> $settings_file
  522. echo ' disabled : True' >> $settings_file
  523. echo '' >> $settings_file
  524. echo ' - name : scanr structures' >> $settings_file
  525. echo ' shortcut: scs' >> $settings_file
  526. echo ' engine : scanr_structures' >> $settings_file
  527. echo ' disabled : True' >> $settings_file
  528. echo '' >> $settings_file
  529. echo ' - name : soundcloud' >> $settings_file
  530. echo ' engine : soundcloud' >> $settings_file
  531. echo ' shortcut : sc' >> $settings_file
  532. echo '' >> $settings_file
  533. echo ' - name : stackoverflow' >> $settings_file
  534. echo ' engine : stackoverflow' >> $settings_file
  535. echo ' shortcut : st' >> $settings_file
  536. echo '' >> $settings_file
  537. echo ' - name : searchcode doc' >> $settings_file
  538. echo ' engine : searchcode_doc' >> $settings_file
  539. echo ' shortcut : scd' >> $settings_file
  540. echo '' >> $settings_file
  541. echo ' - name : searchcode code' >> $settings_file
  542. echo ' engine : searchcode_code' >> $settings_file
  543. echo ' shortcut : scc' >> $settings_file
  544. echo ' disabled : True' >> $settings_file
  545. echo '' >> $settings_file
  546. echo ' - name : framalibre' >> $settings_file
  547. echo ' engine : framalibre' >> $settings_file
  548. echo ' shortcut : frl' >> $settings_file
  549. echo ' disabled : True' >> $settings_file
  550. echo '' >> $settings_file
  551. echo ' - name : semantic scholar' >> $settings_file
  552. echo ' engine : xpath' >> $settings_file
  553. echo ' paging : True' >> $settings_file
  554. echo ' search_url : https://www.semanticscholar.org/search?q={query}&sort=relevance&page={pageno}&ae=false' >> $settings_file
  555. echo ' results_xpath : //article' >> $settings_file
  556. echo ' url_xpath : .//div[@class="search-result-title"]/a/@href' >> $settings_file
  557. echo ' title_xpath : .//div[@class="search-result-title"]/a' >> $settings_file
  558. echo ' content_xpath : .//div[@class="search-result-abstract"]' >> $settings_file
  559. echo ' shortcut : se' >> $settings_file
  560. echo ' categories : science' >> $settings_file
  561. echo '' >> $settings_file
  562. echo ' - name : spotify' >> $settings_file
  563. echo ' engine : spotify' >> $settings_file
  564. echo ' shortcut : stf' >> $settings_file
  565. echo '' >> $settings_file
  566. echo ' - name : subtitleseeker' >> $settings_file
  567. echo ' engine : subtitleseeker' >> $settings_file
  568. echo ' shortcut : ss' >> $settings_file
  569. echo '# The language is an option. You can put any language written in english' >> $settings_file
  570. echo '# Examples : English, French, German, Hungarian, Chinese...' >> $settings_file
  571. echo '# language : English' >> $settings_file
  572. echo '' >> $settings_file
  573. echo ' - name : startpage' >> $settings_file
  574. echo ' engine : startpage' >> $settings_file
  575. echo ' shortcut : sp' >> $settings_file
  576. echo ' timeout : 6.0' >> $settings_file
  577. echo ' disabled : True' >> $settings_file
  578. echo '' >> $settings_file
  579. echo ' - name : ixquick' >> $settings_file
  580. echo ' engine : startpage' >> $settings_file
  581. echo " base_url : 'https://www.ixquick.eu/'" >> $settings_file
  582. echo " search_url : 'https://www.ixquick.eu/do/search'" >> $settings_file
  583. echo ' shortcut : iq' >> $settings_file
  584. echo ' timeout : 6.0' >> $settings_file
  585. echo '' >> $settings_file
  586. echo ' - name : swisscows' >> $settings_file
  587. echo ' engine : swisscows' >> $settings_file
  588. echo ' shortcut : sw' >> $settings_file
  589. echo ' disabled : True' >> $settings_file
  590. echo '' >> $settings_file
  591. echo ' - name : tokyotoshokan' >> $settings_file
  592. echo ' engine : tokyotoshokan' >> $settings_file
  593. echo ' shortcut : tt' >> $settings_file
  594. echo ' timeout : 6.0' >> $settings_file
  595. echo ' disabled : True' >> $settings_file
  596. echo '' >> $settings_file
  597. echo ' - name : twitter' >> $settings_file
  598. echo ' engine : twitter' >> $settings_file
  599. echo ' shortcut : tw' >> $settings_file
  600. echo '' >> $settings_file
  601. echo ' - name : urbandictionary' >> $settings_file
  602. echo ' engine : xpath' >> $settings_file
  603. echo ' search_url : http://www.urbandictionary.com/define.php?term={query}' >> $settings_file
  604. echo ' url_xpath : //*[@class="word"]/@href' >> $settings_file
  605. echo ' title_xpath : //*[@class="def-header"]' >> $settings_file
  606. echo ' content_xpath : //*[@class="meaning"]' >> $settings_file
  607. echo ' shortcut : ud' >> $settings_file
  608. echo '' >> $settings_file
  609. echo ' - name : yandex' >> $settings_file
  610. echo ' engine : yandex' >> $settings_file
  611. echo ' shortcut : yn' >> $settings_file
  612. echo ' disabled : True' >> $settings_file
  613. echo '' >> $settings_file
  614. echo ' - name : youtube' >> $settings_file
  615. echo ' shortcut : yt' >> $settings_file
  616. echo ' # You can use the engine using the official stable API, but you need an API key' >> $settings_file
  617. echo ' # See : https://console.developers.google.com/project' >> $settings_file
  618. echo ' # engine : youtube_api' >> $settings_file
  619. echo ' # api_key: apikey # required!' >> $settings_file
  620. echo ' # Or you can use the html non-stable engine, activated by default' >> $settings_file
  621. echo ' engine : youtube_noapi' >> $settings_file
  622. echo '' >> $settings_file
  623. echo ' - name : dailymotion' >> $settings_file
  624. echo ' engine : dailymotion' >> $settings_file
  625. echo ' shortcut : dm' >> $settings_file
  626. echo '' >> $settings_file
  627. echo ' - name : vimeo' >> $settings_file
  628. echo ' engine : vimeo' >> $settings_file
  629. echo ' shortcut : vm' >> $settings_file
  630. echo '' >> $settings_file
  631. echo ' - name : wolframalpha' >> $settings_file
  632. echo ' shortcut : wa' >> $settings_file
  633. echo ' # You can use the engine using the official stable API, but you need an API key' >> $settings_file
  634. echo ' # See : http://products.wolframalpha.com/api/' >> $settings_file
  635. echo ' # engine : wolframalpha_api' >> $settings_file
  636. echo ' # api_key: '' # required!' >> $settings_file
  637. echo ' engine : wolframalpha_noapi' >> $settings_file
  638. echo ' timeout: 6.0' >> $settings_file
  639. echo ' categories : science' >> $settings_file
  640. echo '' >> $settings_file
  641. echo ' - name : seedpeer' >> $settings_file
  642. echo ' engine : seedpeer' >> $settings_file
  643. echo ' shortcut: speu'
  644. echo ' categories: files, music, videos'
  645. echo ' disabled: True' >> $settings_file
  646. echo '' >> $settings_file
  647. echo ' - name : dictzone' >> $settings_file
  648. echo ' engine : dictzone' >> $settings_file
  649. echo ' shortcut : dc' >> $settings_file
  650. echo '' >> $settings_file
  651. echo ' - name : mymemory translated' >> $settings_file
  652. echo ' engine : translated' >> $settings_file
  653. echo ' shortcut : tl' >> $settings_file
  654. echo ' timeout : 5.0' >> $settings_file
  655. echo ' disabled : True' >> $settings_file
  656. echo ' # You can use without an API key, but you are limited to 1000 words/day' >> $settings_file
  657. echo ' # See : http://mymemory.translated.net/doc/usagelimits.php' >> $settings_file
  658. echo ' # api_key : ""' >> $settings_file
  659. echo '' >> $settings_file
  660. echo ' - name : voat' >> $settings_file
  661. echo ' engine: xpath' >> $settings_file
  662. echo ' shortcut: vo' >> $settings_file
  663. echo ' categories: social media' >> $settings_file
  664. echo ' search_url : https://voat.co/search?q={query}' >> $settings_file
  665. echo ' url_xpath : //p[contains(@class, "title")]/a/@href' >> $settings_file
  666. echo ' title_xpath : //p[contains(@class, "title")]/a' >> $settings_file
  667. echo ' content_xpath : //span[@class="domain"]' >> $settings_file
  668. echo ' timeout : 10.0' >> $settings_file
  669. echo ' disabled : True' >> $settings_file
  670. echo '' >> $settings_file
  671. echo ' - name : 1337x' >> $settings_file
  672. echo ' engine : 1337x' >> $settings_file
  673. echo ' shortcut : 1337x' >> $settings_file
  674. echo ' disabled : True' >> $settings_file
  675. echo '' >> $settings_file
  676. echo 'locales:' >> $settings_file
  677. echo ' en : English' >> $settings_file
  678. echo ' bg : Български (Bulgarian)' >> $settings_file
  679. echo ' cs : Čeština (Czech)' >> $settings_file
  680. echo ' de : Deutsch (German)' >> $settings_file
  681. echo ' de_DE : Deutsch (German_Germany)' >> $settings_file
  682. echo ' el_GR : Ελληνικά (Greek_Greece)' >> $settings_file
  683. echo ' eo : Esperanto (Esperanto)' >> $settings_file
  684. echo ' es : Español (Spanish)' >> $settings_file
  685. echo ' fi : Suomi (Finnish)' >> $settings_file
  686. echo ' fr : Français (French)' >> $settings_file
  687. echo ' he : עברית (Hebrew)' >> $settings_file
  688. echo ' hu : Magyar (Hungarian)' >> $settings_file
  689. echo ' it : Italiano (Italian)' >> $settings_file
  690. echo ' ja : 日本語 (Japanese)' >> $settings_file
  691. echo ' nl : Nederlands (Dutch)' >> $settings_file
  692. echo ' pt : Português (Portuguese)' >> $settings_file
  693. echo ' pt_BR : Português (Portuguese_Brazil)' >> $settings_file
  694. echo ' ro : Română (Romanian)' >> $settings_file
  695. echo ' ru : Русский (Russian)' >> $settings_file
  696. echo ' sk : Slovenčina (Slovak)' >> $settings_file
  697. echo ' sv : Svenska (Swedish)' >> $settings_file
  698. echo ' tr : Türkçe (Turkish)' >> $settings_file
  699. echo ' uk : українська мова (Ukrainian)' >> $settings_file
  700. echo ' zh : 中文 (Chinese)' >> $settings_file
  701. }
  702. function upgrade_searx {
  703. settings_file=${SEARX_PATH}/searx/searx/settings.yml
  704. background_image=/etc/searx/searx/static/themes/courgette/img/bg-body-index.jpg
  705. # save the background image
  706. if [ -f ${background_image} ]; then
  707. cp ${background_image} ${background_image}.prev
  708. fi
  709. # save the settings
  710. cp ${settings_file} ${settings_file}.prev
  711. # do the upgrade
  712. set_repo_commit $SEARX_PATH/searx "searx commit" "$SEARX_COMMIT" $SEARX_REPO
  713. # restore the background image
  714. if [ -f ${background_image}.prev ]; then
  715. cp ${background_image}.prev ${background_image}
  716. chown -R searx:searx ${SEARX_PATH}/searx
  717. fi
  718. # restore the settings
  719. if [ -f ${settings_file}.prev ]; then
  720. cp ${settings_file}.prev ${settings_file}
  721. chown -R searx:searx ${SEARX_PATH}/searx
  722. fi
  723. # remove the github ribbon icon
  724. if [ -f /etc/searx/searx/static/themes/courgette/img/github_ribbon.png ]; then
  725. mv /etc/searx/searx/static/themes/courgette/img/github_ribbon.png /etc/searx/searx/static/themes/courgette/img/github_ribbon.png.old
  726. fi
  727. }
  728. function backup_local_searx {
  729. echo -n ''
  730. }
  731. function restore_local_searx {
  732. echo -n ''
  733. }
  734. function backup_remote_searx {
  735. echo -n ''
  736. }
  737. function restore_remote_searx {
  738. echo -n ''
  739. }
  740. function remove_searx {
  741. systemctl stop searx
  742. systemctl disable searx
  743. rm /etc/systemd/system/searx.service
  744. function_check remove_onion_service
  745. remove_onion_service searx ${SEARX_ONION_PORT}
  746. userdel -r searx
  747. nginx_dissite searx
  748. if [ -f /etc/nginx/sites-available/searx ]; then
  749. rm /etc/nginx/sites-available/searx
  750. fi
  751. if [ -d ${SEARX_PATH}/searx ]; then
  752. rm -rf ${SEARX_PATH}/searx
  753. fi
  754. remove_completion_param install_searx
  755. sed -i '/Search engine /d' $COMPLETION_FILE
  756. sed -i '/searx /d' $COMPLETION_FILE
  757. }
  758. function install_searx {
  759. # Note: currently socks5 outgoing proxies to other search engines does not work
  760. if [ ! -d /etc/nginx ]; then
  761. echo $'Webserver is not installed'
  762. exit 62429
  763. fi
  764. apt-get -yq install python-pip libyaml-dev python-werkzeug python-babel python-lxml apache2-utils
  765. apt-get -yq install git build-essential libxslt-dev python-dev python-virtualenv python-pybabel zlib1g-dev uwsgi uwsgi-plugin-python libapache2-mod-uwsgi imagemagick
  766. pip install --upgrade pip
  767. pip install certifi
  768. if [ ! "$?" = "0" ]; then
  769. echo $'Failed to install certifi'
  770. exit 737692
  771. fi
  772. pip install pyyaml
  773. if [ ! "$?" = "0" ]; then
  774. echo $'Failed to install pyyaml'
  775. exit 469242
  776. fi
  777. pip install flask --upgrade
  778. if [ ! "$?" = "0" ]; then
  779. echo $'Failed to install flask'
  780. exit 888575
  781. fi
  782. pip install flask_restless --upgrade
  783. if [ ! "$?" = "0" ]; then
  784. echo $'Failed to install flask_restless'
  785. exit 54835
  786. fi
  787. pip install flask_babel --upgrade
  788. if [ ! "$?" = "0" ]; then
  789. echo $'Failed to install flask_babel'
  790. exit 63738
  791. fi
  792. if [ ! -d $SEARX_PATH ]; then
  793. mkdir -p $SEARX_PATH
  794. fi
  795. # clone the repo
  796. cd $SEARX_PATH
  797. function_check git_clone
  798. git_clone $SEARX_REPO searx
  799. git checkout $SEARX_COMMIT -b $SEARX_COMMIT
  800. set_completion_param "searx commit" "$SEARX_COMMIT"
  801. # create an onion service
  802. SEARX_ONION_HOSTNAME=$(add_onion_service searx 80 ${SEARX_ONION_PORT})
  803. # an unprivileged user to run as
  804. useradd -d ${SEARX_PATH}/searx/ -s /bin/false searx
  805. adduser searx debian-tor
  806. # daemon
  807. echo '[Unit]' > /etc/systemd/system/searx.service
  808. echo 'Description=Searx (search engine)' >> /etc/systemd/system/searx.service
  809. echo 'After=syslog.target' >> /etc/systemd/system/searx.service
  810. echo 'After=network.target' >> /etc/systemd/system/searx.service
  811. echo '' >> /etc/systemd/system/searx.service
  812. echo '[Service]' >> /etc/systemd/system/searx.service
  813. echo 'Type=simple' >> /etc/systemd/system/searx.service
  814. echo 'User=searx' >> /etc/systemd/system/searx.service
  815. echo 'Group=searx' >> /etc/systemd/system/searx.service
  816. echo "WorkingDirectory=${SEARX_PATH}/searx" >> /etc/systemd/system/searx.service
  817. echo "ExecStart=/usr/bin/python ${SEARX_PATH}/searx/searx/webapp.py" >> /etc/systemd/system/searx.service
  818. echo 'Restart=always' >> /etc/systemd/system/searx.service
  819. echo 'Environment="USER=searx"' >> /etc/systemd/system/searx.service
  820. echo '' >> /etc/systemd/system/searx.service
  821. echo '[Install]' >> /etc/systemd/system/searx.service
  822. echo 'WantedBy=multi-user.target' >> /etc/systemd/system/searx.service
  823. # create a webserver file
  824. echo 'server {' > /etc/nginx/sites-available/searx
  825. echo " listen 127.0.0.1:${SEARX_ONION_PORT} default_server;" >> /etc/nginx/sites-available/searx
  826. echo " root ${SEARX_PATH}/searx;" >> /etc/nginx/sites-available/searx
  827. echo " server_name ${SEARX_ONION_HOSTNAME};" >> /etc/nginx/sites-available/searx
  828. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/searx
  829. echo " error_log /var/log/searx_error.log $WEBSERVER_LOG_LEVEL;" >> /etc/nginx/sites-available/searx
  830. echo '' >> /etc/nginx/sites-available/searx
  831. function_check nginx_disable_sniffing
  832. nginx_disable_sniffing searx
  833. echo ' add_header Strict-Transport-Security max-age=0;' >> /etc/nginx/sites-available/searx
  834. echo '' >> /etc/nginx/sites-available/searx
  835. echo ' location / {' >> /etc/nginx/sites-available/searx
  836. function_check nginx_limits
  837. nginx_limits searx '1M'
  838. echo ' proxy_pass http://localhost:8888;' >> /etc/nginx/sites-available/searx
  839. echo " auth_basic \"${SEARX_LOGIN_TEXT}\";" >> /etc/nginx/sites-available/searx
  840. echo ' auth_basic_user_file /etc/nginx/.htpasswd;' >> /etc/nginx/sites-available/searx
  841. echo ' }' >> /etc/nginx/sites-available/searx
  842. echo '' >> /etc/nginx/sites-available/searx
  843. echo ' fastcgi_buffers 64 4K;' >> /etc/nginx/sites-available/searx
  844. echo '' >> /etc/nginx/sites-available/searx
  845. echo ' error_page 403 /core/templates/403.php;' >> /etc/nginx/sites-available/searx
  846. echo ' error_page 404 /core/templates/404.php;' >> /etc/nginx/sites-available/searx
  847. echo '' >> /etc/nginx/sites-available/searx
  848. echo ' location = /robots.txt {' >> /etc/nginx/sites-available/searx
  849. echo ' allow all;' >> /etc/nginx/sites-available/searx
  850. echo ' log_not_found off;' >> /etc/nginx/sites-available/searx
  851. echo ' access_log /dev/null;' >> /etc/nginx/sites-available/searx
  852. echo ' }' >> /etc/nginx/sites-available/searx
  853. echo '}' >> /etc/nginx/sites-available/searx
  854. # replace the secret key
  855. if ! grep "searx key" $COMPLETION_FILE; then
  856. SEARX_SECRET_KEY="$(create_password 30)"
  857. set_completion_param "searx key" "${SEARX_SECRET_KEY}"
  858. fi
  859. create_searx_config
  860. searx_set_default_background
  861. chown -R searx:searx ${SEARX_PATH}/searx
  862. # enable the site
  863. nginx_ensite searx
  864. # restart the web server
  865. systemctl restart php5-fpm
  866. systemctl restart nginx
  867. # start the daemon
  868. systemctl enable searx.service
  869. systemctl daemon-reload
  870. systemctl start searx.service
  871. SEARX_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
  872. ${PROJECT_NAME}-pass -u $MY_USERNAME -a searx -p "$SEARX_PASSWORD"
  873. if grep -q "$MY_USERNAME:" /etc/nginx/.htpasswd; then
  874. sed -i "/$MY_USERNAME:/d" /etc/nginx/.htpasswd
  875. fi
  876. echo "$SEARX_PASSWORD" | htpasswd -i -s -c /etc/nginx/.htpasswd $MY_USERNAME
  877. APP_INSTALLED=1
  878. }
  879. # NOTE: deliberately no exit 0