1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/meilisearch_ynh.git synced 2024-09-03 19:45:59 +02:00

Merge pull request #20 from YunoHost-Apps/version-2

Version 2
This commit is contained in:
Éric Gaspar 2023-04-17 22:53:22 +02:00 committed by GitHub
commit 13d76cadb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 322 additions and 610 deletions

View file

@ -5,7 +5,8 @@ It shall NOT be edited by hand.
# MeiliSearch for YunoHost
[![Integration level](https://dash.yunohost.org/integration/meilisearch.svg)](https://dash.yunohost.org/appci/app/meilisearch) ![Working status](https://ci-apps.yunohost.org/ci/badges/meilisearch.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/meilisearch.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/meilisearch.svg)](https://dash.yunohost.org/appci/app/meilisearch) ![Working status](https://ci-apps.yunohost.org/ci/badges/meilisearch.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/meilisearch.maintain.svg)
[![Install MeiliSearch with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=meilisearch)
*[Lire ce readme en français.](./README_fr.md)*
@ -15,13 +16,16 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview
Meilisearch is an opensource next generation search API.
Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine
**Shipped version:** 0.30.5~ynh1
**Shipped version:** 1.1.0~ynh1
**Demo:** https://where2watch.meilisearch.com/
## Screenshots
![Screenshot of MeiliSearch](./doc/screenshots/movies-web-demo.gif)
![Screenshot of MeiliSearch](./doc/screenshots/meilisearch.png)
## Disclaimers / important information
@ -39,7 +43,8 @@ At the installation, be sure to set up an API key to secure your API.
## Documentation and resources
* Official app website: <https://www.meilisearch.com/>
* Upstream app code repository: <https://github.com/meilisearch/MeiliSearch>
* Official admin documentation: <https://www.meilisearch.com/docs>
* Upstream app code repository: <https://github.com/meilisearch/meilisearch/>
* YunoHost documentation for this app: <https://yunohost.org/app_meilisearch>
* Report a bug: <https://github.com/YunoHost-Apps/meilisearch_ynh/issues>

View file

@ -5,7 +5,8 @@ It shall NOT be edited by hand.
# MeiliSearch pour YunoHost
[![Niveau dintégration](https://dash.yunohost.org/integration/meilisearch.svg)](https://dash.yunohost.org/appci/app/meilisearch) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/meilisearch.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/meilisearch.maintain.svg)
[![Niveau dintégration](https://dash.yunohost.org/integration/meilisearch.svg)](https://dash.yunohost.org/appci/app/meilisearch) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/meilisearch.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/meilisearch.maintain.svg)
[![Installer MeiliSearch avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=meilisearch)
*[Read this readme in english.](./README.md)*
@ -15,13 +16,15 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
## Vue densemble
Meilisearch is an opensource next generation search API.
Un moteur de recherche open source, ultra-rapide et hyper pertinent qui s'intègre sans effort à votre flux de travail.
**Version incluse :** 0.30.5~ynh1
**Version incluse :** 1.1.0~ynh1
**Démo :** https://where2watch.meilisearch.com/
## Captures décran
![Capture décran de MeiliSearch](./doc/screenshots/movies-web-demo.gif)
![Capture décran de MeiliSearch](./doc/screenshots/meilisearch.png)
## Avertissements / informations importantes
@ -39,7 +42,8 @@ At the installation, be sure to set up an API key to secure your API.
## Documentations et ressources
* Site officiel de lapp : <https://www.meilisearch.com/>
* Dépôt de code officiel de lapp : <https://github.com/meilisearch/MeiliSearch>
* Documentation officielle de ladmin : <https://www.meilisearch.com/docs>
* Dépôt de code officiel de lapp : <https://github.com/meilisearch/meilisearch/>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_meilisearch>
* Signaler un bug : <https://github.com/YunoHost-Apps/meilisearch_ynh/issues>

View file

@ -1,33 +0,0 @@
;; Test name
# Comment ignored
; pre-install
echo -n "Here your commands to execute in the container"
echo ", before each installation of the app."
; Manifest
domain="domain.tld"
path="/path"
master_key="YUNOHOST-API-KEY-202020201456452135"
is_public=1
port="3500"
data_path=""
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
upgrade=1 from_commit=30d48110ea0c820c89ab8ade34e415f07b5b0b86
backup_restore=1
multi_instance=1
change_url=1
actions=0
config_panel=0
;;; Options
Email=
Notification=none
;;; Upgrade options
; commit=30d48110ea0c820c89ab8ade34e415f07b5b0b86
name=Merge pull request #13 from YunoHost-Apps/testing
manifest_arg=domain=DOMAIN&path=PATH&is_public=1&data_path=""&master_key="YUNOHOST-API-KEY-202020201456452135"&

View file

@ -1,6 +0,0 @@
SOURCE_URL=__SRC__
SOURCE_SUM=__SUM__
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

130
conf/config.toml Normal file
View file

@ -0,0 +1,130 @@
# This file shows the default configuration of Meilisearch.
# All variables are defined here: https://docs.meilisearch.com/learn/configuration/instance_options.html#environment-variables
db_path = "./data.ms"
# Designates the location where database files will be created and retrieved.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#database-path
env = "development"
# Configures the instance's environment. Value must be either `production` or `development`.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#environment
http_addr = "127.0.0.1:__PORT__"
# The address on which the HTTP server will listen.
master_key = "__KEY__"
# Sets the instance's master key, automatically protecting all routes except GET /health.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#master-key
no_analytics = true
# Deactivates Meilisearch's built-in telemetry when provided.
# Meilisearch automatically collects data from all instances that do not opt out using this flag.
# All gathered data is used solely for the purpose of improving Meilisearch, and can be deleted at any time.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#disable-analytics
http_payload_size_limit = "100 MB"
# Sets the maximum size of accepted payloads.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#payload-limit-size
log_level = "INFO"
# Defines how much detail should be present in Meilisearch's logs.
# Meilisearch currently supports six log levels, listed in order of increasing verbosity: `OFF`, `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`
# https://docs.meilisearch.com/learn/configuration/instance_options.html#log-level
# max_indexing_memory = "2 GiB"
# Sets the maximum amount of RAM Meilisearch can use when indexing.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#max-indexing-memory
# max_indexing_threads = 4
# Sets the maximum number of threads Meilisearch can use during indexing.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#max-indexing-threads
#############
### DUMPS ###
#############
dump_dir = "dumps/"
# Sets the directory where Meilisearch will create dump files.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#dump-directory
# import_dump = "./path/to/my/file.dump"
# Imports the dump file located at the specified path. Path must point to a .dump file.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#import-dump
ignore_missing_dump = false
# Prevents Meilisearch from throwing an error when `import_dump` does not point to a valid dump file.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ignore-missing-dump
ignore_dump_if_db_exists = false
# Prevents a Meilisearch instance with an existing database from throwing an error when using `import_dump`.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ignore-dump-if-db-exists
#################
### SNAPSHOTS ###
#################
schedule_snapshot = false
# Enables scheduled snapshots when true, disable when false (the default).
# If the value is given as an integer, then enables the scheduled snapshot with the passed value as the interval
# between each snapshot, in seconds.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#schedule-snapshot-creation
snapshot_dir = "snapshots/"
# Sets the directory where Meilisearch will store snapshots.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#snapshot-destination
# import_snapshot = "./path/to/my/snapshot"
# Launches Meilisearch after importing a previously-generated snapshot at the given filepath.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#import-snapshot
ignore_missing_snapshot = false
# Prevents a Meilisearch instance from throwing an error when `import_snapshot` does not point to a valid snapshot file.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ignore-missing-snapshot
ignore_snapshot_if_db_exists = false
# Prevents a Meilisearch instance with an existing database from throwing an error when using `import_snapshot`.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ignore-snapshot-if-db-exists
###########
### SSL ###
###########
# ssl_auth_path = "./path/to/root"
# Enables client authentication in the specified path.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ssl-authentication-path
# ssl_cert_path = "./path/to/certfile"
# Sets the server's SSL certificates.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ssl-certificates-path
# ssl_key_path = "./path/to/private-key"
# Sets the server's SSL key files.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ssl-key-path
# ssl_ocsp_path = "./path/to/ocsp-file"
# Sets the server's OCSP file.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ssl-ocsp-path
ssl_require_auth = false
# Makes SSL authentication mandatory.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ssl-require-auth
ssl_resumption = false
# Activates SSL session resumption.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ssl-resumption
ssl_tickets = false
# Activates SSL tickets.
# https://docs.meilisearch.com/learn/configuration/instance_options.html#ssl-tickets
#############################
### Experimental features ###
#############################
experimental_enable_metrics = false
# Experimental metrics feature. For more information, see: <https://github.com/meilisearch/meilisearch/discussions/3518>
# Enables the Prometheus metrics on the `GET /metrics` endpoint.

View file

@ -1,16 +1,14 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
rewrite __PATH__/(.*) /$1 break;
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:__PORT__;
# Path to source
alias __FINALPATH__/ ;
alias __INSTALL_DIR__/;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;

View file

@ -6,8 +6,42 @@ After=systemd-user-sessions.service
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__/
ExecStart=/usr/bin/meilisearch --http-addr 127.0.0.1:__PORT__ --env production --master-key __MASTER_KEY__ --no-analytics __ANALYTICS__
WorkingDirectory=__INSTALL_DIR__/
ExecStart=__INSTALL_DIR__/meilisearch --config-file-path __INSTALL_DIR__/config.toml
# Sandboxing options to harden security
# Depending on specificities of your service/app, you may need to tweak these
# .. but this should be a good baseline
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
RestrictNamespaces=yes
RestrictRealtime=yes
DevicePolicy=closed
ProtectClock=yes
ProtectHostname=yes
ProtectProc=invisible
ProtectSystem=full
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
LockPersonality=yes
SystemCallArchitectures=native
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged
# Denying access to capabilities that should not be relevant for webapps
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
[Install]
WantedBy=multi-user.target

View file

@ -1 +1 @@
Meilisearch is an opensource next generation search API.
Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Un moteur de recherche open source, ultra-rapide et hyper pertinent qui s'intègre sans effort à votre flux de travail.

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 MiB

View file

@ -1,60 +0,0 @@
{
"name": "MeiliSearch",
"id": "meilisearch",
"packaging_format": 1,
"description": {
"en": "Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine",
"fr": "Moteur de recherche rapide, ultra-performant et tolérant aux fautes de frappe"
},
"version": "0.30.5~ynh1",
"url": "https://www.meilisearch.com/",
"upstream": {
"license": "GPL-3.0",
"website": "https://www.meilisearch.com/",
"code": "https://github.com/meilisearch/MeiliSearch"
},
"license": "GPL-3.0",
"maintainer": {
"name": "Julien Gomes Dias",
"email": "abld@abld.info",
"url": "https://julien.gomes-dias.dev"
},
"requirements": {
"yunohost": ">= 11.0.9"
},
"multi_instance": true,
"services": [
"nginx"
],
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain"
},
{
"name": "is_public",
"type": "boolean",
"default": true
},
{
"name": "master_key",
"type": "string",
"ask": {
"en": "Choose a master API key for Meilisearch",
"fr": "Choisissez une clef d'API pour Meilisearch"
},
"example": "API-key245678635248795"
},
{
"name": "allow_analyse",
"type": "boolean",
"ask": {
"en": "Allow Meilisearch to get data from usage of the application",
"fr": "Autoriser Meilisearch à analyser les données d'usage de l'application"
},
"default": false
}
]
}
}

58
manifest.toml Normal file
View file

@ -0,0 +1,58 @@
packaging_format = 2
id = "meilisearch"
name = "MeiliSearch"
description.en = "Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine"
description.fr = "Moteur de recherche rapide, ultra-performant et tolérant aux fautes de frappe"
version = "1.1.0~ynh1"
maintainers = ["Julien Gomes Dias"]
[upstream]
license = "MIT"
website = "https://www.meilisearch.com/"
demo = "https://where2watch.meilisearch.com/"
admindoc = "https://www.meilisearch.com/docs"
code = "https://github.com/meilisearch/meilisearch/"
[integration]
yunohost = ">= 11.1.17"
architectures = ["amd64", "arm64"]
multi_instance = true
ldap = false
sso = false
disk = "50M"
ram.build = "70M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
full_domain = true
[install.init_main_permission]
type = "group"
default = "visitors"
[resources]
[resources.sources]
[resources.sources.main]
amd64.url = "https://github.com/meilisearch/meilisearch/releases/download/v1.1.0/meilisearch-linux-amd64"
amd64.sha256 = "41674391290246cbb4175289ded653e815aec32a6c91b4b090de1166a3adbb66"
arm64.url = "https://github.com/meilisearch/meilisearch/releases/download/v1.1.0/meilisearch-linux-aarch64"
arm64.sha256 = "b203d556078b805dc13f4252e434f119f96c651a1a3587d10caa163f5c125a3b"
rename = "meilisearch"
in_subdir = false
extract = false
[resources.ports]
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"

View file

@ -1,19 +1,17 @@
#!/bin/bash
latest="v0.30.5"
#=================================================
# COMMON VARIABLES
#=================================================
ynh_detect_arch() {
local architecture
if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep arm)" ]; then
architecture="armv8"
elif [ -n "$(uname -m | grep 64)" ]; then
architecture="amd64"
elif [ -n "$(uname -m | grep 86)" ]; then
architecture="i386"
elif [ -n "$(uname -m | grep arm)" ]; then
architecture="arm"
else
architecture="unknown"
fi
echo $architecture
}
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -10,26 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -39,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
@ -47,13 +27,6 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
#ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
#ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
@ -70,4 +43,4 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for Meilisearch. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -9,59 +9,6 @@
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..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Meilisearch before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# 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
#=================================================
@ -76,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#=================================================
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"
# Create a dedicated nginx config
ynh_add_nginx_config
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
ynh_change_url_nginx_config
#=================================================
# GENERIC FINALISATION
@ -109,13 +34,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,91 +9,20 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
master_key=$YNH_APP_ARG_MASTER_KEY
allow_analyse=$YNH_APP_ARG_ALLOW_ANALYSE
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
mkdir -p $final_path
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
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=master_key --value=$master_key
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=allow_analyse --value=$allow_analyse
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=2
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
key=$(ynh_string_random --length=16)
#=================================================
# DOWNLOAD AND INSTALL MEILISEARCH
#=================================================
ynh_script_progression --message="Installing Meilisearch..." --weight=5
ynh_script_progression --message="Setting up source files..." --weight=1
arch=$(ynh_detect_arch)
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
if [ "$arch" != "amd64" ] && [ "$arch" != "armv8" ]
then
ynh_die --message="Your OS Architecture is not supported"
fi
release_file=meilisearch-linux-$arch
curl -sOL https://github.com/meilisearch/MeiliSearch/releases/download/$latest/meilisearch-linux-$arch
chmod +x "$release_file"
mv "$release_file" /usr/bin/meilisearch
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod +x "$install_dir/meilisearch"
#=================================================
# NGINX CONFIGURATION
@ -103,34 +32,26 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=8
# Create a dedicated nginx config
ynh_add_nginx_config
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
if [ $allow_analyse ]; then
ynh_replace_string "__ANALYTICS__" "false" "../conf/systemd.service"
else
ynh_replace_string "__ANALYTICS__" "true" "../conf/systemd.service"
fi
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
yunohost service add $app --description="Opensource next generation search API" --log="/var/log/$app/$app.log"
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.toml" --destination="$install_dir/config.toml"
chmod 400 "$install_dir/config.toml"
chown $app:$app "$install_dir/config.toml"
#=================================================
# START SYSTEMD SERVICE
#=================================================
@ -139,26 +60,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -9,17 +9,6 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
@ -33,58 +22,17 @@ then
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
ynh_script_progression --message="Removing Meilisearch binary" --weight=1
ynh_secure_remove --file=/usr/bin/meilisearch
ynh_secure_remove --file=$final_path
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=3
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=2
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
#ynh_script_progression --message="Removing fail2ban configuration..." --time --weight=1
# Remove the dedicated fail2ban config
#ynh_remove_fail2ban_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of Meilisearch completed" --last
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -10,36 +10,6 @@
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
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=1
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
@ -48,50 +18,16 @@ test ! -d $final_path \
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring Meilisearch main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# RESTORE Meilisearch
#=================================================
ynh_script_progression --message="Download again binary for the API." --weight=5
arch=$(ynh_detect_arch)
if [ "$arch" != "amd64" ] && [ "$arch" != "armv8" ]
then
ynh_die --message="Your OS Architecture is not supported"
fi
release_file=meilisearch-linux-$arch
curl -sOL https://github.com/meilisearch/MeiliSearch/releases/download/$latest/meilisearch-linux-$arch
chmod +x "$release_file"
mv "$release_file" /usr/bin/meilisearch
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
# ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2
# ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
# ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
# ynh_systemd_action --action=restart --service_name=fail2ban
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC RESTORATION
@ -103,16 +39,8 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
yunohost service add $app --description="Opensource next generation search API" --log="/var/log/$app/$app.log"
#=================================================
@ -122,13 +50,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================

View file

@ -9,66 +9,12 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
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)
master_key=$(ynh_app_setting_get --app=$app --key=master_key)
allow_analyse=$(ynh_app_setting_get --app=$app --key=allow_analyse)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Meilisearch before upgrading (may take a while)..." --weight=5
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port.." --weight=2
# Find an available port
port=$(ynh_find_port --port=8095)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@ -78,78 +24,48 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# UPGRADING MEILISEARCH
#=================================================
ynh_script_progression --message="upgrading Meilisearch..." --weight=5
arch=$(ynh_detect_arch)
if [ "$arch" != "amd64" ] && [ "$arch" != "armv8" ]
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_die --message="Your OS Architecture is not supported"
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --keep="$install_dir/config.toml"
fi
release_file=meilisearch-linux-$arch
curl -sOL https://github.com/meilisearch/MeiliSearch/releases/download/$latest/meilisearch-linux-$arch
chmod +x "$release_file"
mv "$release_file" /usr/bin/meilisearch
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/CONFIG_FILE"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod +x "$install_dir/meilisearch"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
if [ $allow_analyse ]; then
ynh_replace_string "__ANALYTICS__" "false" "../conf/systemd.service"
else
ynh_replace_string "__ANALYTICS__" "true" "../conf/systemd.service"
fi
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
yunohost service add $app --description="Opensource next generation search API" --log="/var/log/$app/$app.log"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.toml" --destination="$install_dir/config.toml"
chmod 400 "$install_dir/config.toml"
chown $app:$app "$install_dir/config.toml"
#=================================================
# START SYSTEMD SERVICE
#=================================================
@ -157,13 +73,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================

13
tests.toml Normal file
View file

@ -0,0 +1,13 @@
test_format = 1.0
[default]
# -------------------------------
# Default args to use for install
# -------------------------------
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.30d48110ea0c820c89ab8ade34e415f07b5b0b86.name = "Upgrade from #13"