Ensure .env file is only accessible to user

This commit is contained in:
David Heinemeier Hansson
2023-02-11 12:56:57 +01:00
parent 0f4e1888d9
commit 63a065237a

View File

@@ -107,10 +107,14 @@ class Mrsk::Cli::Main < Mrsk::Cli::Base
desc "envify", "Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)" desc "envify", "Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)"
def envify def envify
if destination = options[:destination] if destination = options[:destination]
File.write(".env.#{destination}", ERB.new(IO.read(Pathname.new(File.expand_path(".env.#{destination}.erb")))).result) env_template_path = ".env.#{destination}.erb"
env_path = ".env.#{destination}"
else else
File.write(".env", ERB.new(IO.read(Pathname.new(File.expand_path(".env.erb")))).result) env_template_path = ".env.erb"
env_path = ".env"
end end
File.open(env_path, "w+", 0600) { |env_file| env_file.write ERB.new(Pathname.new(env_template_path).read).result }
end end
desc "remove", "Remove Traefik, app, and registry session from servers" desc "remove", "Remove Traefik, app, and registry session from servers"