Skip to content
Snippets Groups Projects
Commit ab707c85 authored by Bob Mottram's avatar Bob Mottram
Browse files

Move search functions into their own file

parent 3f48eabd
No related branches found
No related tags found
No related merge requests found
......@@ -861,190 +861,6 @@ function remove_searx {
sed -i '/searx /d' "$COMPLETION_FILE"
}
function webadmin_upgrade_search {
CURR_SEARX_COMMIT=$(grep "SEARX_COMMIT=" "$rootdir$CONFIGURATION_FILE" | head -n 1 | awk -F '=' '{print $2}')
if [[ "$CURR_SEARX_COMMIT" == "$SEARX_COMMIT" ]]; then
return
fi
settings_file="$rootdir${SEARX_PATH}/searx/searx/settings.yml"
background_image="$rootdir/etc/searx/searx/static/themes/courgette/img/bg-body-index.jpg"
# save the background image
if [ -f "${background_image}" ]; then
cp "${background_image}" "${background_image}.prev"
fi
# save the settings
cp "${settings_file}" "${settings_file}.prev"
# do the upgrade
cat >> "$rootdir/tmp/upgrade_searx" <<EOF
cd $SEARX_PATH/searx || exit 1
git stash
git pull
EOF
chmod +x "$rootdir/tmp/upgrade_searx"
if [ "$rootdir" ]; then
chroot "$rootdir" "$rootdir/tmp/upgrade_searx"
chroot "$rootdir" rm "$rootdir/tmp/upgrade_searx"
else
/tmp/upgrade_searx
rm /tmp/upgrade_searx
fi
# restore the background image
if [ -f "${background_image}.prev" ]; then
cp "${background_image}.prev" "${background_image}"
if [ "$rootdir" ]; then
chroot "$rootdir" chown -R searx:searx "${SEARX_PATH}/searx"
else
chown -R searx:searx "${SEARX_PATH}/searx"
fi
fi
# restore the settings
if [ -f "${settings_file}.prev" ]; then
cp "${settings_file}.prev" "${settings_file}"
if [ "$rootdir" ]; then
chroot "$rootdir" chown -R searx:searx ${SEARX_PATH}/searx
else
chown -R searx:searx ${SEARX_PATH}/searx
fi
fi
# remove the github ribbon icon
if [ -f "$rootdir/etc/searx/searx/static/themes/courgette/img/github_ribbon.png" ]; then
mv "$rootdir/etc/searx/searx/static/themes/courgette/img/github_ribbon.png" "$rootdir/etc/searx/searx/static/themes/courgette/img/github_ribbon.png.old"
fi
sed -i "s|SEARX_COMMIT=.*|SEARX_COMMIT=$SEARX_COMMIT|g" "$rootdir$CONFIGURATION_FILE"
}
function webadmin_install_search {
if grep -q "SEARX_COMMIT=" "$rootdir$CONFIGURATION_FILE"; then
webadmin_upgrade_search
return
fi
if [ "$rootdir" ]; then
# shellcheck disable=SC2086
chroot "$rootdir" $INSTALL_PACKAGES python-pip libyaml-dev python-werkzeug python-babel python-lxml
# shellcheck disable=SC2086
chroot "$rootdir" $INSTALL_PACKAGES git build-essential libxslt-dev python-dev python-virtualenv zlib1g-dev uwsgi uwsgi-plugin-python imagemagick
# shellcheck disable=SC2086
chroot "$rootdir" $INSTALL_PACKAGES apache2-utils python-setuptools
# shellcheck disable=SC2086
chroot "$rootdir" $INSTALL_PACKAGES python-service-identity python-ndg-httpsclient
# shellcheck disable=SC2086
chroot "$rootdir" $REMOVE_PACKAGES_PURGE apache2-bin*
else
$INSTALL_PACKAGES python-pip libyaml-dev python-werkzeug python-babel python-lxml
$INSTALL_PACKAGES git build-essential libxslt-dev python-dev python-virtualenv zlib1g-dev uwsgi uwsgi-plugin-python imagemagick
$INSTALL_PACKAGES apache2-utils python-setuptools
$INSTALL_PACKAGES python-service-identity python-ndg-httpsclient
fi
cat >> "$rootdir/tmp/install_searx" <<EOF
pip2 install --upgrade pip
if ! pip2 install certifi; then
echo $'Failed to install certifi'
exit 737692
fi
if ! pip2 install pyyaml; then
echo $'Failed to install pyyaml'
exit 469242
fi
if ! pip2 install flask --upgrade; then
echo $'Failed to install flask'
exit 888575
fi
if ! pip2 install flask_restless --upgrade; then
echo $'Failed to install flask_restless'
exit 54835
fi
if ! pip2 install flask_babel --upgrade; then
echo $'Failed to install flask_babel'
exit 63738
fi
if ! pip2 install requests --upgrade; then
echo $'Failed to install requests'
exit 357282
fi
if ! pip2 install pygments --upgrade; then
echo $'Failed to install pygments'
exit 357282
fi
if [ ! -d ${SEARX_PATH} ]; then
mkdir -p $SEARX_PATH
fi
if ! git_clone $SEARX_REPO ${SEARX_PATH}/searx; then
exit 35683
fi
cd $SEARX_PATH/searx || exit 26482
git checkout $SEARX_COMMIT -b $SEARX_COMMIT
useradd -d ${SEARX_PATH}/searx/ -s /bin/false searx
adduser searx debian-tor
EOF
chmod +x "$rootdir/tmp/install_searx"
if [ "$rootdir" ]; then
chroot "$rootdir" /tmp/install_searx
chroot "$rootdir" rm /tmp/install_searx
else
/tmp/install_searx
rm /tmp/install_searx
fi
{ echo '[Unit]';
echo 'Description=Searx (search engine)';
echo 'After=syslog.target';
echo 'After=network.target';
echo '';
echo '[Service]';
echo 'Type=simple';
echo 'User=searx';
echo 'Group=searx';
echo "WorkingDirectory=${SEARX_PATH}/searx";
echo "ExecStart=/usr/bin/python ${SEARX_PATH}/searx/searx/webapp.py";
echo 'Restart=always';
echo 'Environment="USER=searx"';
echo '';
echo '[Install]';
echo 'WantedBy=multi-user.target'; } > "$rootdir/etc/systemd/system/searx.service"
create_searx_config
searx_set_default_background
if [ "$rootdir" ]; then
chroot "$rootdir" chown -R searx:searx ${SEARX_PATH}/searx
chroot "$rootdir" systemctl enable searx.service
chroot "$rootdir" systemctl daemon-reload
chroot "$rootdir" systemctl start searx.service
else
chown -R searx:searx ${SEARX_PATH}/searx
systemctl enable searx.service
systemctl daemon-reload
systemctl start searx.service
fi
if ! grep -q "SEARX_COMMIT=" "$rootdir$CONFIGURATION_FILE"; then
echo "SEARX_COMMIT=$SEARX_COMMIT" >> "$rootdir$CONFIGURATION_FILE"
else
sed -i "s|SEARX_COMMIT=.*|SEARX_COMMIT=$SEARX_COMMIT|g" "$rootdir$CONFIGURATION_FILE"
fi
}
function install_searx {
if [ ! -d /etc/nginx ]; then
echo $'Webserver is not installed'
......
This diff is collapsed.
......@@ -992,6 +992,11 @@ function image_install_web_admin {
echo ' }';
echo ' }';
echo '';
echo ' location ^~ /search {';
echo " proxy_pass http://localhost:${SEARX_PORT};";
echo ' proxy_set_header X-Script-Name /search;';
echo ' }';
echo '';
echo ' location ^~ /mail {';
echo ' client_max_body_size 200m;';
echo " root /var/www/${local_hostname}/htdocs;";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment