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-21 09:59:03 +02:00
parent ec897190f5
commit 17648dc8db
4 changed files with 29 additions and 33 deletions

View file

@ -5,5 +5,4 @@
- [Irakurri README euskaraz](README_eu.md) - [Irakurri README euskaraz](README_eu.md)
- [Lire le README en français](README_fr.md) - [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md) - [Le o README en galego](README_gl.md)
- [Baca README dalam bahasa bahasa Indonesia](README_id.md)
- [阅读中文(简体)的 README](README_zh_Hans.md) - [阅读中文(简体)的 README](README_zh_Hans.md)

View file

@ -9,46 +9,38 @@
#================================================= #=================================================
# Install/Upgrade SearXNG in virtual environement # Install/Upgrade SearXNG in virtual environement
myynh_install_searxng () { myynh_source_searxng () {
# Retrieve info from manifest
ynh_script_progression --message="Setting up source files..." --weight=1
# Download source
repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code") 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") commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename --suffix=".tar.gz")
ynh_exec_as $app git clone -n "$repo_fullpath" "$install_dir/searxng-src"
# Download source
ynh_exec_as $app ynh_exec_fully_quiet git clone -n "$repo_fullpath" "$install_dir/searxng-src"
pushd "$install_dir/searxng-src" pushd "$install_dir/searxng-src"
ynh_exec_as $app git checkout "$commit_sha" ynh_exec_as $app ynh_exec_fully_quiet git checkout "$commit_sha"
popd popd
}
myynh_install_searxng () {
# Create the virtual environment # Create the virtual environment
ynh_exec_as $app python3 -m venv "$install_dir/searxng-pyenv" sudo -i -u $app bash << EOF
python3 -m venv "$install_dir/searxng-pyenv"
echo ". $install_dir/searxng-pyenv/bin/activate" >> "$install_dir/.profile"
EOF
# Source the virtual environment in the user profile
ynh_exec_as $app echo ". $install_dir/searxng-pyenv/bin/activate" >> "$install_dir/.profile"
ynh_script_progression --message="Installing SearXNG..." --weight=2
# Install SearXNG in a 'sub shell'
(
# Check if virtualenv was sourced from the login # Check if virtualenv was sourced from the login
ynh_exec_as $app echo $(command -v python && python --version) sudo -i -u $app bash << EOF
command -v python && python --version
EOF
# Install last version of pip sudo -i -u $app bash << EOF
ynh_exec_warn_less ynh_exec_as $app pip install --upgrade pip pip install --upgrade pip
pip install --upgrade setuptools
# Install last version of setuptools pip install --upgrade wheel
ynh_exec_warn_less ynh_exec_as $app pip install --upgrade setuptools pip install --upgrade pyyaml
# Install last version of wheel
ynh_exec_warn_less ynh_exec_as $app pip install --upgrade wheel
# Install last version of pyyaml
ynh_exec_warn_less ynh_exec_as $app pip install --upgrade pyyaml
# Install SearXNG
cd "$install_dir/searxng-src" cd "$install_dir/searxng-src"
pip install -e . pip install -e .
) EOF
} }
# Upgrade the virtual environment directory # Upgrade the virtual environment directory

View file

@ -14,6 +14,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
myynh_source_searxng
ynh_script_progression --message="Installing SearXNG..." --weight=2
myynh_install_searxng myynh_install_searxng
#================================================= #=================================================

View file

@ -47,6 +47,7 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
myynh_upgrade_venv_directory myynh_upgrade_venv_directory
myynh_source_searxng
myynh_install_searxng myynh_install_searxng
fi fi