mirror of
https://github.com/YunoHost-Apps/searx_ynh.git
synced 2024-09-03 20:16:30 +02:00
commit
61b473a96b
14 changed files with 383 additions and 213 deletions
67
README.md
67
README.md
|
@ -1,10 +1,63 @@
|
|||
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)
|
||||
|
||||
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.15.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/
|
||||
* Searx repository: https://github.com/asciimoo/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
|
||||
```
|
||||
|
|
|
@ -16,19 +16,9 @@
|
|||
multi_instance=0
|
||||
incorrect_path=1
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
change_url=1
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
Level 4=na
|
||||
# Level 5: https://github.com/YunoHost-Apps/searx_ynh/issues/17
|
||||
Level 5=1
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
Level 5=auto
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
SOURCE_URL=https://github.com/asciimoo/searx/archive/v0.14.0.tar.gz
|
||||
SOURCE_SUM=002c7f9ceeafc5ada2f1fd30b5d5f6c9
|
||||
SOURCE_SUM_PRG=md5sum
|
||||
SOURCE_URL=https://github.com/asciimoo/searx/archive/v0.15.0.tar.gz
|
||||
SOURCE_SUM=9d605ca08adc91fab27b4fd5311c9585620a9152e9f3e8b4f41f6ec7231af3efe3effdd3f8c0e6d08898c2116ef429455ec8525dad35e17329bd1e509828ba4b
|
||||
SOURCE_SUM_PRG=sha512sum
|
||||
SOURCE_FORMAT=tar.gz
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
SOURCE_FILENAME=searx.tar.gz
|
||||
|
|
|
@ -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.15.0~ynh1",
|
||||
"url": "https://asciimoo.github.io/searx/",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"maintainer": {
|
||||
|
@ -15,7 +15,7 @@
|
|||
"email": "opi@zeropi.net"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 2.7.2"
|
||||
"yunohost": ">= 3.5.0"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
- [ ] **Approval (LGTM)** :
|
||||
- [ ] **Approval (LGTM)** :
|
||||
- **CI succeeded** :
|
||||
[/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
|
||||
[/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.*
|
||||
[](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.
|
||||
|
|
|
@ -1,56 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
# Start or restart a service and follow its booting
|
||||
#
|
||||
# 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}"
|
||||
|
||||
ynh_clean_check_starting () {
|
||||
# Stop the execution of tail.
|
||||
kill -s 15 $pid_tail 2>&1
|
||||
ynh_secure_remove "$templog" 2>&1
|
||||
}
|
||||
|
||||
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 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
|
||||
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# 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"
|
||||
|
|
|
@ -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
|
||||
|
||||
#=================================================
|
||||
|
@ -24,31 +19,40 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
|
||||
# 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)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
#=================================================
|
||||
# BACKUP OF THE MAIN DIR OF THE APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the main app directory..."
|
||||
|
||||
ynh_backup "$final_path"
|
||||
ynh_backup --src_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# BACKUP OF THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up nginx web server configuration..."
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP OF THE UWSGI CONFIG
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up uWSGI configuration..."
|
||||
|
||||
ynh_backup "/etc/uwsgi/apps-available/$app.ini"
|
||||
ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
|
||||
|
|
117
scripts/change_url
Normal file
117
scripts/change_url
Normal file
|
@ -0,0 +1,117 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
old_domain=$YNH_APP_OLD_DOMAIN
|
||||
old_path=$YNH_APP_OLD_PATH
|
||||
|
||||
new_domain=$YNH_APP_NEW_DOMAIN
|
||||
new_path=$YNH_APP_NEW_PATH
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
# Needed for helper "ynh_add_nginx_config"
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
||||
#=================================================
|
||||
|
||||
change_domain=0
|
||||
if [ "$old_domain" != "$new_domain" ]
|
||||
then
|
||||
change_domain=1
|
||||
fi
|
||||
|
||||
change_path=0
|
||||
if [ "$old_path" != "$new_path" ]
|
||||
then
|
||||
change_path=1
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping searx..." --weight=10
|
||||
|
||||
ynh_systemd_action --service_name=uwsgi --action=stop
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating nginx web server configuration..." --weight=2
|
||||
|
||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||
|
||||
# Change the path in the nginx config file
|
||||
if [ $change_path -eq 1 ]
|
||||
then
|
||||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
||||
# Set global variables for nginx helper
|
||||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
|
||||
path_no_root=${path_url%/}
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config "path_no_root"
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
if [ $change_domain -eq 1 ]
|
||||
then
|
||||
# Delete file checksum for the old conf file location
|
||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||
# Store file checksum for the new config file location
|
||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# RECONFIGURING SEARX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reconfiguring Searx..."
|
||||
|
||||
ynh_replace_string --match_string="base_url : https://${old_domain}${old_path%/}/" --replace_string="base_url : https://${new_domain}${new_path%/}/" --target_file="$final_path/searx/settings.yml"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting Searx..." --weight=2
|
||||
|
||||
ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
|
@ -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
|
||||
|
||||
|
@ -29,69 +32,64 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
#=================================================
|
||||
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating installation parameters..."
|
||||
|
||||
final_path="/opt/yunohost/$app"
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
test ! -e "$final_path" || ynh_die --message="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
|
||||
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
ynh_script_progression --message="Storing installation settings..." --weight=2
|
||||
|
||||
ynh_app_setting_set $app domain $domain
|
||||
ynh_app_setting_set $app path $path_url
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing dependencies..." --weight=35
|
||||
|
||||
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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring nginx web server..."
|
||||
|
||||
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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring system user..." --weight=3
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=2
|
||||
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# INSTALL SEARX IN A VIRTUALENV
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Searx..."
|
||||
|
||||
virtualenv --system-site-packages "$final_path"
|
||||
set +u; source $final_path/bin/activate; set -u
|
||||
|
@ -101,21 +99,18 @@ pip install --requirement $final_path/requirements-ynh.txt
|
|||
#=================================================
|
||||
# CONFIGURE SEARX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Searx..." --weight=2
|
||||
|
||||
# Change instance name
|
||||
ynh_replace_string "instance_name : \"searx\"" "instance_name : \"YunoSearx\"" "$final_path/searx/settings.yml"
|
||||
ynh_replace_string --match_string="instance_name : \"searx\"" --replace_string="instance_name : \"YunoSearx\"" --target_file="$final_path/searx/settings.yml"
|
||||
|
||||
# Generate a secret key
|
||||
ynh_replace_string "secret_key : \"ultrasecretkey\"" "secret_key : \"$(ynh_string_random)\"" "$final_path/searx/settings.yml"
|
||||
ynh_replace_string --match_string="secret_key : \"ultrasecretkey\"" --replace_string="secret_key : \"$(ynh_string_random)\"" --target_file="$final_path/searx/settings.yml"
|
||||
|
||||
# Modify the base_url parameter, if it's installed in a subpath
|
||||
if [ "$path_url" != "/" ]
|
||||
then
|
||||
ynh_replace_string "base_url : False" "base_url : https://${domain}${path_url}/" "$final_path/searx/settings.yml"
|
||||
else
|
||||
ynh_replace_string "base_url : False" "base_url : False" "$final_path/searx/settings.yml"
|
||||
fi
|
||||
ynh_store_file_checksum "$final_path/searx/settings.yml"
|
||||
# Modify the base_url parameter
|
||||
ynh_replace_string --match_string="base_url : False" --replace_string="base_url : https://${domain}${path_url%/}/" --target_file="$final_path/searx/settings.yml"
|
||||
|
||||
ynh_store_file_checksum --file="$final_path/searx/settings.yml"
|
||||
|
||||
#=================================================
|
||||
# SET PERMISSIONS ON SEARX DIRECTORY
|
||||
|
@ -126,41 +121,50 @@ chown $app: --recursive "$final_path"
|
|||
#=================================================
|
||||
# CONFIGURE UWSGI FOR SEARX
|
||||
#=================================================
|
||||
ynh_script_progression --message="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
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" /etc/uwsgi/apps-available/$app.ini
|
||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=/etc/uwsgi/apps-available/$app.ini
|
||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/uwsgi/apps-available/$app.ini
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# CHECK SEARX STARTING
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting Searx..." --weight=4
|
||||
|
||||
# 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
|
||||
#=================================================
|
||||
# SETUP SSOWAT
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring SSOwat..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
|
|
|
@ -6,71 +6,85 @@
|
|||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# source _common.sh
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
#=================================================
|
||||
# STOP AND REMOVE SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping and removing the systemd service..."
|
||||
|
||||
# Remove the uwsgi configuration
|
||||
systemctl stop uwsgi
|
||||
if [ -h "/etc/uwsgi/apps-enabled/$app.ini" ]; then
|
||||
echo "Delete uwsgi config"
|
||||
ynh_secure_remove "/etc/uwsgi/apps-enabled/$app.ini"
|
||||
ynh_systemd_action --service_name=uwsgi --action=stop
|
||||
if [ -h "/etc/uwsgi/apps-enabled/$app.ini" ]
|
||||
then
|
||||
ynh_print_info --message="Delete uwsgi config for $app"
|
||||
ynh_secure_remove --file="/etc/uwsgi/apps-enabled/$app.ini"
|
||||
fi
|
||||
ynh_secure_remove "/etc/uwsgi/apps-available/$app.ini"
|
||||
ynh_secure_remove --file="/etc/uwsgi/apps-available/$app.ini"
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=3
|
||||
|
||||
ynh_remove_app_dependencies
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MAIN DIR OF THE APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing app main directory..."
|
||||
|
||||
ynh_secure_remove "/opt/yunohost/$app"
|
||||
ynh_secure_remove --file="$final_path"
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing nginx web server configuration..." --weight=2
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
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 --message="Remove uwsgi service"
|
||||
yunohost service remove uwsgi
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# REMOVE DEDICATED USER
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing the dedicated system user..."
|
||||
|
||||
# Delete a system user
|
||||
ynh_system_user_delete $app
|
||||
ynh_system_user_delete --username=$app
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
|
|
|
@ -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,18 +25,19 @@ 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)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
#=================================================
|
||||
ynh_script_progression --message="Validating restoration parameters..." --weight=2
|
||||
|
||||
ynh_webpath_available $domain $path_url \
|
||||
|| ynh_die "Path not available: ${domain}${path_url}"
|
||||
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||
test ! -d $final_path \
|
||||
|| ynh_die "There is already a directory: $final_path "
|
||||
|| ynh_die --message="There is already a directory: $final_path "
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORE STEPS
|
||||
|
@ -41,27 +45,30 @@ test ! -d $final_path \
|
|||
# RESTORE OF THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RESTORE OF THE MAIN DIR OF THE APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..."
|
||||
|
||||
mkdir -p /opt/yunohost
|
||||
ynh_restore_file "$final_path"
|
||||
mkdir -p "$(dirname "$final_path")"
|
||||
ynh_restore_file --origin_path="$final_path"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=35
|
||||
|
||||
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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Recreating the dedicated system user..." --weight=3
|
||||
|
||||
# Create the dedicated user (if not existing)
|
||||
ynh_system_user_create $app
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORE
|
||||
|
@ -75,7 +82,7 @@ chown $app: --recursive "$final_path"
|
|||
# RESTORE THE UWSGI CONFIG
|
||||
#=================================================
|
||||
|
||||
ynh_restore_file "/etc/uwsgi/apps-available/$app.ini"
|
||||
ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini"
|
||||
ln -s /etc/uwsgi/apps-available/$app.ini /etc/uwsgi/apps-enabled/$app.ini
|
||||
|
||||
#=================================================
|
||||
|
@ -83,12 +90,20 @@ ln -s /etc/uwsgi/apps-available/$app.ini /etc/uwsgi/apps-enabled/$app.ini
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# CHECK SEARX STARTING
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting Searx..." --weight=4
|
||||
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
|
|
117
scripts/upgrade
117
scripts/upgrade
|
@ -12,95 +12,109 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Loading installation settings..."
|
||||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
|
||||
#=================================================
|
||||
# FIX OLD THINGS
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||
|
||||
# Fix is_public as a boolean value
|
||||
if [ "${is_public,,}" = "yes" ]; then
|
||||
ynh_app_setting_set $app is_public 1
|
||||
if [ "$is_public" = "Yes" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=1
|
||||
is_public=1
|
||||
elif [ "${is_public,,}" = "no" ]; then
|
||||
ynh_app_setting_set $app is_public 0
|
||||
elif [ "$is_public" = "No" ]; then
|
||||
ynh_app_setting_set --app=$app --key=is_public --value=0
|
||||
is_public=0
|
||||
fi
|
||||
|
||||
# If final_path doesn't exist, create it
|
||||
if [ -z $final_path ]; then
|
||||
final_path="/opt/yunohost/$app"
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
if [ -z "$final_path" ]; then
|
||||
final_path=/var/www/$app
|
||||
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=2
|
||||
|
||||
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
|
||||
#=================================================
|
||||
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
path_url=$(ynh_normalize_url_path --path_url=$path_url)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading dependencies..." --weight=7
|
||||
|
||||
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
|
||||
#=================================================
|
||||
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different "$final_path/searx/settings.yml"
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
# Verify the checksum and backup the file if it's different
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/searx/settings.yml"
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=3
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$final_path"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading nginx web server 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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||
|
||||
# Create a system user
|
||||
ynh_system_user_create $app
|
||||
# Create a dedicated user (if not existing)
|
||||
ynh_system_user_create --username=$app
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPGRADE SEARX IN ITS VIRTUALENV
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading Searx..." --weight=7
|
||||
|
||||
rm -r $final_path/lib/python2.7/site-packages/setuptools $final_path/lib/python2.7/site-packages/setuptools-*
|
||||
virtualenv --system-site-packages "$final_path"
|
||||
|
@ -111,21 +125,18 @@ pip install --requirement $final_path/requirements-ynh.txt --upgrade
|
|||
#=================================================
|
||||
# CONFIGURE SEARX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reconfiguring Searx..." --weight=2
|
||||
|
||||
# Change instance name
|
||||
ynh_replace_string "instance_name : \"searx\"" "instance_name : \"YunoSearx\"" "$final_path/searx/settings.yml"
|
||||
ynh_replace_string --match_string="instance_name : \"searx\"" --replace_string="instance_name : \"YunoSearx\"" --target_file="$final_path/searx/settings.yml"
|
||||
|
||||
# Generate a secret key
|
||||
ynh_replace_string "secret_key : \"ultrasecretkey\"" "secret_key : \"$(ynh_string_random)\"" "$final_path/searx/settings.yml"
|
||||
ynh_replace_string --match_string="secret_key : \"ultrasecretkey\"" --replace_string="secret_key : \"$(ynh_string_random)\"" --target_file="$final_path/searx/settings.yml"
|
||||
|
||||
# Modify the base_url parameter, if it's installed in a subpath
|
||||
if [ "$path_url" != "/" ]
|
||||
then
|
||||
ynh_replace_string "base_url : False" "base_url : https://${domain}${path_url}/" "$final_path/searx/settings.yml"
|
||||
else
|
||||
ynh_replace_string "base_url : False" "base_url : False" "$final_path/searx/settings.yml"
|
||||
fi
|
||||
ynh_store_file_checksum "$final_path/searx/settings.yml"
|
||||
# Modify the base_url parameter
|
||||
ynh_replace_string --match_string="base_url : False" --replace_string="base_url : https://${domain}${path_url%/}/" --target_file="$final_path/searx/settings.yml"
|
||||
|
||||
ynh_store_file_checksum --file="$final_path/searx/settings.yml"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALISATION
|
||||
|
@ -138,30 +149,40 @@ chown $app: --recursive "$final_path"
|
|||
#=================================================
|
||||
# CONFIGURE UWSGI FOR SEARX
|
||||
#=================================================
|
||||
ynh_script_progression --message="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
|
||||
ynh_replace_string "__FINALPATH__" "$final_path" /etc/uwsgi/apps-available/$app.ini
|
||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=/etc/uwsgi/apps-available/$app.ini
|
||||
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file=/etc/uwsgi/apps-available/$app.ini
|
||||
|
||||
#=================================================
|
||||
# CHECK SEARX STARTING
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restarting Searx..." --weight=3
|
||||
|
||||
# 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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
||||
|
||||
# Make app public if necessary
|
||||
if [ $is_public -eq 1 ]
|
||||
then
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading nginx web server..."
|
||||
|
||||
systemctl reload nginx
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue