mirror of
https://github.com/YunoHost-Apps/searxng_ynh.git
synced 2024-09-03 20:26:00 +02:00
Merge pull request #324 from yunohost-bot/auto-helpers-2.1
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
commit
e358f716cf
9 changed files with 88 additions and 137 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
*~
|
*~
|
||||||
*.sw[op]
|
*.sw[op]
|
||||||
|
.DS_Store
|
||||||
|
|
|
@ -18,7 +18,8 @@ userdoc = "https://docs.searxng.org/user/"
|
||||||
code = "https://github.com/searxng/searxng"
|
code = "https://github.com/searxng/searxng"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.2.14"
|
yunohost = ">= 11.2.18"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = false
|
multi_instance = false
|
||||||
ldap = "not_relevant"
|
ldap = "not_relevant"
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PERSONAL HELPERS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Install/Upgrade SearXNG in virtual environement
|
# Install/Upgrade SearXNG in virtual environement
|
||||||
myynh_source_searxng () {
|
myynh_source_searxng () {
|
||||||
# Retrieve info from manifest
|
# Retrieve info from manifest
|
||||||
repo_fullpath=$(ynh_read_manifest --manifest_key="upstream.code")
|
repo_fullpath=$(ynh_read_manifest
|
||||||
commit_sha=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | xargs basename --suffix=".tar.gz")
|
commit_sha=$(ynh_read_manifest | xargs basename --suffix=".tar.gz")
|
||||||
|
|
||||||
# Download source
|
# Download source
|
||||||
sudo -H -u $app -i bash << EOF
|
sudo -H -u $app -i bash << EOF
|
||||||
|
@ -53,9 +49,9 @@ EOF
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
myynh_set_permissions () {
|
myynh_set_permissions () {
|
||||||
chown -R $app: "$install_dir"
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app: "$install_dir"
|
||||||
chmod 750 "$install_dir"
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
|
||||||
chmod -R o-rwx "$install_dir"
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -66,7 +62,7 @@ myynh_set_permissions () {
|
||||||
#
|
#
|
||||||
# usage: ynh_check_global_uwsgi_config
|
# usage: ynh_check_global_uwsgi_config
|
||||||
ynh_check_global_uwsgi_config () {
|
ynh_check_global_uwsgi_config () {
|
||||||
uwsgi --version || ynh_die --message="You need to add uwsgi (and appropriate plugin) as a dependency"
|
uwsgi --version || ynh_die "You need to add uwsgi (and appropriate plugin) as a dependency"
|
||||||
|
|
||||||
cat > "/etc/systemd/system/uwsgi-app@.service" <<EOF
|
cat > "/etc/systemd/system/uwsgi-app@.service" <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
|
@ -99,9 +95,10 @@ EOF
|
||||||
# To be able to customise the settings of the systemd unit you can override the rules with the file "conf/uwsgi-app@override.service".
|
# To be able to customise the settings of the systemd unit you can override the rules with the file "conf/uwsgi-app@override.service".
|
||||||
# This file will be automatically placed on the good place
|
# This file will be automatically placed on the good place
|
||||||
#
|
#
|
||||||
|
|
||||||
# Note that the service need to be started manually at the end of the installation.
|
# Note that the service need to be started manually at the end of the installation.
|
||||||
# Generally you can start the service with this command:
|
# Generally you can start the service with this command:
|
||||||
# ynh_systemd_action --service_name "uwsgi-app@$app.service" --line_match "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
# ynh_systemctl --service "uwsgi-app@$app.service" --wait_until "WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path "/var/log/uwsgi/$app/$app.log"
|
||||||
#
|
#
|
||||||
# usage: ynh_add_uwsgi_service
|
# usage: ynh_add_uwsgi_service
|
||||||
#
|
#
|
||||||
|
@ -112,10 +109,10 @@ ynh_add_uwsgi_service () {
|
||||||
local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
local finaluwsgiini="/etc/uwsgi/apps-available/$app.ini"
|
||||||
|
|
||||||
# www-data group is needed since it is this nginx who will start the service
|
# www-data group is needed since it is this nginx who will start the service
|
||||||
usermod --append --groups www-data "$app" || ynh_die --message="It wasn't possible to add user $app to group www-data"
|
usermod --append --groups www-data "$app" || ynh_die "It wasn't possible to add user $app to group www-data"
|
||||||
|
|
||||||
ynh_add_config --template="uwsgi.ini" --destination="$finaluwsgiini"
|
ynh_config_add --template="uwsgi.ini" --destination="$finaluwsgiini"
|
||||||
ynh_store_file_checksum --file="$finaluwsgiini"
|
ynh_store_file_checksum "$finaluwsgiini"
|
||||||
chown $app:root "$finaluwsgiini"
|
chown $app:root "$finaluwsgiini"
|
||||||
|
|
||||||
# make sure the folder for logs exists and set authorizations
|
# make sure the folder for logs exists and set authorizations
|
||||||
|
@ -127,11 +124,11 @@ ynh_add_uwsgi_service () {
|
||||||
mkdir -p "/etc/systemd/system/uwsgi-app@$app.service.d"
|
mkdir -p "/etc/systemd/system/uwsgi-app@$app.service.d"
|
||||||
if [ -e "../conf/uwsgi-app@override.service" ]
|
if [ -e "../conf/uwsgi-app@override.service" ]
|
||||||
then
|
then
|
||||||
ynh_add_config --template="uwsgi-app@override.service" --destination="/etc/systemd/system/uwsgi-app@$app.service.d/override.conf"
|
ynh_config_add --template="uwsgi-app@override.service" --destination="/etc/systemd/system/uwsgi-app@$app.service.d/override.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="enable"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="enable"
|
||||||
|
|
||||||
# Add as a service
|
# Add as a service
|
||||||
yunohost service add "uwsgi-app@$app" --description="uWSGI service for searxng" --log "/var/log/uwsgi/$app/$app.log"
|
yunohost service add "uwsgi-app@$app" --description="uWSGI service for searxng" --log "/var/log/uwsgi/$app/$app.log"
|
||||||
|
@ -145,12 +142,12 @@ ynh_remove_uwsgi_service () {
|
||||||
if [ -e "$finaluwsgiini" ]
|
if [ -e "$finaluwsgiini" ]
|
||||||
then
|
then
|
||||||
yunohost service remove "uwsgi-app@$app"
|
yunohost service remove "uwsgi-app@$app"
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="stop"
|
||||||
ynh_exec_fully_quiet ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="disable"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="disable"
|
||||||
|
|
||||||
ynh_secure_remove --file="$finaluwsgiini"
|
ynh_safe_rm "$finaluwsgiini"
|
||||||
ynh_secure_remove --file="/var/log/uwsgi/$app"
|
ynh_safe_rm "/var/log/uwsgi/$app"
|
||||||
ynh_secure_remove --file="/etc/systemd/system/uwsgi-app@$app.service.d"
|
ynh_safe_rm "/etc/systemd/system/uwsgi-app@$app.service.d"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,8 +156,8 @@ ynh_remove_uwsgi_service () {
|
||||||
#
|
#
|
||||||
# usage: ynh_backup_uwsgi_service
|
# usage: ynh_backup_uwsgi_service
|
||||||
ynh_backup_uwsgi_service () {
|
ynh_backup_uwsgi_service () {
|
||||||
ynh_backup --src_path="/etc/uwsgi/apps-available/$app.ini"
|
ynh_backup "/etc/uwsgi/apps-available/$app.ini"
|
||||||
ynh_backup --src_path="/etc/systemd/system/uwsgi-app@$app.service.d" --not_mandatory
|
ynh_backup "/etc/systemd/system/uwsgi-app@$app.service.d" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restore the dedicated uwsgi config
|
# Restore the dedicated uwsgi config
|
||||||
|
@ -169,13 +166,13 @@ ynh_backup_uwsgi_service () {
|
||||||
# usage: ynh_restore_uwsgi_service
|
# usage: ynh_restore_uwsgi_service
|
||||||
ynh_restore_uwsgi_service () {
|
ynh_restore_uwsgi_service () {
|
||||||
ynh_check_global_uwsgi_config
|
ynh_check_global_uwsgi_config
|
||||||
ynh_restore_file --origin_path="/etc/uwsgi/apps-available/$app.ini"
|
ynh_restore "/etc/uwsgi/apps-available/$app.ini"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/uwsgi-app@$app.service.d" --not_mandatory
|
ynh_restore "/etc/systemd/system/uwsgi-app@$app.service.d" || true
|
||||||
|
|
||||||
mkdir -p "/var/log/uwsgi/$app"
|
mkdir -p "/var/log/uwsgi/$app"
|
||||||
chown $app:root "/var/log/uwsgi/$app"
|
chown $app:root "/var/log/uwsgi/$app"
|
||||||
chmod -R u=rwX,g=rX,o= "/var/log/uwsgi/$app"
|
chmod -R u=rwX,g=rX,o= "/var/log/uwsgi/$app"
|
||||||
|
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="enable"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="enable"
|
||||||
yunohost service add "uwsgi-app@$app" --description="uWSGI service for searxng" --log "/var/log/uwsgi/$app/$app.log"
|
yunohost service add "uwsgi-app@$app" --description="uWSGI service for searxng" --log "/var/log/uwsgi/$app/$app.log"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
ynh_print_info "Declaring files to be backed up..."
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
|
||||||
#=================================================
|
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$install_dir"
|
ynh_backup "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC BACKUP
|
# SPECIFIC BACKUP
|
||||||
|
@ -38,4 +29,4 @@ ynh_backup_uwsgi_service
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
|
@ -1,51 +1,41 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC STARTING
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
ynh_script_progression "Stopping $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log_path="/var/log/uwsgi/$app/$app.log"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="stop" --log_path="/var/log/uwsgi/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
ynh_script_progression "Updating NGINX web server configuration..."
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_config_change_url_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECONFIGURING SEARXNG
|
# RECONFIGURING SEARXNG
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reconfiguring SearXNG..." --weight=2
|
ynh_script_progression "Reconfiguring SearXNG..."
|
||||||
|
|
||||||
ynh_replace_string --match_string="base_url: https://$old_domain$old_path" --replace_string="base_url: https://$new_domain$new_path" --target_file="$install_dir/settings.yml"
|
ynh_replace --match="base_url: https://$old_domain$old_path" --replace="base_url: https://$new_domain$new_path" --file="$install_dir/settings.yml"
|
||||||
ynh_replace_string --match_string="instance_name: SearXNG - $old_domain" --replace_string="instance_name: SearXNG - $new_domain" --target_file="$install_dir/settings.yml"
|
ynh_replace --match="instance_name: SearXNG - $old_domain" --replace="instance_name: SearXNG - $new_domain" --file="$install_dir/settings.yml"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALISATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --log_path="/var/log/uwsgi/$app/$app.log"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="start" --log_path="/var/log/uwsgi/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
ynh_script_progression "Change of URL completed for $app"
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -14,18 +8,18 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
ynh_script_progression "Setting up source files..."
|
||||||
myynh_source_searxng
|
myynh_source_searxng
|
||||||
|
|
||||||
ynh_script_progression --message="Installing SearXNG..." --weight=2
|
ynh_script_progression "Installing SearXNG..."
|
||||||
myynh_install_searxng
|
myynh_install_searxng
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
ynh_script_progression "Adding system configurations related to $app..."
|
||||||
|
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
ynh_add_uwsgi_service
|
ynh_add_uwsgi_service
|
||||||
|
|
||||||
|
@ -34,24 +28,22 @@ ynh_add_uwsgi_service
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
ynh_script_progression "Adding $app's configuration..."
|
||||||
|
|
||||||
secret_key=$(ynh_string_random)
|
secret_key=$(ynh_string_random)
|
||||||
ynh_add_config --template="../conf/settings.yml" --destination="$install_dir/settings.yml"
|
ynh_config_add --template="settings.yml" --destination="$install_dir/settings.yml"
|
||||||
|
|
||||||
myynh_set_permissions
|
myynh_set_permissions
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --line_match="WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path="/var/log/uwsgi/$app/$app.log"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="start" --wait_until="WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path="/var/log/uwsgi/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
@ -13,10 +7,11 @@ source /usr/share/yunohost/helpers
|
||||||
# REMOVE SYSTEM CONFIGURATIONS
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SYSTEMD SERVICE
|
# REMOVE SYSTEMD SERVICE
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
|
||||||
|
|
||||||
ynh_remove_nginx_config
|
#=================================================
|
||||||
|
ynh_script_progression "Removing system configurations related to $app..."
|
||||||
|
|
||||||
|
ynh_config_remove_nginx
|
||||||
|
|
||||||
ynh_remove_uwsgi_service
|
ynh_remove_uwsgi_service
|
||||||
|
|
||||||
|
@ -24,4 +19,4 @@ ynh_remove_uwsgi_service
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
ynh_script_progression "Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$install_dir"
|
ynh_restore "$install_dir"
|
||||||
|
|
||||||
myynh_set_permissions
|
myynh_set_permissions
|
||||||
|
|
||||||
|
@ -22,23 +16,21 @@ myynh_set_permissions
|
||||||
# RESTORE SYSTEM CONFIGURATIONS
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
ynh_restore_uwsgi_service
|
ynh_restore_uwsgi_service
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --line_match="WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path="/var/log/uwsgi/$app/$app.log"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="start" --wait_until="WSGI app 0 \(mountpoint='[/[:alnum:]_-]*'\) ready in [[:digit:]]* seconds on interpreter" --log_path="/var/log/uwsgi/$app/$app.log"
|
||||||
|
|
||||||
ynh_systemd_action --service_name="nginx" --action="reload"
|
ynh_systemctl --service="nginx" --action="reload"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -1,42 +1,33 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC START
|
|
||||||
#=================================================
|
|
||||||
# IMPORT GENERIC HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD UPGRADE STEPS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
ynh_script_progression "Ensuring downward compatibility..."
|
||||||
|
|
||||||
if [ -e "$install_dir/searx" ]; then
|
if [ -e "$install_dir/searx" ]; then
|
||||||
tempdir="$(mktemp -d)"
|
tempdir="$(mktemp -d)"
|
||||||
mv "$install_dir/searx/settings.yml" "$tempdir/settings.yml"
|
mv "$install_dir/searx/settings.yml" "$tempdir/settings.yml"
|
||||||
sed -i '1s/^/use_default_settings: true\n\n/' "$tempdir/settings.yml"
|
sed -i '1s/^/use_default_settings: true\n\n/' "$tempdir/settings.yml"
|
||||||
ynh_secure_remove --file="$install_dir"
|
ynh_safe_rm "$install_dir"
|
||||||
mkdir "$install_dir"
|
mkdir "$install_dir"
|
||||||
mv "$tempdir/settings.yml" "$install_dir/settings.yml"
|
mv "$tempdir/settings.yml" "$install_dir/settings.yml"
|
||||||
ynh_secure_remove --file="$tempdir"
|
ynh_safe_rm "$tempdir"
|
||||||
ynh_store_file_checksum --file="$install_dir/settings.yml"
|
ynh_store_file_checksum "$install_dir/settings.yml"
|
||||||
ynh_delete_file_checksum --file="/opt/yunohost/$app/searx/settings.yml"
|
ynh_delete_file_checksum "/opt/yunohost/$app/searx/settings.yml"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_delete_file_checksum --file="etc/nginx_conf.d/$domain/$app.conf"
|
ynh_delete_file_checksum "etc/nginx_conf.d/$domain/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
ynh_script_progression "Stopping $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log_path="/var/log/uwsgi/$app/$app.log"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="stop" --log_path="/var/log/uwsgi/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
||||||
|
@ -44,12 +35,13 @@ ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="stop" --log
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
|
||||||
|
if ynh_app_upstream_version_changed
|
||||||
then
|
then
|
||||||
ynh_secure_remove --file="$install_dir/.profile"
|
ynh_safe_rm "$install_dir/.profile"
|
||||||
ynh_secure_remove --file="$install_dir/.cache"
|
ynh_safe_rm "$install_dir/.cache"
|
||||||
ynh_secure_remove --file="$install_dir/searxng-src"
|
ynh_safe_rm "$install_dir/searxng-src"
|
||||||
ynh_secure_remove --file="$install_dir/searxng-pyenv"
|
ynh_safe_rm "$install_dir/searxng-pyenv"
|
||||||
myynh_source_searxng
|
myynh_source_searxng
|
||||||
myynh_install_searxng
|
myynh_install_searxng
|
||||||
fi
|
fi
|
||||||
|
@ -59,28 +51,28 @@ myynh_set_permissions
|
||||||
#=================================================
|
#=================================================
|
||||||
# REAPPLY SYSTEM CONFIGURATIONS
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||||
|
|
||||||
ynh_add_nginx_config
|
ynh_config_add_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
ynh_script_progression "Updating configuration..."
|
||||||
|
|
||||||
ynh_add_uwsgi_service
|
ynh_add_uwsgi_service
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="uwsgi-app@$app.service" --action="start" --line_match="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log"
|
ynh_systemctl --service="uwsgi-app@$app.service" --action="start" --wait_until="spawned uWSGI master process" --log_path="/var/log/uwsgi/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression "Upgrade of $app completed"
|
||||||
|
|
Loading…
Reference in a new issue