mirror of
https://github.com/YunoHost-Apps/searxng_ynh.git
synced 2024-09-03 20:26:00 +02:00
Refactor
This commit is contained in:
parent
699876f4cb
commit
61fdd293b1
5 changed files with 81 additions and 41 deletions
|
@ -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"
|
||||||
|
|
|
@ -4,6 +4,79 @@
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PERSONAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Install/Upgrade SearXNG in virtual environement
|
||||||
|
myynh_install_searxng () {
|
||||||
|
|
||||||
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
|
|
||||||
|
# Download source
|
||||||
|
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_as $app git clone -n "$repo_fullpath" "$install_dir/searxng-src"
|
||||||
|
pushd "$install_dir/searxng-src"
|
||||||
|
ynh_exec_as $app git checkout "$commit_sha"
|
||||||
|
popd
|
||||||
|
|
||||||
|
# Create the virtual environment
|
||||||
|
ynh_exec_as $app python3 -m venv "$install_dir/searxng-pyenv"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
ynh_exec_as $app echo $(command -v python && python --version)
|
||||||
|
|
||||||
|
# Install last version of pip
|
||||||
|
ynh_exec_warn_less ynh_exec_as $app pip install --upgrade pip
|
||||||
|
|
||||||
|
# Install last version of setuptools
|
||||||
|
ynh_exec_warn_less ynh_exec_as $app pip install --upgrade setuptools
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
pip install -e .
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Upgrade the virtual environment directory
|
||||||
|
myynh_upgrade_venv_directory () {
|
||||||
|
|
||||||
|
# Remove old python links before recreating them
|
||||||
|
find "$install_dir/bin/" -type l -name 'python*' \
|
||||||
|
-exec bash -c 'rm --force "$1"' _ {} \;
|
||||||
|
|
||||||
|
# Remove old python directories before recreating them
|
||||||
|
find "$install_dir/lib/" -mindepth 1 -maxdepth 1 -type d -name "python*" \
|
||||||
|
-not -path "*/python${py_required_version%.*}" \
|
||||||
|
-exec bash -c 'rm --force --recursive "$1"' _ {} \;
|
||||||
|
find "$install_dir/include/site/" -mindepth 1 -maxdepth 1 -type d -name "python*" \
|
||||||
|
-not -path "*/python${py_required_version%.*}" \
|
||||||
|
-exec bash -c 'rm --force --recursive "$1"' _ {} \;
|
||||||
|
|
||||||
|
# Upgrade the virtual environment directory
|
||||||
|
ynh_exec_as $app $py_app_version -m venv --upgrade "$install_dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
myynh_set_permissions () {
|
||||||
|
chown -R $app: "$install_dir"
|
||||||
|
chmod 750 "$install_dir"
|
||||||
|
chmod -R o-rwx "$install_dir"
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UWSGI HELPERS
|
# UWSGI HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -14,21 +14,7 @@ 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_install_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
|
|
||||||
|
|
||||||
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 +35,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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -46,26 +46,11 @@ 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
|
myynh_upgrade_venv_directory
|
||||||
|
myynh_install_searxng
|
||||||
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"
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue