From ccc07840b7f39c092b85dff8e73a4f8046d70a25 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 3 Mar 2019 20:32:26 +0100 Subject: [PATCH 1/6] Normalization from example_ynh --- README.md | 66 ++++++++++++++++++--- conf/nginx.conf | 5 +- manifest.json | 2 +- scripts/_common.sh | 139 ++++++++++++++++++++++++++++++--------------- scripts/backup | 10 +--- scripts/install | 23 +++----- scripts/remove | 22 +++---- scripts/restore | 9 ++- scripts/upgrade | 28 ++++----- 9 files changed, 197 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index b47e10c..47f93b3 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,62 @@ -Searx for YunoHost -================== +# Searx for YunoHost -[Yunohost project](https://yunohost.org/#/) +[![Integration level](https://dash.yunohost.org/integration/searx.svg)](https://dash.yunohost.org/appci/app/searx) +[![Install Searx with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=searx) -Searx is a privacy-respecting, hackable metasearch engine. -For more information ,visit [Searx homepage](https://asciimoo.github.io/searx/). +> *This package allow you to install Searx quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* -This package is the [YunoHost](https://yunohost.org) application that ease -Searx installation on your YunoHost server. +## Overview + +Searx is a privacy-respecting, hackable metasearch engine. + +**Shipped version:** 0.14.0 + +## Screenshots + +## Demo + +* [YunoHost demo](https://demo.yunohost.org/searx/) + +## Configuration + +## Documentation + + * Official documentation: https://github.com/asciimoo/searx/wiki + +## YunoHost specific features + +#### Multi-users support + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/searx%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/searx/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/searx%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/searx/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/searx%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/searx/) + +## Limitations + +## Additional information + +- [Search syntax](https://asciimoo.github.io/searx/user/search_syntax.html) + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/searx_ynh/issues + * Searx website: https://asciimoo.github.io/searx/ + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/searx_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/searx_ynh/tree/testing --debug +or +sudo yunohost app upgrade searx -u https://github.com/YunoHost-Apps/searx_ynh/tree/testing --debug +``` diff --git a/conf/nginx.conf b/conf/nginx.conf index f68e6b5..3261a00 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,7 @@ -#noroot location = __PATH__ { rewrite ^ __PATH__/; } +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { -location __PATH__ { + # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } diff --git a/manifest.json b/manifest.json index 62e6426..f7de10d 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Un méta-moteur de recherche respectueux de la vie privée et bidouillable", "de": "Eine Meta-Suchmaschine, die den Privatsphäre wahrt und 'hackable' ist." }, - "version": "0.14.0~ynh1", + "version": "0.14.0~ynh2", "url": "https://asciimoo.github.io/searx/", "license": "AGPL-3.0-or-later", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 7160957..173b14b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,56 +1,105 @@ #!/bin/bash #================================================= -# EXPERIMENTAL HELPERS +# FUTURE OFFICIAL HELPERS #================================================= -# Start or restart a service and follow its booting +# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started # -# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name] -# -# | arg: Line to match - The line to find in the log to attest the service have finished to boot. -# | arg: Log file - The log file to watch -# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds. -# | arg: Service name -# /var/log/$app/$app.log will be used if no other log is defined. -ynh_check_starting () { - local line_to_match="$1" - local app_log="${2:-/var/log/$service_name/$service_name.log}" - local timeout=${3:-300} - local service_name="${4:-$app}" +# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] +# | arg: -n, --service_name= - Name of the service to reload. Default : $app +# | arg: -a, --action= - Action to perform with systemctl. Default: start +# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. +# If not defined it don't wait until the service is completely started. +# WARNING: When using --line_match, you should always add `ynh_clean_check_starting` into your +# `ynh_clean_setup` at the beginning of the script. Otherwise, tail will not stop in case of failure +# of the script. The script will then hang forever. +# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log +# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. +# | arg: -e, --length= - Length of the error log : Default : 20 +ynh_systemd_action() { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) + local service_name + local action + local line_match + local length + local log_path + local timeout - ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 - } + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - echo "Starting of $service_name" >&2 - systemctl stop $service_name - local templog="$(mktemp)" - # Following the starting of the app in its log - tail -F -n0 "$app_log" > "$templog" & - # Get the PID of the tail command - local pid_tail=$! - systemctl start $service_name + local service_name="${service_name:-$app}" + local action=${action:-start} + local log_path="${log_path:-/var/log/$service_name/$service_name.log}" + local length=${length:-20} + local timeout=${timeout:-300} - local i=0 - for i in `seq 1 $timeout` - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_to_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully started before the timeout." >&2 - fi + # Start to read the log + if [[ -n "${line_match:-}" ]] + then + local templog="$(mktemp)" + # Following the starting of the app in its log + if [ "$log_path" == "systemd" ] ; then + # Read the systemd journal + journalctl --unit=$service_name --follow --since=-0 --quiet > "$templog" & + # Get the PID of the journalctl command + local pid_tail=$! + else + # Read the specified log file + tail -F -n0 "$log_path" 2>&1 > "$templog" & + # Get the PID of the tail command + local pid_tail=$! + fi + fi - echo "" - ynh_clean_check_starting + ynh_print_info "${action^} the service $service_name" + systemctl $action $service_name \ + || ( journalctl --no-pager --lines=$length -u $service_name >&2 \ + ; test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2 \ + ; false ) + + # Start the timeout and try to find line_match + if [[ -n "${line_match:-}" ]] + then + local i=0 + for i in $(seq 1 $timeout) + do + # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout + if grep --quiet "$line_match" "$templog" + then + ynh_print_info "The service $service_name has correctly started." + break + fi + if [ $i -eq 3 ]; then + echo -n "Please wait, the service $service_name is ${action}ing" >&2 + fi + if [ $i -ge 3 ]; then + echo -n "." >&2 + fi + sleep 1 + done + if [ $i -ge 3 ]; then + echo "" >&2 + fi + if [ $i -eq $timeout ] + then + ynh_print_warn "The service $service_name didn't fully started before the timeout." + ynh_print_warn "Please find here an extract of the end of the log of the service $service_name:" + journalctl --no-pager --lines=$length -u $service_name >&2 + test -e "$log_path" && echo "--" >&2 && tail --lines=$length "$log_path" >&2 + fi + ynh_clean_check_starting + fi +} + +# Clean temporary process and file used by ynh_check_starting +# (usually used in ynh_clean_setup scripts) +# +# usage: ynh_clean_check_starting +ynh_clean_check_starting () { + # Stop the execution of tail. + kill -s 15 $pid_tail 2>&1 + ynh_secure_remove "$templog" 2>&1 } diff --git a/scripts/backup b/scripts/backup index 5d586f6..027ba01 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,12 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# if [ ! -e _common.sh ]; then -# # Rapatrie le fichier de fonctions si il n'est pas dans le dossier courant -# cp ../settings/scripts/_common.sh ./_common.sh -# chmod a+rx _common.sh -# fi -# source _common.sh +# source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -25,11 +20,10 @@ ynh_abort_if_errors # LOAD SETTINGS #================================================= -# Récupère les infos de l'application. app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD BACKUP STEPS diff --git a/scripts/install b/scripts/install index 32f2498..592f216 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE FAILURE OF THE SCRIPT #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -36,8 +39,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register $app $domain $path_url @@ -61,16 +62,9 @@ ynh_install_app_dependencies git build-essential libxslt-dev python-dev python-v # NGINX CONFIGURATION #================================================= -ynh_add_nginx_config -if [ "$path_url" = "/" ] -then - ynh_replace_string "__PATH_NO_ROOT__" "" /etc/nginx/conf.d/$domain.d/$app.conf - sed --in-place '/#noroot*/d' /etc/nginx/conf.d/$domain.d/$app.conf -else - ynh_replace_string "#noroot" "" /etc/nginx/conf.d/$domain.d/$app.conf - ynh_replace_string "__PATH_NO_ROOT__" "$path_url" /etc/nginx/conf.d/$domain.d/$app.conf -fi -ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" +path_no_root=${path_url%/} +# Create a dedicated nginx config +ynh_add_nginx_config "path_no_root" #================================================= # CREATE DEDICATED USER @@ -133,10 +127,9 @@ ynh_replace_string "__FINALPATH__" "$final_path" /etc/uwsgi/apps-available/$app. ln -s /etc/uwsgi/apps-available/$app.ini /etc/uwsgi/apps-enabled/$app.ini #================================================= -# ENABLE UWSGI SERVICE IN ADMIN PANEL +# ADVERTISE SERVICE IN ADMIN PANEL #================================================= -systemctl restart uwsgi # Ajoute le service au monitoring de Yunohost. yunohost service add uwsgi --log "/var/log/uwsgi/app/$app.log" @@ -145,7 +138,7 @@ yunohost service add uwsgi --log "/var/log/uwsgi/app/$app.log" #================================================= # Wait for searx to be fully started -ynh_check_starting "spawned uWSGI master process" "/var/log/uwsgi/app/$app.log" "300" "uwsgi" +ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/app/$app.log" #================================================= # GENERIC FINALISATION diff --git a/scripts/remove b/scripts/remove index 611f594..4aaae73 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -16,6 +16,7 @@ source /usr/share/yunohost/helpers app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE @@ -24,9 +25,10 @@ domain=$(ynh_app_setting_get $app domain) #================================================= # Remove the uwsgi configuration -systemctl stop uwsgi -if [ -h "/etc/uwsgi/apps-enabled/$app.ini" ]; then - echo "Delete uwsgi config" +ynh_systemd_action --service_name=uwsgi --action=stop +if [ -h "/etc/uwsgi/apps-enabled/$app.ini" ] +then + ynh_print_info "Delete uwsgi config for $app" ynh_secure_remove "/etc/uwsgi/apps-enabled/$app.ini" fi ynh_secure_remove "/etc/uwsgi/apps-available/$app.ini" @@ -41,7 +43,7 @@ ynh_remove_app_dependencies # REMOVE THE MAIN DIR OF THE APP #================================================= -ynh_secure_remove "/opt/yunohost/$app" +ynh_secure_remove "$final_path" #================================================= # REMOVE THE NGINX CONFIGURATION @@ -51,23 +53,23 @@ ynh_secure_remove "/opt/yunohost/$app" ynh_remove_nginx_config #================================================= -# DISABLE SERVICE IN ADMIN PANEL +# REMOVE SERVICE FROM ADMIN PANEL #================================================= if [ -e /etc/init.d/uwsgi ] then # Redémarre le service uwsgi si il n'est pas désinstallé. - systemctl start uwsgi + ynh_systemd_action --service_name=uwsgi --action=start else - if yunohost service status | grep -q uwsgi # Test l'existence du service dans Yunohost + if yunohost service status | grep -q uwsgi then - echo "Remove uwsgi service" + ynh_print_info "Remove uwsgi service" yunohost service remove uwsgi fi fi #================================================= -# GENERIC FINALISATION +# GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= diff --git a/scripts/restore b/scripts/restore index 413aa02..8380e09 100755 --- a/scripts/restore +++ b/scripts/restore @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -22,9 +25,9 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -47,7 +50,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" # RESTORE OF THE MAIN DIR OF THE APP #================================================= -mkdir -p /opt/yunohost +mkdir -p "$(dirname "$final_path")" ynh_restore_file "$final_path" #================================================= @@ -91,4 +94,4 @@ systemctl reload nginx #================================================= # Wait for searx to be fully started -ynh_check_starting "spawned uWSGI master process" "/var/log/uwsgi/app/$app.log" "300" "uwsgi" +ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/app/$app.log" diff --git a/scripts/upgrade b/scripts/upgrade index b71f771..177664b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,7 @@ is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) #================================================= -# FIX OLD THINGS +# ENSURE DOWNWARD COMPATIBILITY #================================================= # Fix is_public as a boolean value @@ -43,11 +43,14 @@ fi # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_backup_before_upgrade # Backup the current version of the app +# Backup the current version of the app +ynh_backup_before_upgrade ynh_clean_setup () { - ynh_restore_upgradebackup # restore it if the upgrade fails + # restore it if the upgrade fails + ynh_restore_upgradebackup } -ynh_abort_if_errors # Exit if an error occurs during the execution of the script +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # CHECK THE PATH @@ -78,22 +81,15 @@ ynh_setup_source "$final_path" # NGINX CONFIGURATION #================================================= -ynh_add_nginx_config -if [ "$path_url" = "/" ] -then - ynh_replace_string "__PATH_NO_ROOT__" "" /etc/nginx/conf.d/$domain.d/$app.conf - sed --in-place '/#noroot*/d' /etc/nginx/conf.d/$domain.d/$app.conf -else - ynh_replace_string "#noroot" "" /etc/nginx/conf.d/$domain.d/$app.conf - ynh_replace_string "__PATH_NO_ROOT__" "$path_url" /etc/nginx/conf.d/$domain.d/$app.conf -fi -ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" +path_no_root=${path_url%/} +# Create a dedicated nginx config +ynh_add_nginx_config "path_no_root" #================================================= # CREATE DEDICATED USER #================================================= -# Create a system user +# Create a dedicated user (if not existing) ynh_system_user_create $app #================================================= @@ -148,7 +144,7 @@ ynh_replace_string "__FINALPATH__" "$final_path" /etc/uwsgi/apps-available/$app. #================================================= # Wait for searx to be fully started -ynh_check_starting "spawned uWSGI master process" "/var/log/uwsgi/app/$app.log" "300" "uwsgi" +ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/app/$app.log" #================================================= # SETUP SSOWAT From f1bbc57a4edf571fb52d6555d28aab736522dd6f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 3 Mar 2019 20:33:02 +0100 Subject: [PATCH 2/6] Add progression with ynh_print_info --- manifest.json | 2 +- scripts/backup | 10 ++++++++++ scripts/install | 18 ++++++++++++++++++ scripts/remove | 12 ++++++++++++ scripts/restore | 12 ++++++++++++ scripts/upgrade | 19 +++++++++++++++++++ 6 files changed, 72 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index f7de10d..d99d860 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "email": "opi@zeropi.net" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.2.0" }, "multi_instance": false, "services": [ diff --git a/scripts/backup b/scripts/backup index 027ba01..71f68a4 100755 --- a/scripts/backup +++ b/scripts/backup @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -30,12 +31,14 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # BACKUP OF THE MAIN DIR OF THE APP #================================================= +ynh_print_info "Backing up the main app directory..." ynh_backup "$final_path" #================================================= # BACKUP OF THE NGINX CONFIGURATION #================================================= +ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" @@ -44,5 +47,12 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP OF THE UWSGI CONFIG #================================================= +ynh_print_info "Backing up uWSGI configuration..." ynh_backup "/etc/uwsgi/apps-available/$app.ini" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 592f216..ac1924e 100644 --- a/scripts/install +++ b/scripts/install @@ -32,6 +32,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS #================================================= +ynh_print_info "Validating installation parameters..." final_path="/opt/yunohost/$app" test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -45,6 +46,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -55,12 +57,14 @@ ynh_app_setting_set $app is_public $is_public #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_print_info "Installing dependencies..." ynh_install_app_dependencies git build-essential libxslt-dev python-dev python-virtualenv virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx web server..." path_no_root=${path_url%/} # Create a dedicated nginx config @@ -69,6 +73,7 @@ ynh_add_nginx_config "path_no_root" #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Configuring system user..." # Create a system user ynh_system_user_create $app @@ -76,6 +81,7 @@ ynh_system_user_create $app #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Setting up source files..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src @@ -86,6 +92,7 @@ ynh_setup_source "$final_path" #================================================= # INSTALL SEARX IN A VIRTUALENV #================================================= +ynh_print_info "Installing Searx..." virtualenv --system-site-packages "$final_path" set +u; source $final_path/bin/activate; set -u @@ -95,6 +102,7 @@ pip install --requirement $final_path/requirements-ynh.txt #================================================= # CONFIGURE SEARX #================================================= +ynh_print_info "Configuring Searx..." # Change instance name ynh_replace_string "instance_name : \"searx\"" "instance_name : \"YunoSearx\"" "$final_path/searx/settings.yml" @@ -120,6 +128,7 @@ chown $app: --recursive "$final_path" #================================================= # CONFIGURE UWSGI FOR SEARX #================================================= +ynh_print_info "Configuring uWSGI for Searx..." cp ../conf/searx.ini /etc/uwsgi/apps-available/$app.ini ynh_replace_string "__APP__" "$app" /etc/uwsgi/apps-available/$app.ini @@ -136,6 +145,7 @@ yunohost service add uwsgi --log "/var/log/uwsgi/app/$app.log" #================================================= # CHECK SEARX STARTING #================================================= +ynh_print_info "Starting Searx..." # Wait for searx to be fully started ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/app/$app.log" @@ -145,6 +155,7 @@ ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned u #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -155,5 +166,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 4aaae73..eb81181 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -23,6 +24,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # STOP AND REMOVE SERVICE #================================================= +ynh_print_info "Stopping and removing the systemd service" # Remove the uwsgi configuration ynh_systemd_action --service_name=uwsgi --action=stop @@ -36,18 +38,21 @@ ynh_secure_remove "/etc/uwsgi/apps-available/$app.ini" #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_print_info "Removing dependencies" ynh_remove_app_dependencies #================================================= # REMOVE THE MAIN DIR OF THE APP #================================================= +ynh_print_info "Removing app main directory" ynh_secure_remove "$final_path" #================================================= # REMOVE THE NGINX CONFIGURATION #================================================= +ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -73,6 +78,13 @@ fi #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Removing the dedicated system user" # Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 8380e09..881bbae 100755 --- a/scripts/restore +++ b/scripts/restore @@ -32,6 +32,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -49,6 +50,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE OF THE MAIN DIR OF THE APP #================================================= +ynh_print_info "Restoring the app main directory..." mkdir -p "$(dirname "$final_path")" ynh_restore_file "$final_path" @@ -56,12 +58,14 @@ ynh_restore_file "$final_path" #================================================= # INSTALL DEPENDENCIES #================================================= +ynh_print_info "Reinstalling dependencies..." ynh_install_app_dependencies git build-essential libxslt-dev python-dev python-virtualenv virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python #================================================= # RECREATE OF THE DEDICATED USER #================================================= +ynh_print_info "Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create $app @@ -86,12 +90,20 @@ ln -s /etc/uwsgi/apps-available/$app.ini /etc/uwsgi/apps-enabled/$app.ini #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx #================================================= # CHECK SEARX STARTING #================================================= +ynh_print_info "Starting Searx..." # Wait for searx to be fully started ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/app/$app.log" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 177664b..ac4bdac 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -23,6 +24,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_print_info "Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "${is_public,,}" = "yes" ]; then @@ -42,6 +44,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -64,12 +67,14 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # UPGRADE DEPENDENCIES #================================================= +ynh_print_info "Upgrading dependencies..." ynh_install_app_dependencies git build-essential libxslt-dev python-dev python-virtualenv virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Upgrading source files..." # Verify the checksum and backup the file if it's different ynh_backup_if_checksum_is_different "$final_path/searx/settings.yml" @@ -80,6 +85,7 @@ ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Upgrading nginx web server configuration..." path_no_root=${path_url%/} # Create a dedicated nginx config @@ -88,6 +94,7 @@ ynh_add_nginx_config "path_no_root" #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -97,6 +104,7 @@ ynh_system_user_create $app #================================================= # UPGRADE SEARX IN ITS VIRTUALENV #================================================= +ynh_print_info "Upgrading Searx..." rm -r $final_path/lib/python2.7/site-packages/setuptools $final_path/lib/python2.7/site-packages/setuptools-* virtualenv --system-site-packages "$final_path" @@ -107,6 +115,7 @@ pip install --requirement $final_path/requirements-ynh.txt --upgrade #================================================= # CONFIGURE SEARX #================================================= +ynh_print_info "Reconfiguring Searx..." # Change instance name ynh_replace_string "instance_name : \"searx\"" "instance_name : \"YunoSearx\"" "$final_path/searx/settings.yml" @@ -134,6 +143,7 @@ chown $app: --recursive "$final_path" #================================================= # CONFIGURE UWSGI FOR SEARX #================================================= +ynh_print_info "Reconfiguring uWSGI for Searx..." cp ../conf/searx.ini /etc/uwsgi/apps-available/$app.ini ynh_replace_string "__APP__" "$app" /etc/uwsgi/apps-available/$app.ini @@ -142,6 +152,7 @@ ynh_replace_string "__FINALPATH__" "$final_path" /etc/uwsgi/apps-available/$app. #================================================= # CHECK SEARX STARTING #================================================= +ynh_print_info "Restarting Searx..." # Wait for searx to be fully started ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/app/$app.log" @@ -149,6 +160,7 @@ ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned u #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -159,5 +171,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" From 4cb1310e4ded0a37a166d2721e3eaee8bec90c94 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 24 Mar 2019 16:47:27 +0100 Subject: [PATCH 3/6] Update pull_request_template.md --- pull_request_template.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 5f38ab0..25913d5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,7 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/searx_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/searx_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* -or -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/searx_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/searx_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/searx_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/searx_ynh%20PR-NUM-/) +*Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From ed336272f2a5fe7a88d6812b5af476cc9a92be6e Mon Sep 17 00:00:00 2001 From: Kayou Date: Mon, 8 Apr 2019 15:08:56 +0200 Subject: [PATCH 4/6] Fix ARM install #43 --- sources/extra_files/app/requirements-ynh.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/extra_files/app/requirements-ynh.txt b/sources/extra_files/app/requirements-ynh.txt index d0a8eef..eb02727 100644 --- a/sources/extra_files/app/requirements-ynh.txt +++ b/sources/extra_files/app/requirements-ynh.txt @@ -13,6 +13,6 @@ requests[socks]==2.18.4 # Additionnals requirements markupsafe>=0.23 ndg-httpsclient>=0.4.2 -pyasn1>=0.1.9 -pyasn1-modules>=0.0.8 -cffi>=1.6 +pyasn1>=0.2.3 +pyasn1-modules>=0.0.9 +cffi>=1.12.1 From 6cc38c8dfc9a31ed9585fcf688f6749e0c0aaaaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Bourr=C3=A9?= Date: Sat, 13 Apr 2019 00:38:47 +0200 Subject: [PATCH 5/6] potential solution --- scripts/_common.sh | 7 +++++++ scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 173b14b..c66e49f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,12 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="git build-essential libxslt-dev python-dev python-virtualenv python-cffi virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python" + #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index ac1924e..7d0fd1c 100644 --- a/scripts/install +++ b/scripts/install @@ -59,7 +59,7 @@ ynh_app_setting_set $app is_public $is_public #================================================= ynh_print_info "Installing dependencies..." -ynh_install_app_dependencies git build-essential libxslt-dev python-dev python-virtualenv virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python +ynh_install_app_dependencies $pkg_dependencies #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 881bbae..ca9171b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -60,7 +60,7 @@ ynh_restore_file "$final_path" #================================================= ynh_print_info "Reinstalling dependencies..." -ynh_install_app_dependencies git build-essential libxslt-dev python-dev python-virtualenv virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python +ynh_install_app_dependencies $pkg_dependencies #================================================= # RECREATE OF THE DEDICATED USER diff --git a/scripts/upgrade b/scripts/upgrade index ac4bdac..4c67861 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,7 +69,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= ynh_print_info "Upgrading dependencies..." -ynh_install_app_dependencies git build-essential libxslt-dev python-dev python-virtualenv virtualenv python-babel zlib1g-dev libffi-dev libssl-dev python-lxml uwsgi uwsgi-plugin-python +ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE From 1371678df0eace8039894d8119132b2adee97b14 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 15 Apr 2019 20:55:05 +0200 Subject: [PATCH 6/6] Move from ci-apps-dev to ci-apps-hq --- pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull_request_template.md b/pull_request_template.md index 25913d5..c2a7d44 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,6 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/searx_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/searx_ynh%20PR-NUM-/) +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/searx_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/searx_ynh%20PR-NUM-/) *Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.