mirror of
https://github.com/plausible/analytics.git
synced 2024-11-23 11:12:15 +03:00
Use password for sshh
This commit is contained in:
parent
1efc68fa59
commit
6b8cfbe676
@ -153,6 +153,7 @@ config :plausible, :twitter,
|
||||
|
||||
config :plausible, :custom_domain_server,
|
||||
user: System.get_env("CUSTOM_DOMAIN_SERVER_USER"),
|
||||
password: System.get_env("CUSTOM_DOMAIN_SERVER_PASSWORD"),
|
||||
ip: System.get_env("CUSTOM_DOMAIN_SERVER_IP")
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
|
@ -49,6 +49,7 @@ postmark_api_key = System.get_env("POSTMARK_API_KEY")
|
||||
cron_enabled = String.to_existing_atom(System.get_env("CRON_ENABLED", "false"))
|
||||
custom_domain_server_ip = System.get_env("CUSTOM_DOMAIN_SERVER_IP")
|
||||
custom_domain_server_user = System.get_env("CUSTOM_DOMAIN_SERVER_USER")
|
||||
custom_domain_server_password = System.get_env("CUSTOM_DOMAIN_SERVER_PASSWORD")
|
||||
|
||||
config :plausible,
|
||||
admin_user: admin_user,
|
||||
@ -131,6 +132,7 @@ config :plausible, :twitter,
|
||||
|
||||
config :plausible, :custom_domain_server,
|
||||
user: custom_domain_server_user,
|
||||
password: custom_domain_server_password,
|
||||
ip: custom_domain_server_ip
|
||||
|
||||
crontab = [
|
||||
|
@ -1,15 +1,15 @@
|
||||
defmodule Plausible.Workers.ProvisionSslCertificates do
|
||||
use Plausible.Repo
|
||||
use Oban.Worker, queue: :provision_ssl_certificates
|
||||
@custom_domain_server Application.get_env(:plausible, :custom_domain_server)
|
||||
|
||||
@impl Oban.Worker
|
||||
def perform(_args, _job, ssh \\ SSHEx) do
|
||||
IO.inspect(@custom_domain_server)
|
||||
config = get_config()
|
||||
|
||||
{:ok, conn} = ssh.connect(
|
||||
ip: to_charlist(@custom_domain_server[:ip]),
|
||||
user: to_charlist(@custom_domain_server[:user]),
|
||||
user_dir: '/app/.ssh'
|
||||
ip: to_charlist(config[:ip]),
|
||||
user: to_charlist(config[:user]),
|
||||
password: to_charlist(config[:password])
|
||||
)
|
||||
|
||||
recent_custom_domains = Repo.all(
|
||||
@ -22,6 +22,7 @@ defmodule Plausible.Workers.ProvisionSslCertificates do
|
||||
{:ok, res, code} = ssh.run(conn, 'sudo certbot certonly --nginx -n -d \"#{domain.domain}\"')
|
||||
report_result({res, code}, domain)
|
||||
end
|
||||
:ok
|
||||
end
|
||||
|
||||
defp report_result({_, 0}, domain) do
|
||||
@ -34,4 +35,8 @@ defmodule Plausible.Workers.ProvisionSslCertificates do
|
||||
Sentry.capture_message("Error obtaining SSL certificate", extra: %{error_msg: error_msg, error_code: error_code, domain: domain.domain})
|
||||
:ok # Failing to obtain is expected, not a failure for the job queue
|
||||
end
|
||||
|
||||
defp get_config() do
|
||||
Application.get_env(:plausible, :custom_domain_server)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user