1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00

Indentation

This commit is contained in:
Maniack Crudelis 2020-04-24 19:59:27 +02:00
parent 4e28257f05
commit a934b73698
9 changed files with 239 additions and 239 deletions

View file

@ -1,22 +1,22 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH) path="/path" (PATH)
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
always_encrypt=1 always_encrypt=1
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
setup_root=1 setup_root=1
setup_nourl=0 setup_nourl=0
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
upgrade=1 from_commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d upgrade=1 from_commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=1 (8095) port_already_use=1 (8095)
change_url=1 change_url=1
;;; Levels ;;; Levels
# Level 5: https://github.com/YunoHost/package_linter/issues/36 # Level 5: https://github.com/YunoHost/package_linter/issues/36
Level 5=1 Level 5=1
@ -24,6 +24,6 @@
Email= Email=
Notification=down Notification=down
;;; Upgrade options ;;; Upgrade options
; commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d ; commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
name=08 Sep 2017 4c29aa94f9d9048411c6e165e122e03574fb9b8d name=08 Sep 2017 4c29aa94f9d9048411c6e165e122e03574fb9b8d
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&always_encrypt=1& manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&always_encrypt=1&

View file

@ -1,30 +1,30 @@
location __PATH__ { location __PATH__ {
# Force usage of https # Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
# This is important for user's privacy ! # This is important for user's privacy !
access_log off; access_log off;
error_log /var/log/nginx/lutim.error.log; error_log /var/log/nginx/lutim.error.log;
# This is important ! Make it OK with your Lutim configuration # This is important ! Make it OK with your Lutim configuration
client_max_body_size 40M; client_max_body_size 40M;
proxy_pass http://127.0.0.1:__PORT__; proxy_pass http://127.0.0.1:__PORT__;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Lutim reads this header and understands that the current session is actually HTTPS. # Lutim reads this header and understands that the current session is actually HTTPS.
# Enable it if you run a HTTPS server (in this case, don't forgot to change the listen port # Enable it if you run a HTTPS server (in this case, don't forgot to change the listen port
proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Proto https;
# We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite # We expect the downsteam servers to redirect to the right hostname, so don't do any rewrite
proxy_redirect off; proxy_redirect off;
} }

View file

@ -1,64 +1,64 @@
{ {
"name": "Lutim", "name": "Lutim",
"id": "lutim", "id": "lutim",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "Self hosting images and sharing anonymous application", "en": "Self hosting images and sharing anonymous application",
"fr": "Application d'hébergement et de partage d'images anonyme" "fr": "Application d'hébergement et de partage d'images anonyme"
}, },
"version": "0.11.6~ynh3", "version": "0.11.6~ynh3",
"url": "https://lut.im", "url": "https://lut.im",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"maintainer": { "maintainer": {
"name": "Maniack Crudelis et matlink", "name": "Maniack Crudelis et matlink",
"email": "maniackc_dev@crudelis.fr" "email": "maniackc_dev@crudelis.fr"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.7" "yunohost": ">= 3.7"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
"nginx" "nginx"
], ],
"arguments": { "arguments": {
"install" : [ "install" : [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain",
"ask": { "ask": {
"en": "Choose a domain for Lutim", "en": "Choose a domain for Lutim",
"fr": "Choisissez un domaine pour Lutim" "fr": "Choisissez un domaine pour Lutim"
}, },
"example": "domain.org" "example": "domain.org"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"ask": { "ask": {
"en": "Choose a path for Lutim", "en": "Choose a path for Lutim",
"fr": "Choisissez un chemin pour Lutim" "fr": "Choisissez un chemin pour Lutim"
}, },
"example": "/lutim", "example": "/lutim",
"default": "/lutim" "default": "/lutim"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"ask": { "ask": {
"en": "Uploading images is it public?", "en": "Uploading images is it public?",
"fr": "L'upload des images est-il public ?" "fr": "L'upload des images est-il public ?"
}, },
"default": false "default": false,
}, },
{ {
"name": "always_encrypt", "name": "always_encrypt",
"type": "boolean", "type": "boolean",
"ask": { "ask": {
"en": "Force the encryption of images?", "en": "Force the encryption of images?",
"fr": "Forcer le chiffrement des images ?" "fr": "Forcer le chiffrement des images ?"
}, },
"default": true "default": true
} }
] ]
} }
} }

View file

