From 40105216aaddb6837642fd2b44d4e3c7e988a7a0 Mon Sep 17 00:00:00 2001 From: anmol Date: Sat, 10 Nov 2018 03:30:30 +0530 Subject: [PATCH] Added option for cache --- conf/prod.secret.exs | 2 +- scripts/install | 6 ++++++ scripts/remove | 5 +---- scripts/upgrade | 31 ++++++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/conf/prod.secret.exs b/conf/prod.secret.exs index 898c983..708f37c 100644 --- a/conf/prod.secret.exs +++ b/conf/prod.secret.exs @@ -14,7 +14,7 @@ config :pleroma, :instance, dedupe_media: false config :pleroma, :media_proxy, - enabled: false, + enabled: __MEDIA_CACHE__, redirect_on_failure: true #base_url: "https://cache.pleroma.social" diff --git a/scripts/install b/scripts/install index c2f0c40..5153a68 100755 --- a/scripts/install +++ b/scripts/install @@ -170,6 +170,12 @@ ynh_replace_string "__ADMIN_EMAIL__" "$admin_email" "$final_path/$app/config ynh_replace_string "__PORT__" "$port" "$final_path/$app/config/prod.secret.exs" ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/setup_db.psql" ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/setup_db.psql" +if [ $cache -eq 1 ] +then + ynh_replace_string "__MEDIA_CACHE__" "true" "$final_path/$app/config/prod.secret.exs" +else + ynh_replace_string "__MEDIA_CACHE__" "false" "$final_path/$app/config/prod.secret.exs" +fi # Set registrations open/closed if [ $registration -eq 1 ] diff --git a/scripts/remove b/scripts/remove index 683af58..6f73b04 100755 --- a/scripts/remove +++ b/scripts/remove @@ -65,11 +65,8 @@ ynh_secure_remove "$final_path" # Remove the dedicated nginx config ynh_remove_nginx_config +ynh_secure_remove /etc/nginx/conf.d/$app-cache.conf -if [ $cache -eq 1 ] -then - rm -f /etc/nginx/conf.d/$app-cache.conf -fi #================================================= # CLOSE A PORT diff --git a/scripts/upgrade b/scripts/upgrade index f4daa4b..49ddd13 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -120,9 +120,9 @@ chown -R "$app":"$app" "$final_path" # Create a dedicated nginx config ynh_add_nginx_config +ynh_secure_remove /etc/nginx/conf.d/$app-cache.conf if [ $cache -eq 1 ] then - rm -f /etc/nginx/conf.d/$app-cache.conf cp -rf "../conf/cache.conf" "/etc/nginx/conf.d/$app-cache.conf" ynh_replace_string "{APP}" "$app" "/etc/nginx/conf.d/$app-cache.conf" ynh_replace_string "__SIZE__" "$size" "/etc/nginx/conf.d/$app-cache.conf" @@ -133,6 +133,35 @@ then ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" fi +#================================================= +# MODIFY A CONFIG FILE +#================================================= +cp -f ../conf/prod.secret.exs "$final_path/$app/config/prod.secret.exs" +cp -f ../conf/setup_db.psql "$final_path/$app/config/setup_db.psql" + +ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/config/prod.secret.exs" +ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/config/prod.secret.exs" +ynh_replace_string "__INSTANCE_NAME__" "$name" "$final_path/$app/config/prod.secret.exs" +ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/prod.secret.exs" +ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/prod.secret.exs" +ynh_replace_string "__ADMIN_EMAIL__" "$admin_email" "$final_path/$app/config/prod.secret.exs" +ynh_replace_string "__PORT__" "$port" "$final_path/$app/config/prod.secret.exs" +ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/setup_db.psql" +ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/setup_db.psql" +if [ $cache -eq 1 ] +then + ynh_replace_string "__MEDIA_CACHE__" "true" "$final_path/$app/config/prod.secret.exs" +else + ynh_replace_string "__MEDIA_CACHE__" "false" "$final_path/$app/config/prod.secret.exs" +fi + +# Set registrations open/closed +if [ $registration -eq 1 ] +then + ynh_replace_string "__REG__" "true" "$final_path/$app/config/prod.secret.exs" +else + ynh_replace_string "__REG__" "false" "$final_path/$app/config/prod.secret.exs" +fi # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/$app/config/prod.secret.exs"