Allow setting upload/static directories in the config generator
authorrinpatch <rinpatch@sdf.org>
Thu, 20 Jun 2019 00:59:16 +0000 (03:59 +0300)
committerrinpatch <rinpatch@sdf.org>
Thu, 20 Jun 2019 00:59:16 +0000 (03:59 +0300)
lib/mix/tasks/pleroma/instance.ex
lib/mix/tasks/pleroma/sample_config.eex

index 1d89827ba1b737822b565fbb355d350d2dc9b100..2c4e414cfa71ec3a4e2ce027ac99289304917872 100644 (file)
@@ -31,6 +31,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
   - `--dbpass DBPASS` - the password to use for the database connection
   - `--indexable Y/N` - Allow/disallow indexing site by search engines
   - `--db-configurable Y/N` - Allow/disallow configuring instance from admin part
+  - `--uploads-dir` - the directory uploads go in when using a local uploader
+  - `--static-dir` - the directory custom public files should be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)
   """
 
   def run(["gen" | rest]) do
@@ -50,7 +52,9 @@ defmodule Mix.Tasks.Pleroma.Instance do
           dbuser: :string,
           dbpass: :string,
           indexable: :string,
-          db_configurable: :string
+          db_configurable: :string,
+          uploads_dir: :string,
+          static_dir: :string
         ],
         aliases: [
           o: :output,
@@ -107,7 +111,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
         get_option(
           options,
           :db_configurable,
-          "Do you want to be able to configure instance from admin part? (y/n)",
+          "Do you want to store the configuration in the database (allows controlling it from admin-fe)? (y/n)",
           "y"
         ) === "y"
 
@@ -132,6 +136,22 @@ defmodule Mix.Tasks.Pleroma.Instance do
           "autogenerated"
         )
 
+      uploads_dir =
+        get_option(
+          options,
+          :upload_dir,
+          "What directory should media uploads go in (when using the local uploader)?",
+          Pleroma.Config.get([Pleroma.Uploaders.Local, :uploads])
+        )
+
+      static_dir =
+        get_option(
+          options,
+          :static_dir,
+          "What directory should custom public files be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)?",
+          Pleroma.Config.get([:instance, :static_dir])
+        )
+
       secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
       signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
       {web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)
@@ -152,7 +172,9 @@ defmodule Mix.Tasks.Pleroma.Instance do
           signing_salt: signing_salt,
           web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
           web_push_private_key: Base.url_encode64(web_push_private_key, padding: false),
-          db_configurable?: db_configurable?
+          db_configurable?: db_configurable?,
+          static_dir: static_dir,
+          uploads_dir: uploads_dir
         )
 
       result_psql =
index 0c4e49f0db5e60adec0364ddfc10f9c2c502449d..8b45acb05b6eb7c625fb819d7d463c145be0f4c3 100644 (file)
@@ -37,6 +37,9 @@ config :web_push_encryption, :vapid_details,
   public_key: "<%= web_push_public_key %>",
   private_key: "<%= web_push_private_key %>"
 
+config :pleroma, :instance, static_dir: "<%= static_dir %>"
+config :pleroma, Pleroma.Uploaders.Local, uploads: "<%= uploads_dir %>"
+
 # Enable Strict-Transport-Security once SSL is working:
 # config :pleroma, :http_security,
 #   sts: true