@ -28,7 +28,7 @@ secret=$(ynh_app_setting_get --app=$app --key=secret)
file="$1" file="$1"
if [ "$file" = "lutim.conf" ]; then if [ "$file" = "lutim.conf" ]; then
config_file="$final_path/lutim.conf" config_file="$final_path/lutim.conf"
fi fi
#================================================= #=================================================
@ -43,15 +43,15 @@ ynh_backup_if_checksum_is_different --file="$config_file"
if [ "$file" = "lutim.conf" ] if [ "$file" = "lutim.conf" ]
then then
# Get the default file and overwrite the current config # Get the default file and overwrite the current config
cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file" cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file"
# Recreate the default config # Recreate the default config
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file"
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config_file" ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config_file"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$config_file" ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$config_file"
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config_file" ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config_file"
# Set the number of process for Lutim to twice the number of CPU core. # Set the number of process for Lutim to twice the number of CPU core.
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
fi fi

View file

@ -63,13 +63,13 @@ ynh_maintenance_mode_ON
change_domain=0 change_domain=0
if [ "$old_domain" != "$new_domain" ] if [ "$old_domain" != "$new_domain" ]
then then
change_domain=1 change_domain=1
fi fi
change_path=0 change_path=0
if [ "$old_path" != "$new_path" ] if [ "$old_path" != "$new_path" ]
then then
change_path=1 change_path=1
fi fi
#================================================= #=================================================
@ -95,26 +95,26 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file # Change the path in the nginx config file
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
then then
# Make a backup of the original nginx config file if modified # Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path" ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for nginx helper # Set global variables for nginx helper
domain="$old_domain" domain="$old_domain"
path_url="$new_path" path_url="$new_path"
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
fi fi
# Change the domain for nginx # Change the domain for nginx
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path" ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#================================================= #=================================================
@ -124,14 +124,14 @@ ynh_script_progression --message="Reconfiguring SSOwat..."
if [ $is_public -eq 0 ] # Only user with a yunohost account can upload an image if [ $is_public -eq 0 ] # Only user with a yunohost account can upload an image
then then
# If the app is private, viewing images stays publicly accessible. # If the app is private, viewing images stays publicly accessible.
if [ "$new_path" == "/" ]; then if [ "$new_path" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
new_path="" new_path=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$new_domain" | sed 's@-@.@g') domain_regex=$(echo "$new_domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$new_path/stats/?$","$domain_regex$new_path/manifest.webapp/?$","$domain_regex$new_path/?$","$domain_regex$new_path/[d-m]/.*$" ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$new_path/stats/?$","$domain_regex$new_path/manifest.webapp/?$","$domain_regex$new_path/?$","$domain_regex$new_path/[d-m]/.*$"
fi fi
#================================================= #=================================================

View file

@ -26,9 +26,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
config_file="$final_path/lutim.conf" config_file="$final_path/lutim.conf"
get_config_value() { get_config_value() {
option_name="$1" option_name="$1"
# Get the value of this option in the config file # Get the value of this option in the config file
grep "$option_name *=>" "$config_file" | cut -d'>' -f2 | sed s'/ //g' | cut -d',' -f1 grep "$option_name *=>" "$config_file" | cut -d'>' -f2 | sed s'/ //g' | cut -d',' -f1
} }
#================================================= #=================================================
@ -49,15 +49,15 @@ antiflood="${YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD:-$old_antiflood}"
# delay # delay
old_delay="$(get_config_value default_delay)" old_delay="$(get_config_value default_delay)"
if [ $old_delay -eq 0 ]; then if [ $old_delay -eq 0 ]; then
old_delay=None old_delay=None
elif [ $old_delay -eq 1 ]; then elif [ $old_delay -eq 1 ]; then
old_delay=Day old_delay=Day
elif [ $old_delay -eq 7 ]; then elif [ $old_delay -eq 7 ]; then
old_delay=Week old_delay=Week
elif [ $old_delay -eq 30 ]; then elif [ $old_delay -eq 30 ]; then
old_delay=Month old_delay=Month
else else
old_delay=Year old_delay=Year
fi fi
delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}" delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}"
@ -82,18 +82,18 @@ admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_htm
#================================================= #=================================================
show_config() { show_config() {
# here you are supposed to read some config file/database/other then print the values # here you are supposed to read some config file/database/other then print the values
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" # ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT=$always_encrypt" ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT=$always_encrypt"
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood" ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood"
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay" ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay"
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings" ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd" ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html" ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
} }
#================================================= #=================================================
@ -166,6 +166,6 @@ apply_config() {
#================================================= #=================================================
case $1 in case $1 in
show) show_config;; show) show_config;;
apply) apply_config;; apply) apply_config;;
esac esac

