mirror of
https://github.com/YunoHost-Apps/searx_ynh.git
synced 2024-09-03 20:16:30 +02:00
Normalization from example_ynh
This commit is contained in:
parent
a4c3b09237
commit
ccc07840b7
9 changed files with 197 additions and 107 deletions
64
README.md
64
README.md
|
@ -1,10 +1,62 @@
|
|||
Searx for YunoHost
|
||||
==================
|
||||
# Searx for YunoHost
|
||||
|
||||
[Yunohost project](https://yunohost.org/#/)
|
||||
[](https://dash.yunohost.org/appci/app/searx)
|
||||
[](https://install-app.yunohost.org/?app=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.*
|
||||
|
||||
## Overview
|
||||
|
||||
Searx is a privacy-respecting, hackable metasearch engine.
|
||||
For more information ,visit [Searx homepage](https://asciimoo.github.io/searx/).
|
||||
|
||||
This package is the [YunoHost](https://yunohost.org) application that ease
|
||||
Searx installation on your YunoHost server.
|
||||
**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 - [](https://ci-apps.yunohost.org/ci/apps/searx/)
|
||||
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/searx/)
|
||||
* Jessie x86-64b - [](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
|
||||
```
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue