diff --git a/conf/config.toml b/conf/config.toml new file mode 100644 index 0000000..61156b0 --- /dev/null +++ b/conf/config.toml @@ -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: +# Enables the Prometheus metrics on the `GET /metrics` endpoint. + + diff --git a/conf/nginx.conf b/conf/nginx.conf index 3ff63c5..7ccc7fc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,13 +1,11 @@ #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 __INSTALL_DIR__/; diff --git a/conf/systemd.service b/conf/systemd.service index 959fd97..def4b50 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ -ExecStart=__INSTALL_DIR__/meilisearch --http-addr 127.0.0.1:__PORT__ --env production --master-key __MASTER_KEY__ --no-analytics __ANALYTICS__ +ExecStart=__INSTALL_DIR__/meilisearch [Install] WantedBy=multi-user.target diff --git a/manifest.toml b/manifest.toml index 32f7bd5..4e8cffe 100644 --- a/manifest.toml +++ b/manifest.toml @@ -32,18 +32,6 @@ ram.runtime = "50M" type = "group" default = "visitors" - [install.master_key] - ask.en = "Choose a master API key for Meilisearch" - ask.fr = "Choisissez une clef d'API pour Meilisearch" - type = "string" - example = "API-key245678635248795" - - [install.allow_analyse] - ask.en = "Allow Meilisearch to get data from usage of the application" - ask.fr = "Autoriser Meilisearch à analyser les données d'usage de l'application" - type = "boolean" - default = false - [resources] [resources.sources] diff --git a/scripts/install b/scripts/install index 1dce645..353292a 100644 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,8 @@ source _common.sh source /usr/share/yunohost/helpers +key=$(ynh_string_random --length=16) + #================================================= # DOWNLOAD AND INSTALL MEILISEARCH #================================================= @@ -30,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 #================================================= diff --git a/scripts/remove b/scripts/remove index 801613a..7adaac7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -22,27 +22,12 @@ 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 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 diff --git a/scripts/restore b/scripts/restore index 5dcfd88..43802ca 100644 --- a/scripts/restore +++ b/scripts/restore @@ -39,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" #================================================= @@ -58,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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8ae4834..6d4e9a5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,14 +24,6 @@ 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 - #================================================= # UPGRADING MEILISEARCH #================================================= @@ -41,7 +33,7 @@ then 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" + ynh_setup_source --dest_dir="$install_dir" --keep="$install_dir/config.toml" fi chown -R $app:www-data "$install_dir" @@ -51,27 +43,15 @@ chown -R $app:www-data "$install_dir" #================================================= 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" #=================================================