View file

@ -17,7 +17,7 @@ source _variables
ynh_clean_setup () { ynh_clean_setup () {
# Clean installation remaining that are not handle by the remove script. # Clean installation remaining that are not handle by the remove script.
ynh_clean_check_starting ynh_clean_check_starting
} }
ynh_abort_if_errors ynh_abort_if_errors
@ -158,7 +158,7 @@ carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu) arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu)
if [ "$?" -ne 0 ] if [ "$?" -ne 0 ]
then then
ynh_die --message="Unable to find the perl directory for your architecture." ynh_die --message="Unable to find the perl directory for your architecture."
fi fi
ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$final_path/script/lutim" ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$final_path/script/lutim"
@ -208,17 +208,17 @@ ynh_permission_create --permission="upload images" --allowed="visitors"
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then then
# If the app is private, viewing images stays publicly accessible. # If the app is private, viewing images stays publicly accessible.
if [ "$path_url" == "/" ]; then if [ "$path_url" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
path_url="" path_url=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$" ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
# If the app is not public, then the "visitors" group doesn't have this permission # If the app is not public, then the "visitors" group doesn't have this permission
ynh_permission_update --permission="upload images" --remove="visitors" ynh_permission_update --permission="upload images" --remove="visitors"
fi fi
#================================================= #=================================================

View file

@ -17,7 +17,7 @@ source ../settings/scripts/_variables
ynh_clean_setup () { ynh_clean_setup () {
# Clean installation remaining that are not handle by the remove script. # Clean installation remaining that are not handle by the remove script.
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -39,9 +39,9 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
ynh_script_progression --message="Validating restoration parameters..." ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available --domain=$domain --path_url=$path_url \ ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE

View file

@ -48,87 +48,87 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
# Fix is_public as a boolean # Fix is_public as a boolean
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=1 ynh_app_setting_set --app=$app --key=is_public --value=1
is_public=1 is_public=1
elif [ "$is_public" = "No" ]; then elif [ "$is_public" = "No" ]; then
ynh_app_setting_set --app=$app --key=is_public --value=0 ynh_app_setting_set --app=$app --key=is_public --value=0
is_public=0 is_public=0
fi fi
skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris) skipped_uris=$(ynh_app_setting_get --app=$app --key=skipped_uris)
# Unused with the permission system # Unused with the permission system
if [ ! -z "$skipped_uris" ]; then if [ ! -z "$skipped_uris" ]; then
ynh_app_setting_delete --app=$app --key=skipped_uris ynh_app_setting_delete --app=$app --key=skipped_uris
fi fi
# Create the permission "upload images" only if it doesn't exist. # Create the permission "upload images" only if it doesn't exist.
if ! ynh_permission_exists --permission="upload images" if ! ynh_permission_exists --permission="upload images"
then then
# This is a fake permission without any URL. # This is a fake permission without any URL.
# The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified. # The purpose of this permission is only to trigger hooks post_app_add/removeaccess when it's modified.
# We can't use a real permission for now because the actual permision system doesn't support regex. # We can't use a real permission for now because the actual permision system doesn't support regex.
ynh_permission_create --permission="upload images" --allowed="visitors" ynh_permission_create --permission="upload images" --allowed="visitors"
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then then
# If the app is private, viewing images stays publicly accessible. # If the app is private, viewing images stays publicly accessible.
if [ "$path_url" == "/" ]; then if [ "$path_url" == "/" ]; then
# If the path is /, clear it to prevent any error with the regex. # If the path is /, clear it to prevent any error with the regex.
path_url="" path_url=""
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$" ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
# If the app is not public, then the "visitors" group doesn't have this permission # If the app is not public, then the "visitors" group doesn't have this permission
ynh_permission_update --permission="upload images" --remove="visitors" ynh_permission_update --permission="upload images" --remove="visitors"
fi fi
fi fi
# if final_path isn't set, which can happens with old scripts, set final_path. # if final_path isn't set, which can happens with old scripts, set final_path.
if [ -z "$final_path" ]; then if [ -z "$final_path" ]; then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
# Fix always_encrypt as a boolean # Fix always_encrypt as a boolean
if [ "$always_encrypt" = "Yes" ]; then if [ "$always_encrypt" = "Yes" ]; then
ynh_app_setting_set --app=$app --key=always_encrypt --value=1 ynh_app_setting_set --app=$app --key=always_encrypt --value=1
always_encrypt=1 always_encrypt=1
elif [ "$always_encrypt" = "No" ]; then elif [ "$always_encrypt" = "No" ]; then
ynh_app_setting_set --app=$app --key=always_encrypt --value=0 ynh_app_setting_set --app=$app --key=always_encrypt --value=0
always_encrypt=0 always_encrypt=0
fi fi
# If overwrite_settings doesn't exist, create it # If overwrite_settings doesn't exist, create it
if [ -z "$overwrite_settings" ]; then if [ -z "$overwrite_settings" ]; then
overwrite_settings=1 overwrite_settings=1
ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings
fi fi
# If overwrite_nginx doesn't exist, create it # If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1 overwrite_nginx=1
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
fi fi
# If overwrite_systemd doesn't exist, create it # If overwrite_systemd doesn't exist, create it
if [ -z "$overwrite_systemd" ]; then if [ -z "$overwrite_systemd" ]; then
overwrite_systemd=1 overwrite_systemd=1
ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd
fi fi
# If secret doesn't exist, create it # If secret doesn't exist, create it
if [ -z "$secret" ]; then if [ -z "$secret" ]; then
secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2) secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2)
ynh_app_setting_set --app=$app --key=secret --value=$secret ynh_app_setting_set --app=$app --key=secret --value=$secret
fi fi
# Close opened port # Close opened port
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
ynh_exec_quiet yunohost firewall disallow TCP $port ynh_exec_quiet yunohost firewall disallow TCP $port
fi fi
# Replace skipped_uris by unprotected_uris for the migration to the new permission system. # Replace skipped_uris by unprotected_uris for the migration to the new permission system.
@ -144,9 +144,9 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# Clean installation remaining that are not handle by the remove script. # Clean installation remaining that are not handle by the remove script.
ynh_clean_check_starting ynh_clean_check_starting
# restore it if the upgrade fails # restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -173,9 +173,9 @@ ynh_maintenance_mode_ON
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
fi fi
#================================================= #=================================================
@ -192,8 +192,8 @@ ynh_install_app_dependencies $app_depencencies
# Overwrite the nginx configuration only if it's allowed # Overwrite the nginx configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ] if [ $overwrite_nginx -eq 1 ]
then then
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
ynh_add_nginx_config ynh_add_nginx_config
fi fi
#================================================= #=================================================
@ -214,31 +214,31 @@ ynh_script_progression --message="Reconfigure Lutim"
# Overwrite the settings config file only if it's allowed # Overwrite the settings config file only if it's allowed
if [ $overwrite_settings -eq 1 ] if [ $overwrite_settings -eq 1 ]
then then
# Configure Lutim # Configure Lutim
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different --file="$final_path/lutim.conf" ynh_backup_if_checksum_is_different --file="$final_path/lutim.conf"
cp ../conf/lutim.conf.template "$final_path/lutim.conf" cp ../conf/lutim.conf.template "$final_path/lutim.conf"
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lutim.conf"
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/lutim.conf"
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/lutim.conf"
ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$final_path/lutim.conf"
ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$final_path/lutim.conf"
# Set the number of process for Lutim to twice the number of CPU core. # Set the number of process for Lutim to twice the number of CPU core.
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/lutim.conf" ynh_store_file_checksum --file="$final_path/lutim.conf"
# Optional parameters from config-panel feature # Optional parameters from config-panel feature
if [ -n "$antiflood" ]; then if [ -n "$antiflood" ]; then
ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$final_path/lutim.conf" ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$final_path/lutim.conf"
# Disable anti_flood_delay if the delay is 0 # Disable anti_flood_delay if the delay is 0
if [ $antiflood = 0 ]; then if [ $antiflood = 0 ]; then
ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$final_path/lutim.conf" ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$final_path/lutim.conf"
fi fi
fi fi
if [ -n "$delay" ]; then if [ -n "$delay" ]; then
ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$final_path/lutim.conf" ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$final_path/lutim.conf"
fi fi
fi fi
#================================================= #=================================================
@ -255,8 +255,8 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
# Overwrite the systemd configuration only if it's allowed # Overwrite the systemd configuration only if it's allowed
if [ $overwrite_systemd -eq 1 ] if [ $overwrite_systemd -eq 1 ]
then then
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
ynh_add_systemd_config ynh_add_systemd_config
fi fi
#================================================= #=================================================
@ -273,9 +273,9 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading Lutim with carton..." --weight=4 ynh_script_progression --message="Upgrading Lutim with carton..." --weight=4
(cd $final_path (cd $final_path
carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log") carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
fi fi
#================================================= #=================================================