diff --git a/README.md b/README.md index 3682d78..9fc5959 100644 --- a/README.md +++ b/README.md @@ -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. -**Shipped version:** 2024.07.08~ynh2 +**Shipped version:** 2024.07.08~ynh3 **Demo:** diff --git a/README_es.md b/README_es.md index a80bfec..c64a905 100644 --- a/README_es.md +++ b/README_es.md @@ -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. -**Versión actual:** 2024.07.08~ynh2 +**Versión actual:** 2024.07.08~ynh3 **Demo:** diff --git a/README_eu.md b/README_eu.md index ae6f267..9b9cf69 100644 --- a/README_eu.md +++ b/README_eu.md @@ -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. -**Paketatutako bertsioa:** 2024.07.08~ynh2 +**Paketatutako bertsioa:** 2024.07.08~ynh3 **Demoa:** diff --git a/README_fr.md b/README_fr.md index 024f40b..3c8021f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -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. -**Version incluse :** 2024.07.08~ynh2 +**Version incluse :** 2024.07.08~ynh3 **Démo :** diff --git a/README_gl.md b/README_gl.md index fa7b80a..ead840b 100644 --- a/README_gl.md +++ b/README_gl.md @@ -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. -**Versión proporcionada:** 2024.07.08~ynh2 +**Versión proporcionada:** 2024.07.08~ynh3 **Demo:** diff --git a/README_id.md b/README_id.md index b516642..a6e8aac 100644 --- a/README_id.md +++ b/README_id.md @@ -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. -**Versi terkirim:** 2024.07.08~ynh2 +**Versi terkirim:** 2024.07.08~ynh3 **Demo:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index e86c4f5..d0a617c 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -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. -**分发版本:** 2024.07.08~ynh2 +**分发版本:** 2024.07.08~ynh3 **演示:** diff --git a/manifest.toml b/manifest.toml index d7385aa..1769b8f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "SearXNG" 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" -version = "2024.07.08~ynh2" +version = "2024.07.08~ynh3" maintainers = ["mh4ckt3mh4ckt1c4s", "ewilly"] @@ -56,4 +56,4 @@ ram.runtime = "200M" main.url = "/" [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" diff --git a/scripts/_common.sh b/scripts/_common.sh index 15c1ebe..e91855d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,60 @@ # 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 #================================================= @@ -71,7 +125,8 @@ ynh_add_uwsgi_service () { # Setup specific Systemd rules if necessary 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" fi @@ -87,7 +142,8 @@ ynh_add_uwsgi_service () { # usage: ynh_remove_uwsgi_service ynh_remove_uwsgi_service () { local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini" - if [ -e "$finaluwsgiini" ]; then + if [ -e "$finaluwsgiini" ] + then yunohost service remove "uwsgi-app@$app" 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" diff --git a/scripts/install b/scripts/install index 7d472c5..fa616c5 100755 --- a/scripts/install +++ b/scripts/install @@ -15,20 +15,10 @@ source /usr/share/yunohost/helpers # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 - -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 +myynh_source_searxng ynh_script_progression --message="Installing SearXNG..." --weight=2 - -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" +myynh_install_searxng #================================================= # SYSTEM CONFIGURATION @@ -49,9 +39,7 @@ ynh_script_progression --message="Adding a configuration file..." --weight=1 secret_key=$(ynh_string_random) ynh_add_config --template="../conf/settings.yml" --destination="$install_dir/settings.yml" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app: "$install_dir" +myynh_set_permissions #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index 1ac85c5..4cd5198 100755 --- a/scripts/restore +++ b/scripts/restore @@ -16,9 +16,7 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chown -R $app:www-data "$install_dir" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" +myynh_set_permissions #================================================= # RESTORE SYSTEM CONFIGURATIONS diff --git a/scripts/upgrade b/scripts/upgrade index 331f05e..d435a78 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,26 +46,15 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log if [ "$upgrade_type" == "UPGRADE_APP" ] 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" - 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" - 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" + myynh_source_searxng + myynh_install_searxng fi -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R $app: "$install_dir" +myynh_set_permissions #================================================= # REAPPLY SYSTEM CONFIGURATIONS