From 66f1f8d04234dafdb9e32e128a8a3a2e73153393 Mon Sep 17 00:00:00 2001 From: Kayou Date: Sun, 3 Mar 2019 18:52:39 +0100 Subject: [PATCH] check max_file_size --- scripts/change_url | 3 +++ scripts/install | 8 ++++++++ scripts/upgrade | 3 +++ 3 files changed, 14 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index a58390a..ef25dbf 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -112,6 +112,9 @@ ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" +if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit + ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" +fi ynh_replace_string "__SECRET__" "$secret" "${final_path}/lufi.conf" if [ $is_public -eq 0 ]; diff --git a/scripts/install b/scripts/install index 850b828..b2a5b4a 100644 --- a/scripts/install +++ b/scripts/install @@ -43,6 +43,11 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) +# Check if max_file_size is a number +if ! [[ $max_file_size =~ "^[\-0-9]+$" ]] && [ $max_file_size -lt 0 ]; then + ynh_die "Max file must be a number positive or zero" +fi + # Check web path availability ynh_webpath_available $domain $path_url # Register (book) web path @@ -132,6 +137,9 @@ ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" +if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit + ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" +fi secret=$(ynh_string_random 24) ynh_app_setting_set $app secret $secret diff --git a/scripts/upgrade b/scripts/upgrade index d2be926..95e9ea0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -116,6 +116,9 @@ ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lufi.conf" ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lufi.conf" ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lufi.conf" ynh_replace_string "__MAX_FILE_SIZE__" "$max_file_size" "${final_path}/lufi.conf" +if [ $max_file_size -eq 0 ]; then # Comment the limitation line if no limit + ynh_replace_string "max_file_size" "#max_file_size" "${final_path}/lufi.conf" +fi ynh_replace_string "__SECRET__" "$secret" "${final_path}/lufi.conf" if [ $is_public -eq 0 ];