1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/searxng_ynh.git synced 2024-09-03 20:26:00 +02:00

Refractor

This commit is contained in:
Sylvain 2024-07-22 16:17:56 +02:00
parent ca9d0aaea5
commit 6a66fca2fb
12 changed files with 76 additions and 45 deletions

View file

@ -19,7 +19,7 @@ It shall NOT be edited by hand.
SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled. SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled.
**Shipped version:** 2024.07.08~ynh2 **Shipped version:** 2024.07.08~ynh3
**Demo:** <https://searx.be> **Demo:** <https://searx.be>

View file

@ -19,7 +19,7 @@ No se debe editar a mano.
SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled. SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled.
**Versión actual:** 2024.07.08~ynh2 **Versión actual:** 2024.07.08~ynh3
**Demo:** <https://searx.be> **Demo:** <https://searx.be>

View file

@ -19,7 +19,7 @@ EZ editatu eskuz.
SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled. SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled.
**Paketatutako bertsioa:** 2024.07.08~ynh2 **Paketatutako bertsioa:** 2024.07.08~ynh3
**Demoa:** <https://searx.be> **Demoa:** <https://searx.be>

View file

@ -19,7 +19,7 @@ Il NE doit PAS être modifié à la main.
SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled. SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled.
**Version incluse:** 2024.07.08~ynh2 **Version incluse:** 2024.07.08~ynh3
**Démo:** <https://searx.be> **Démo:** <https://searx.be>

View file

@ -19,7 +19,7 @@ NON debe editarse manualmente.
SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled. SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled.
**Versión proporcionada:** 2024.07.08~ynh2 **Versión proporcionada:** 2024.07.08~ynh3
**Demo:** <https://searx.be> **Demo:** <https://searx.be>

View file

@ -19,7 +19,7 @@ Ini TIDAK boleh diedit dengan tangan.
SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled. SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled.
**Versi terkirim:** 2024.07.08~ynh2 **Versi terkirim:** 2024.07.08~ynh3
**Demo:** <https://searx.be> **Demo:** <https://searx.be>

View file

@ -19,7 +19,7 @@
SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled. SearxXNG is a free internet metasearch engine which aggregates results from more than 70 search services. Users are neither tracked nor profiled.
**分发版本:** 2024.07.08~ynh2 **分发版本:** 2024.07.08~ynh3
**演示:** <https://searx.be> **演示:** <https://searx.be>

View file

@ -5,7 +5,7 @@ name = "SearXNG"
description.en = "Internet metasearch engine which aggregates results from more than 70 search services" description.en = "Internet metasearch engine which aggregates results from more than 70 search services"
description.fr = "Méta-moteur de recherche qui rassemble les résultats de plus de 70 services de recherche" description.fr = "Méta-moteur de recherche qui rassemble les résultats de plus de 70 services de recherche"
version = "2024.07.08~ynh2" version = "2024.07.08~ynh3"
maintainers = ["mh4ckt3mh4ckt1c4s", "ewilly"] maintainers = ["mh4ckt3mh4ckt1c4s", "ewilly"]
@ -56,4 +56,4 @@ ram.runtime = "200M"
main.url = "/" main.url = "/"
[resources.apt] [resources.apt]
packages = "git, build-essential, libxslt-dev, python3-dev, python3-venv, python3-cffi, python3-babel, zlib1g-dev, libffi-dev, libssl-dev, python3-lxml, uwsgi, uwsgi-plugin-python3, shellcheck" packages = "python3-dev, python3-babel, python3-venv, uwsgi, uwsgi-plugin-python3, git, build-essential, libxslt-dev, zlib1g-dev, libffi-dev, libssl-dev"

View file

