diff --git a/conf/systemd.service b/conf/systemd.service index a564fed..7823f2b 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -ExecStart=/usr/bin/mailisearch --http-addr 127.0.0.1:__PORT__ --env production --master-key __API_KEY__ +ExecStart=/usr/bin/mailisearch --http-addr 127.0.0.1:__PORT__ --env production --master-key __API_KEY__ --no-analytics __ANALYTICS__ [Install] WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index dd80d75..9604b9a 100644 --- a/manifest.json +++ b/manifest.json @@ -60,14 +60,13 @@ "example": "API-key245678635248795" }, { - "name": "data_path", - "type": "path", + "name": "allow_analyse", + "type": "boolean", "ask": { - "en": "Choose a path (existing or not) for Meilisearch data files (absolute path)", - "fr": "Choisissez un dossier existant ou non pour les fichiers de données de Meilisearch (chemin absolu)" + "en": "Allow Meilisearch to get data from usage of the application", + "fr": "Autoriser Meilisearch à analyser les données d'usage de l'application" }, - "example": "/var/www/mailisearch", - "default": "/var/www/mailisearch" + "default": false } ] } diff --git a/scripts/install b/scripts/install index 93b5a03..e87aed1 100644 --- a/scripts/install +++ b/scripts/install @@ -28,7 +28,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC master_key=$YNH_APP_ARG_MASTER_KEY -data_path=$YNH_APP_ARG_DATA_PATH +allow_analyse=$YNH_APP_ARG_ALLOW_ANALYSE app=$YNH_APP_INSTANCE_NAME @@ -41,15 +41,8 @@ ynh_script_progression --message="Validating installation parameters..." --time final_path=/var/www/$app -if [ $data_path != "" ];then - test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - mkdir -p $final_path -else - test ! -e "$data_path" || mkdir "$data_path" - final_path=$data_path -fi - - +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 @@ -64,6 +57,7 @@ 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=is_public --value=$is_public 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 @@ -89,9 +83,10 @@ if [ "$arch" != "amd64" ] && [ "$arch" != "armv8" ] then ynh_die --message="Your OS Architecture is not supported" fi - -curl https://github.com/meilisearch/MeiliSearch/releases/download/$latest/mailisearch-linux-$arch -o mailisearch -mv mailisearch /usr/bin/mailisearch +$release_file=meilisearch-linux-$arch +curl -OL https://github.com/meilisearch/MeiliSearch/releases/download/$latest/meilisearch-linux-$arch +chmod +x "$release_file" +mv "$release_file" /usr/bin/mailisearch #================================================= @@ -117,6 +112,11 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 +if [ $allow_analyse ]; then + ynh_replace_string "__ANALYTICS__" "false" "../conf/systemd.service" +else + ynh_replace_string "__ANALYTICS__" "true" "../conf/systemd.service" +fi ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" ynh_replace_string "__API_KEY__" "$master_key" "../conf/systemd.service" diff --git a/scripts/remove b/scripts/remove index f8f1ce0..361e108 100644 --- a/scripts/remove +++ b/scripts/remove @@ -48,6 +48,7 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing Meilisearch binary" --time --weight=1 ynh_secure_remove --file=/usr/bin/meilisearch +ynh_secure_remove --file=$final_path #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index fbba530..5ff5556 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ 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) master_key=$(ynh_app_setting_get --app=$app --key=master_key) -$port=$(ynh_app_setting_get --app=$app --key=final_path) +allow_analyse=$(ynh_app_setting_get --app=$app --key=allow_analyse) #================================================= # CHECK VERSION @@ -134,6 +134,11 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Configuring a systemd service..." --time --weight=1 +if [ $allow_analyse ]; then + ynh_replace_string "__ANALYTICS__" "false" "../conf/systemd.service" +else + ynh_replace_string "__ANALYTICS__" "true" "../conf/systemd.service" +fi ynh_replace_string "__PORT__" "$port" "conf/systemd.service" ynh_replace_string "__API_KEY__" "$master_key" "conf/systemd.service"