1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/searx_ynh.git synced 2024-09-03 20:16:30 +02:00

Merge pull request #48 from YunoHost-Apps/package_upgrade

Normalization from example_ynh
This commit is contained in:
Kayou 2019-05-24 09:36:39 +02:00 committed by GitHub
commit af7b2ac439
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 131 additions and 245 deletions

View file

@ -30,9 +30,9 @@ Searx is a privacy-respecting, hackable metasearch engine.
#### 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/)
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/searx%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/searx/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/searx%20%28Apps%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%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/searx/)
## Limitations
@ -44,6 +44,7 @@ Searx is a privacy-respecting, hackable metasearch engine.
* 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/
---

View file

@ -18,17 +18,7 @@
port_already_use=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

View file

@ -15,7 +15,7 @@
"email": "opi@zeropi.net"
},
"requirements": {
"yunohost": ">= 3.2.0"
"yunohost": ">= 3.5.0"
},
"multi_instance": false,
"services": [

View file

@ -6,107 +6,3 @@
# 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
#=================================================
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
#
# 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
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
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}
# 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
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
}

View file

@ -19,40 +19,40 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get $app final_path)
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_print_info "Backing up the main app directory..."
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_print_info "Backing up nginx web server 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_print_info "Backing up uWSGI configuration..."
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_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

View file

@ -32,39 +32,36 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#=================================================
ynh_print_info "Validating installation parameters..."
ynh_script_progression --message="Validating installation parameters..."
final_path="/opt/yunohost/$app"
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)
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# 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_print_info "Storing installation settings..."
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_print_info "Installing dependencies..."
ynh_script_progression --message="Installing dependencies..." --weight=35
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_print_info "Configuring nginx web server..."
ynh_script_progression --message="Configuring nginx web server..."
path_no_root=${path_url%/}
# Create a dedicated nginx config
@ -73,26 +70,26 @@ ynh_add_nginx_config "path_no_root"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Configuring system 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_print_info "Setting up source files..."
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_print_info "Installing Searx..."
ynh_script_progression --message="Installing Searx..."1
virtualenv --system-site-packages "$final_path"
set +u; source $final_path/bin/activate; set -u
@ -102,22 +99,18 @@ pip install --requirement $final_path/requirements-ynh.txt
#=================================================
# CONFIGURE SEARX
#=================================================
ynh_print_info "Configuring 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
@ -128,11 +121,11 @@ chown $app: --recursive "$final_path"
#=================================================
# CONFIGURE UWSGI FOR SEARX
#=================================================
ynh_print_info "Configuring 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
#=================================================
@ -145,7 +138,7 @@ yunohost service add uwsgi --log "/var/log/uwsgi/app/$app.log"
#=================================================
# CHECK SEARX STARTING
#=================================================
ynh_print_info "Starting Searx..."
ynh_script_progression --message="Starting Searx..." --weight=4
# 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"
@ -155,23 +148,23 @@ ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned u
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Configuring 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_print_info "Reloading nginx web server..."
ynh_script_progression --message="Reloading nginx web server..."
systemctl reload nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -12,47 +12,47 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation settings..."
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
final_path=$(ynh_app_setting_get $app final_path)
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_print_info "Stopping and removing the systemd service"
ynh_script_progression --message="Stopping and removing the systemd service..."0
# Remove the uwsgi configuration
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"
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_print_info "Removing dependencies"
ynh_script_progression --message="Removing dependencies..."3
ynh_remove_app_dependencies
#=================================================
# REMOVE THE MAIN DIR OF THE APP
#=================================================
ynh_print_info "Removing app main directory"
ynh_script_progression --message="Removing app main directory..."
ynh_secure_remove "$final_path"
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE THE NGINX CONFIGURATION
#=================================================
ynh_print_info "Removing nginx web server configuration"
ynh_script_progression --message="Removing nginx web server configuration..." --weight=2
# Remove the dedicated nginx config
ynh_remove_nginx_config
@ -68,7 +68,7 @@ then
else
if yunohost service status | grep -q uwsgi
then
ynh_print_info "Remove uwsgi service"
ynh_print_info --message="Remove uwsgi service"
yunohost service remove uwsgi
fi
fi
@ -78,13 +78,13 @@ fi
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_print_info "Removing the dedicated system 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_print_info "Removal of $app completed"
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -25,19 +25,19 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path)
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)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_print_info "Validating restoration parameters..."
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
@ -45,30 +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_print_info "Restoring the app main directory..."
ynh_script_progression --message="Restoring the app main directory..."
mkdir -p "$(dirname "$final_path")"
ynh_restore_file "$final_path"
ynh_restore_file --origin_path="$final_path"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Reinstalling dependencies..."
ynh_script_progression --message="Reinstalling dependencies..." --weight=35
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RECREATE OF THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system 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
@ -82,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
#=================================================
@ -90,14 +90,14 @@ ln -s /etc/uwsgi/apps-available/$app.ini /etc/uwsgi/apps-enabled/$app.ini
#=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
ynh_script_progression --message="Reloading nginx web server..."
systemctl reload nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# CHECK SEARX STARTING
#=================================================
ynh_print_info "Starting Searx..."
ynh_script_progression --message="Starting Searx..." --weight=4
# 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"
@ -106,4 +106,4 @@ ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned u
# END OF SCRIPT
#=================================================
ynh_print_info "Restoration completed for $app"
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,39 +12,45 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info "Loading installation 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)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_print_info "Ensuring 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_print_info "Backing up the app before upgrading (may take a while)..."
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."2
# Backup the current version of the app
ynh_backup_before_upgrade
@ -60,32 +66,36 @@ ynh_abort_if_errors
#=================================================
# 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_print_info "Upgrading dependencies..."
ynh_script_progression --message="Upgrading dependencies..." --weight=7
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# 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"
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_print_info "Upgrading nginx web server configuration..."
ynh_script_progression --message="Upgrading nginx web server configuration..."
path_no_root=${path_url%/}
# Create a dedicated nginx config
@ -94,17 +104,17 @@ ynh_add_nginx_config "path_no_root"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_print_info "Making sure dedicated system user exists..."
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create $app
ynh_system_user_create --username=$app
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPGRADE SEARX IN ITS VIRTUALENV
#=================================================
ynh_print_info "Upgrading Searx..."
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"
@ -115,22 +125,18 @@ pip install --requirement $final_path/requirements-ynh.txt --upgrade
#=================================================
# CONFIGURE SEARX
#=================================================
ynh_print_info "Reconfiguring 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
@ -143,16 +149,16 @@ chown $app: --recursive "$final_path"
#=================================================
# CONFIGURE UWSGI FOR SEARX
#=================================================
ynh_print_info "Reconfiguring 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_print_info "Restarting Searx..."
ynh_script_progression --message="Restarting Searx..." --weight=3
# 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"
@ -160,23 +166,23 @@ ynh_systemd_action --service_name=uwsgi --action=restart --line_match="spawned u
#=================================================
# SETUP SSOWAT
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
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_print_info "Reloading nginx web server..."
ynh_script_progression --message="Reloading nginx web server..."
systemctl reload nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"
ynh_script_progression --message="Upgrade of $app completed" --last