@ -4,6 +4,60 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
# Install/Upgrade SearXNG in virtual environement
myynh_source_searxng () {
# Retrieve info from manifest
repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code")
commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename --suffix=".tar.gz")
# Download source
sudo -H -u $app -i bash << EOF
mkdir "$install_dir/searxng-src"
git clone -n "$repo_fullpath" "$install_dir/searxng-src" 2>&1
EOF
# Checkout commit
pushd "$install_dir/searxng-src"
sudo -H -u $app -i bash << EOF
cd "$install_dir/searxng-src"
git checkout "$commit_sha" 2>&1
EOF
popd
}
myynh_install_searxng () {
# Create the virtual environment
sudo -H -u $app -i bash << EOF
python3 -m venv "$install_dir/searxng-pyenv"
echo ". $install_dir/searxng-pyenv/bin/activate" > "$install_dir/.profile"
EOF
# Check if virtualenv was sourced from the login
sudo -H -u $app -i bash << EOF
command -v python && python --version
EOF
sudo -H -u $app -i bash << EOF
pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade wheel
pip install --upgrade pyyaml
cd "$install_dir/searxng-src"
pip install -e .
EOF
}
# Set permissions
myynh_set_permissions () {
chown -R $app: "$install_dir"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
}
#================================================= #=================================================
# UWSGI HELPERS # UWSGI HELPERS
#================================================= #=================================================
@ -71,7 +125,8 @@ ynh_add_uwsgi_service () {
# Setup specific Systemd rules if necessary # Setup specific Systemd rules if necessary
mkdir -p "/etc/systemd/system/uwsgi-app@$app.service.d" mkdir -p "/etc/systemd/system/uwsgi-app@$app.service.d"
if [ -e "../conf/uwsgi-app@override.service" ]; then if [ -e "../conf/uwsgi-app@override.service" ]
then
ynh_add_config --template="uwsgi-app@override.service" --destination="/etc/systemd/system/uwsgi-app@$app.service.d/override.conf" ynh_add_config --template="uwsgi-app@override.service" --destination="/etc/systemd/system/uwsgi-app@$app.service.d/override.conf"
fi fi
@ -87,7 +142,8 @@ ynh_add_uwsgi_service () {
# usage: ynh_remove_uwsgi_service # usage: ynh_remove_uwsgi_service
ynh_remove_uwsgi_service () { ynh_remove_uwsgi_service () {
local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
if [ -e "$finaluwsgiini" ]; then if [ -e "$finaluwsgiini" ]
then
yunohost service remove "uwsgi-app@$app" yunohost service remove "uwsgi-app@$app"
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop"
ynh_exec_fully_quiet ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="disable" ynh_exec_fully_quiet ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="disable"

View file

@ -15,20 +15,10 @@ source /usr/share/yunohost/helpers
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
myynh_source_searxng
repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code")
commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename --suffix=".tar.gz")
ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src"
pushd "$install_dir/searxng-src"
ynh_exec_fully_quiet git checkout "$commit_sha"
popd
ynh_script_progression --message="Installing SearXNG..." --weight=2 ynh_script_progression --message="Installing SearXNG..." --weight=2
myynh_install_searxng
python3 -m venv --system-site-packages "$install_dir/searxng-pyenv"
set +o nounset; source "$install_dir/searxng-pyenv/bin/activate"; set -o nounset
pip3 install -U pip "setuptools<71.0.0" wheel pyyaml --no-cache-dir
ynh_exec_fully_quiet pip3 install -e "$install_dir/searxng-src"
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
@ -49,9 +39,7 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1
secret_key=$(ynh_string_random) secret_key=$(ynh_string_random)
ynh_add_config --template="../conf/settings.yml" --destination="$install_dir/settings.yml" ynh_add_config --template="../conf/settings.yml" --destination="$install_dir/settings.yml"
chmod 750 "$install_dir" myynh_set_permissions
chmod -R o-rwx "$install_dir"
chown -R $app: "$install_dir"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -16,9 +16,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$install_dir" ynh_restore_file --origin_path="$install_dir"
chown -R $app:www-data "$install_dir" myynh_set_permissions
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS

View file

@ -46,26 +46,15 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_secure_remove --file="$install_dir/.profile"
ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$install_dir/searxng-src" ynh_secure_remove --file="$install_dir/searxng-src"
repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code")
commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename --suffix=".tar.gz")
ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src"
pushd "$install_dir/searxng-src"
ynh_exec_fully_quiet git checkout "$commit_sha"
popd
ynh_secure_remove --file="$install_dir/searxng-pyenv" ynh_secure_remove --file="$install_dir/searxng-pyenv"
python3 -m venv --system-site-packages "$install_dir/searxng-pyenv" myynh_source_searxng
set +o nounset; source "$install_dir/searxng-pyenv/bin/activate"; set -o nounset myynh_install_searxng
pip3 install -U pip "setuptools<71.0.0" wheel pyyaml --no-cache-dir
ynh_exec_fully_quiet pip3 install -e "$install_dir/searxng-src"
fi fi
chmod 750 "$install_dir" myynh_set_permissions
chmod -R o-rwx "$install_dir"
chown -R $app: "$install_dir"
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # REAPPLY SYSTEM CONFIGURATIONS