diff --git a/check_process b/check_process index 22e4be9..34b5af9 100644 --- a/check_process +++ b/check_process @@ -4,11 +4,11 @@ echo -n "Here your commands to execute in the container" echo ", before each installation of the app." ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) + domain="domain.tld" + path="/path" master_key="YUNOHOST-API-KEY-202020201456452135" - is_public=1 (PUBLIC|public=1|private=0) - port="3500" (PORT) + is_public=1 + port="3500" data_path="" ; Actions action_argument=arg1|arg2 diff --git a/conf/systemd.service b/conf/systemd.service index 04bd082..8af88a7 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -ExecStart=/usr/bin/meilisearch --http-addr 127.0.0.1:__PORT__ --env production --master-key __API_KEY__ --no-analytics __ANALYTICS__ +ExecStart=/usr/bin/meilisearch --http-addr 127.0.0.1:__PORT__ --env production --master-key __MASTER_KEY__ --no-analytics __ANALYTICS__ [Install] WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index ae99103..36426cc 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "url": "https://julien.gomes-dias.dev" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.0" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 117fec9..006c964 100644 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,14 @@ ynh_script_progression --message="Finding an available port..." --weight=2 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" + #================================================= # DOWNLOAD AND INSTALL MEILISEARCH #================================================= @@ -86,6 +94,10 @@ curl -OL https://github.com/meilisearch/MeiliSearch/releases/download/$latest/me 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" + #================================================= # NGINX CONFIGURATION #================================================= @@ -94,14 +106,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=8 # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # SETUP SYSTEMD #================================================= @@ -112,21 +116,10 @@ if [ $allow_analyse ]; then 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" # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -chown -R $app:$app $final_path - #================================================= # SETUP LOGROTATE #================================================= @@ -149,14 +142,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 FAIL2BAN -#================================================= -#ynh_script_progression --message="Configuring fail2ban..." --time --weight=1 -# -## Create a dedicated fail2ban config -#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" - #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/restore b/scripts/restore index 41ba9cd..42791a5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -50,6 +50,14 @@ 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 #================================================= @@ -57,6 +65,10 @@ ynh_script_progression --message="Restoring Meilisearch main directory..." --wei ynh_restore_file --origin_path="$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # RESTORE Meilisearch #================================================= @@ -75,14 +87,6 @@ curl -OL https://github.com/meilisearch/MeiliSearch/releases/download/$latest/me chmod +x "$release_file" mv "$release_file" /usr/bin/meilisearch -#================================================= -# 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 - #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 10b3e94..2683bd7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -89,6 +89,14 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # 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 #================================================= @@ -105,13 +113,9 @@ curl -OL https://github.com/meilisearch/MeiliSearch/releases/download/$latest/me chmod +x "$release_file" mv "$release_file" /usr/bin/meilisearch -#================================================= -# 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 +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -139,29 +143,10 @@ if [ $allow_analyse ]; then 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" # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# UPGRADE FAIL2BAN -#================================================= -#ynh_script_progression --message="Reconfiguring fail2ban..." --weight=1 - -# Create a dedicated fail2ban config -#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" - -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions on app files -chown -R $app:$app $final_path - #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================