diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 9f8f74b..30fb19e 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -43,11 +43,12 @@ fi if [ $is_public -eq 0 ] then - # Si l'app est privée, seul le visionnage des images reste public + # If the app is private, viewing images stays publicly accessible. if [ "$path_url" == "/" ]; then - path_url="" # Si path correspond à la racine, supprime le / pour éviter une erreur de la regex. + # If the path is /, clear it to prevent any error with the regex. + path_url="" fi - # Modifie le domaine pour qu'il passe dans une regex + # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" else diff --git a/scripts/backup b/scripts/backup index b1dd753..beee673 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,14 +28,14 @@ domain=$(ynh_app_setting_get $app domain) #================================================= # STANDARD BACKUP STEPS #================================================= -# BACKUP OF THE MAIN DIR OF THE APP +# BACKUP THE APP MAIN DIR #================================================= CHECK_SIZE "$final_path" ynh_backup "$final_path" #================================================= -# BACKUP OF THE NGINX CONFIGURATION +# BACKUP NGINX CONFIGURATION #================================================= ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" @@ -55,7 +55,7 @@ ynh_backup "/etc/logrotate.d/$app" ynh_backup "/etc/systemd/system/$app.service" #================================================= -# BACKUP OF THE CRON FILE +# BACKUP A CRON FILE #================================================= ynh_backup "/etc/cron.d/$app" diff --git a/scripts/change_url b/scripts/change_url index a1eb031..f284e84 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -67,7 +67,7 @@ fi #================================================= ynh_clean_setup () { -# Nettoyage des résidus d'installation non pris en charge par le script remove. +# Clean installation remaining that are not handle by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -114,11 +114,13 @@ fi #================================================= if [ $is_public -eq 0 ] -then # Si l'app est privée, seul le visionnage des images reste public +then + # If the app is private, viewing images stays publicly accessible. if [ "$new_path" == "/" ]; then - new_path="" # Si path correspond à la racine, supprime le / pour éviter une erreur de la regex. + # If the path is /, clear it to prevent any error with the regex. + new_path="" fi - # Modifie le domaine pour qu'il passe dans une regex + # Modify the domain to be used in a regex domain_regex=$(echo "$new_domain" | sed 's@-@.@g') ynh_app_setting_set $app protected_regex "$domain_regex$new_path/stats$","$domain_regex$new_path/manifest.webapp$","$domain_regex$new_path/$","$domain_regex$new_path/d/.*$","$domain_regex$new_path/m/.*$" fi @@ -143,7 +145,7 @@ ynh_systemd_action --action=reload --service_name=nginx # START AND CHECK LUTIM BOOTING #================================================= -# Wait for lutim fully started +# Wait for lutim to be fully started ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" #================================================= diff --git a/scripts/install b/scripts/install index a3fefac..2668972 100644 --- a/scripts/install +++ b/scripts/install @@ -16,7 +16,7 @@ source _variables #================================================= ynh_clean_setup () { -# Nettoyage des résidus d'installation non pris en charge par le script remove. +# Clean installation remaining that are not handle by the remove script. ynh_clean_check_starting } ynh_abort_if_errors @@ -56,20 +56,15 @@ ynh_app_setting_set $app overwrite_settings "1" ynh_app_setting_set $app overwrite_nginx "1" ynh_app_setting_set $app overwrite_systemd "1" -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= - -ynh_maintenance_mode_ON - #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -port=$(ynh_find_port 8095) # Cherche un port libre. -# Ouvre le port dans le firewall +# Find a free port +port=$(ynh_find_port 8095) +# Open this port ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port ynh_app_setting_set $app port $port @@ -78,7 +73,8 @@ ynh_app_setting_set $app port $port #================================================= ynh_app_setting_set $app final_path $final_path -ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path +# Download, check integrity and uncompress the source from app.src +ynh_setup_source "$final_path" #================================================= # INSTALL DEPENDENCIES @@ -90,13 +86,15 @@ ynh_install_app_dependencies $app_depencencies # NGINX CONFIGURATION #================================================= +# Create a dedicated nginx config ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_system_user_create $app # Créer un utilisateur système dédié à l'app +# Create a dedicated system user +ynh_system_user_create $app #================================================= # SPECIFIC SETUP @@ -104,7 +102,7 @@ ynh_system_user_create $app # Créer un utilisateur système dédié à l'app # SETUP LUTIM #================================================= -## Copie et configuration du fichier de conf. +# Configure Lutim cp ../conf/lutim.conf.template "$final_path/lutim.conf" ynh_replace_string "__DOMAIN__" "$domain" "$final_path/lutim.conf" ynh_replace_string "__PATH__" "$path_url" "$final_path/lutim.conf" @@ -113,12 +111,14 @@ ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$final_path/lutim.conf" secret=$(ynh_string_random) ynh_replace_string "__SECRET__" "$secret" "$final_path/lutim.conf" ynh_app_setting_set $app secret "$secret" -ynh_store_file_checksum "$final_path/lutim.conf" # Enregistre la somme de contrôle du fichier de config +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$final_path/lutim.conf" #================================================= # SETUP SYSTEMD #================================================= +# Create a dedicated systemd config ynh_add_systemd_config #================================================= @@ -137,11 +137,11 @@ mkdir -p /var/log/$app/ (cd $final_path carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log") -# Configure le path du dossier perl en fonction de l'architecture système +# Use a perl path adapted to the system architecture arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu) if [ "$?" -ne 0 ] then - ynh_die "Impossible de trouver le dossier relatif à l'architecture système." + ynh_die "Unable to find the perl directory for your architecture." fi ynh_replace_string "__ARCHDIR__" "$arch_dir" "$final_path/script/lutim" @@ -149,7 +149,7 @@ ynh_replace_string "__ARCHDIR__" "$arch_dir" "$final_path/script/lutim" # SETUP LOG FILE #================================================= -# Making log symbolic link to /var/log +# Making log a symbolic link to /var/log touch /var/log/$app/production.log chown $app -R /var/log/$app ln -s /var/log/$app/production.log "$final_path/log/production.log" @@ -158,6 +158,7 @@ ln -s /var/log/$app/production.log "$final_path/log/production.log" # SECURING FILES AND DIRECTORIES #================================================= +# Set permissions to app files chown -R $app: $final_path #================================================= @@ -166,10 +167,11 @@ chown -R $app: $final_path # SETUP LOGROTATE #================================================= +# Use logrotate to manage application logfile(s) ynh_use_logrotate #================================================= -# ENABLE SERVICE IN ADMIN PANEL +# ADVERTISE SERVICE IN ADMIN PANEL #================================================= yunohost service add lutim -l $final_path/log/production.log @@ -180,11 +182,13 @@ yunohost service add lutim -l $final_path/log/production.log ynh_app_setting_set $app skipped_uris "/" if [ $is_public -eq 0 ] -then # Si l'app est privée, seul le visionnage des images reste public +then + # If the app is private, viewing images stays publicly accessible. if [ "$path_url" == "/" ]; then - path_url="" # Si path correspond à la racine, supprime le / pour éviter une erreur de la regex. + # If the path is /, clear it to prevent any error with the regex. + path_url="" fi - # Modifie le domaine pour qu'il passe dans une regex + # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" fi @@ -199,24 +203,18 @@ ynh_systemd_action --action=reload --service_name=nginx # CHECK LUTIM BOOTING #================================================= -# Wait for lutim fully started +# Wait for lutim to be fully started ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" # Set right permissions on new files created at first start chown -R $app: $final_path -#================================================= -# DEACTIVE MAINTENANCE MODE -#================================================= - -ynh_maintenance_mode_OFF - #================================================= # SEND A README FOR THE ADMIN #================================================= message="You can find a config file at $final_path/lutim.conf -If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/lutim_ynh" +If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/lutim_ynh" ynh_send_readme_to_admin --app_message="$message" --recipients="root" diff --git a/scripts/remove b/scripts/remove index 6fe12f3..36e6234 100644 --- a/scripts/remove +++ b/scripts/remove @@ -23,13 +23,15 @@ domain=$(ynh_app_setting_get $app domain) # STOP AND REMOVE SERVICE #================================================= +# Remove the dedicated systemd config ynh_remove_systemd_config #================================================= -# DISABLE SERVICE IN ADMIN PANEL +# REMOVE SERVICE FROM ADMIN PANEL #================================================= -if yunohost service status | grep -q $app # Test l'existence du service dans Yunohost +# Check if the service is declared in YunoHost +if yunohost service status | grep -q $app then ynh_print_info "Remove $app service" >&2 yunohost service remove $app @@ -39,30 +41,34 @@ fi # REMOVE DEPENDENCIES #================================================= +# Remove metapackage and its dependencies ynh_remove_app_dependencies #================================================= -# REMOVE THE MAIN DIR OF THE APP +# REMOVE APP MAIN DIR #================================================= -ynh_secure_remove "/var/www/$app" # Suppression du dossier de l'application +# Remove the app directory securely +ynh_secure_remove "/var/www/$app" #================================================= -# REMOVE THE NGINX CONFIGURATION +# REMOVE NGINX CONFIGURATION #================================================= -ynh_remove_nginx_config # Suppression de la configuration nginx +# Remove the dedicated nginx config +ynh_remove_nginx_config #================================================= -# REMOVE THE LOGROTATE CONFIG +# REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_remove_logrotate # Suppression de la configuration de logrotate +# Remove the app-specific logrotate config +ynh_remove_logrotate #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE CRON JOBS +# REMOVE CRON JOB #================================================= ynh_secure_remove "/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index d40cf10..19562d8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -16,7 +16,7 @@ source ../settings/scripts/_variables #================================================= ynh_clean_setup () { -# Nettoyage des résidus d'installation non pris en charge par le script remove. +# Clean installation remaining that are not handle by the remove script. ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -50,28 +50,29 @@ ynh_maintenance_mode_ON #================================================= # STANDARD RESTORE STEPS #================================================= -# RESTORE OF THE NGINX CONFIGURATION +# RESTORE THE NGINX CONFIGURATION #================================================= ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# RESTORE OF THE MAIN DIR OF THE APP +# RESTORE THE APP MAIN DIR #================================================= ynh_restore_file "$final_path" #================================================= -# RECREATE OF THE DEDICATED USER +# RECREATE THE DEDICATED USER #================================================= -ynh_system_user_create $app # Recreate the dedicated user, if not exist +# Create the dedicated user (if not existing) +ynh_system_user_create $app #================================================= # RESTORE USER RIGHTS #================================================= -# Les fichiers appartiennent à root +# Restore permissions on app files chown -R $app: $final_path #================================================= @@ -83,7 +84,7 @@ chown -R $app: $final_path ynh_install_app_dependencies $app_depencencies #================================================= -# ENABLE SERVICE IN ADMIN PANEL +# ADVERTISE SERVICE IN ADMIN PANEL #================================================= yunohost service add $app --log "/var/log/$app/APP.log" @@ -93,11 +94,10 @@ yunohost service add $app --log "/var/log/$app/APP.log" #================================================= ynh_restore_file "/etc/systemd/system/$app.service" -## Démarrage auto du service systemctl enable $app.service #================================================= -# RESTORE OF THE CRON FILE +# RESTORE THE CRON FILE #================================================= ynh_restore_file "/etc/cron.d/$app" @@ -106,13 +106,13 @@ ynh_restore_file "/etc/cron.d/$app" # SETUP LOG FILE #================================================= -# Making log symbolic link to /var/log +# Making log a symbolic link to /var/log mkdir -p /var/log/$app/ touch /var/log/$app/production.log chown $app -R /var/log/$app #================================================= -# RESTORE THE LOGROTATE CONFIGURATION +# RESTORE LOGROTATE CONFIGURATION #================================================= ynh_restore_file "/etc/logrotate.d/$app" @@ -129,7 +129,7 @@ ynh_systemd_action --action=reload --service_name=nginx # START AND CHECK LUTIM BOOTING #================================================= -# Wait for lutim fully started +# Wait for lutim to be fully started ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" #================================================= @@ -144,6 +144,6 @@ ynh_maintenance_mode_OFF message="You can find a config file at $final_path/lutim.conf -If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/lutim_ynh" +If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/lutim_ynh" ynh_send_readme_to_admin --app_message="$message" --recipients="root" diff --git a/scripts/upgrade b/scripts/upgrade index c8d3f3b..2241e7a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,22 +42,25 @@ upgrade_type=$(ynh_check_app_version_changed) # ENSURE DOWNWARD COMPATIBILITY #================================================= +# Fix is_public as a boolean if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen + ynh_app_setting_set $app is_public 1 is_public=1 elif [ "$is_public" = "No" ]; then ynh_app_setting_set $app is_public 0 is_public=0 fi +# if final_path isn't set, which can happens with old scripts, set final_path. if [ "${#final_path}" -eq 0 ] -then # Si final_path n'est pas renseigné dans la config yunohost, cas d'ancien script, code final_path en dur +then final_path=/var/www/$app ynh_app_setting_set $app final_path $final_path fi +# Fix always_encrypt as a boolean if [ "$always_encrypt" = "Yes" ]; then - ynh_app_setting_set $app always_encrypt 1 # Fixe always_encrypt en booléen + ynh_app_setting_set $app always_encrypt 1 always_encrypt=1 elif [ "$always_encrypt" = "No" ]; then ynh_app_setting_set $app always_encrypt 0 @@ -95,7 +98,7 @@ fi # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { -# Nettoyage des résidus d'installation non pris en charge par le script remove. +# Clean installation remaining that are not handle by the remove script. ynh_clean_check_starting # restore it if the upgrade fails ynh_restore_upgradebackup @@ -107,7 +110,8 @@ ynh_abort_if_errors # CHECK THE PATH #================================================= -path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path. +# Normalize the URL path syntax +path_url=$(ynh_normalize_url_path $path_url) #================================================= # ACTIVATE MAINTENANCE MODE @@ -123,7 +127,8 @@ ynh_maintenance_mode_ON if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source "$final_path" fi #================================================= @@ -146,7 +151,8 @@ fi # CREATE DEDICATED USER #================================================= -ynh_system_user_create $app # Create the dedicated user, if not exist +# Create a dedicated user (if not existing) +ynh_system_user_create $app #================================================= # SPECIFIC UPGRADE @@ -157,15 +163,17 @@ ynh_system_user_create $app # Create the dedicated user, if not exist # Overwrite the settings config file only if it's allowed if [ $overwrite_settings -eq 1 ] then - ## Copie et configuration du fichier de conf. - ynh_backup_if_checksum_is_different "$final_path/lutim.conf" # Créé un backup du fichier de config si il a été modifié. + # Configure Lutim + # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. + ynh_backup_if_checksum_is_different "$final_path/lutim.conf" cp ../conf/lutim.conf.template "$final_path/lutim.conf" ynh_replace_string "__DOMAIN__" "$domain" "$final_path/lutim.conf" ynh_replace_string "__PATH__" "$path_url" "$final_path/lutim.conf" ynh_replace_string "__PORT__" "$port" "$final_path/lutim.conf" ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$final_path/lutim.conf" ynh_replace_string "__SECRET__" "$secret" "$final_path/lutim.conf" - ynh_store_file_checksum "$final_path/lutim.conf" # Réenregistre la somme de contrôle du fichier de config + # Recalculate and store the checksum of the file for the next upgrade. + ynh_store_file_checksum "$final_path/lutim.conf" # Optional parameters from config-panel feature if [ -n "$antiflood" ]; then @@ -211,6 +219,7 @@ fi # SECURING FILES AND DIRECTORIES #================================================= +# Set permissions on app files chown -R $app: $final_path #================================================= @@ -228,8 +237,9 @@ chown $app -R /var/log/$app ynh_app_setting_set $app skipped_uris "/" if [ $is_public -eq 0 ] -then # Si l'app est privée, seul le visionnage des images reste public - # Modifie le domaine pour qu'il passe dans une regex +then + # If the app is private, viewing images stays publicly accessible. + # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" fi @@ -244,7 +254,7 @@ ynh_systemd_action --action=reload --service_name=nginx # START AND CHECK LUTIM BOOTING #================================================= -# Wait for lutim fully started +# Wait for lutim to be fully started ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" #=================================================