Fix sponsorship tier price formatting

Fix sponsorship tier price formatting

Sponsors

        Our sponsors play a vital role in supporting the foundation's initiatives. It is through their generous donations that we can work on our mission to support and expand the Beam community.

          <%= for %{logo_url: logo_path, url: href} <- active_and_founding_sponsors(@sponsors) do %>

              <a href="<%= href %>" class="d-block mb-2">
                <img class="img-fluid img-thumbnail borderless sponsor" src="<%= image_path(@conn, logo_path) %>" alt="">

          <% end %>
          <%= for %{logo_url: logo_path, url: href} <- active_non_founding_sponsors(@sponsors) do %>

              <a href="<%= href %>" class="d-block mb-2">
                <img class="img-fluid img-thumbnail borderless sponsor" src="<%= image_path(@conn, logo_path) %>" alt="">

          <% end %>

Become a sponsor!

Your donation will help the development of technologies and open source projects that your engineers and many engineers around the world will use daily.

We are really excited you are interested in helping us grow a diverse community around the Erlang and Elixir Ecosystem. Your donation will help the development of technologies and open source projects that your engineers and many engineers around the world will use daily. This work can’t be done without the financial support of organizations like yours.

When you become a sponsor we will acknowledge your donation and we will include your logo and link on the EEF web site and on other communications such as conferences and social media whenever appropriate.

Sponsorship Tiers

              Revenue or expense (whichever is larger)
              Yearly minimal sponsorship fee

               $10,000
              $2,000

              $10,000 … $50,000
              $5,000

               $50,000
              $10,000

Founding Sponsors

        <%= for %{name: name} <- active_and_founding_sponsors(@sponsors) do %>

<%= name %>

        <% end %>

Sponsors

        Our sponsors play a vital role in supporting the foundation's initiatives. It is through their generous donations that we can work on our mission to support and expand the Beam community.

          <%= for %{logo_url: logo_path, url: href} <- active_and_founding_sponsors(@sponsors) do %>

              <a href="<%= href %>" class="d-block mb-2">
                <img class="img-fluid img-thumbnail borderless sponsor" src="<%= image_path(@conn, logo_path) %>" alt="">

          <% end %>
          <%= for %{logo_url: logo_path, url: href} <- active_non_founding_sponsors(@sponsors) do %>

              <a href="<%= href %>" class="d-block mb-2">
                <img class="img-fluid img-thumbnail borderless sponsor" src="<%= image_path(@conn, logo_path) %>" alt="">

          <% end %>

Become a sponsor!

Your donation will help the development of technologies and open source projects that your engineers and many engineers around the world will use daily.

We are really excited you are interested in helping us grow a diverse community around the Erlang and Elixir Ecosystem. Your donation will help the development of technologies and open source projects that your engineers and many engineers around the world will use daily. This work can’t be done without the financial support of organizations like yours.

When you become a sponsor we will acknowledge your donation and we will include your logo and link on the EEF web site and on other communications such as conferences and social media whenever appropriate.

Sponsorship Tiers

              Revenue or expense (whichever is larger)
              Yearly minimal sponsorship fee

               $1.000.000
              $2.000

              $1.000.000 … $5.000.000
              $5.000

               $5.000.000
              $10.000

Founding Sponsors

        <%= for %{name: name} <- active_and_founding_sponsors(@sponsors) do %>

<%= name %>

        <% end %>


Add login form

Add login form

  <%= form_for @conn, auth_path(@conn, :create), [as: :auth], fn f -> %>
    <fieldset>

        <%= email_input(f, :email,
          id: "auth_email",
          class: class_with_error(f, :email, "email"),
          placeholder: gettext("Your account's e-mail"),
          required: true) %>
        <%= error_tag(f, :email) %>

        <%= password_input(f, :password,
          id: "auth_password",
          class: class_with_error(f, :password, "password"),
          placeholder: gettext("Your account's password"),
          required: true) %>
        <%= error_tag(f, :password) %>

    </fieldset>
    <fieldset>

        <%= submit("Submit", class: "btn btn-primary") %>

    </fieldset>
  <% end %>


links in header

links in header

  <button type="button"
          class="navbar-toggle collapsed"
          data-toggle="collapse"
          data-target="#navbar"
          aria-expanded="false"
          aria-controls="navbar">
    Toggle navigation

  </button>

  Panoptikum.io

<%= link "Home", to: category_frontend_path(@conn, :index) %>

<%= link "Podcasters", to: user_frontend_path(@conn, :index) %>

<%= link ["Random ", fa_icon("podcast")], to: recommendation_frontend_path(@conn, :random) %>

    <%= if @current_user do %>

          @<%= @current_user.username %>

<%= link "My Profile",  to: user_frontend_path(@conn, :my_profile)%>

<%= link "Change Password", to: user_frontend_path(@conn, :edit_password)%>

<%= link "My Messages", to: user_frontend_path(@conn, :my_messages)%>

<%= link "My Podcasts", to: user_frontend_path(@conn, :my_podcasts)%>

<%= link "My Recommendations", to: recommendation_frontend_path(@conn, :my_recommendations)%>

<%= link "My OPMLs",    to: opml_frontend_path(@conn, :index)%>

      <%= if @current_user.admin do %>

            Administration

<%= link "Categories",      to: category_path(@conn, :index) %>

<%= link "Feed Backlog",    to: feed_backlog_path(@conn, :index) %>

<%= link "Languages",       to: language_path(@conn, :index) %>

<%= link "Podcasts",        to: podcast_path(@conn, :index) %>

<%= link "Users",           to: user_path(@conn, :index) %>

<%= link "OPMLs",           to: opml_path(@conn, :index) %>

<%= link "Messagages",      to: message_path(@conn, :index) %>

<%= link "Likes",           to: like_path(@conn, :index) %>

<%= link "Follows",         to: follow_path(@conn, :index) %>

<%= link "Subscriptions",   to: subscription_path(@conn, :index) %>

<%= link "Recommendations", to: recommendation_path(@conn, :index) %>

      <% end %>

          <%= link "Log out", to: session_path(@conn, :delete, @current_user),
                              method: "delete" %>

    <% else %>

<%= link "Register", to: user_path(@conn, :new) %>

<%= link "Log in", to: session_path(@conn, :new) %>

    <% end %>

  <button type="button"
          class="navbar-toggle collapsed"
          data-toggle="collapse"
          data-target="#navbar"
          aria-expanded="false"
          aria-controls="navbar">
    Toggle navigation

  </button>

  Panoptikum.io

<%= link "Categories", to: category_frontend_path(@conn, :index) %>

<%= link "Podcasters", to: user_frontend_path(@conn, :index) %>

<%= link ["Random ", fa_icon("podcast")], to: recommendation_frontend_path(@conn, :random) %>

    <%= if @current_user do %>

          @<%= @current_user.username %>

<%= link "My Profile",  to: user_frontend_path(@conn, :my_profile)%>

<%= link "Change Password", to: user_frontend_path(@conn, :edit_password)%>

<%= link "My Messages", to: user_frontend_path(@conn, :my_messages)%>

<%= link "My Podcasts", to: user_frontend_path(@conn, :my_podcasts)%>

<%= link "My Recommendations", to: recommendation_frontend_path(@conn, :my_recommendations)%>

<%= link "My OPMLs",    to: opml_frontend_path(@conn, :index)%>

      <%= if @current_user.admin do %>

            Administration

<%= link "Categories",      to: category_path(@conn, :index) %>

<%= link "Feed Backlog",    to: feed_backlog_path(@conn, :index) %>

<%= link "Languages",       to: language_path(@conn, :index) %>

<%= link "Podcasts",        to: podcast_path(@conn, :index) %>

<%= link "Users",           to: user_path(@conn, :index) %>

<%= link "OPMLs",           to: opml_path(@conn, :index) %>

<%= link "Messagages",      to: message_path(@conn, :index) %>

<%= link "Likes",           to: like_path(@conn, :index) %>

<%= link "Follows",         to: follow_path(@conn, :index) %>

<%= link "Subscriptions",   to: subscription_path(@conn, :index) %>

<%= link "Recommendations", to: recommendation_path(@conn, :index) %>

      <% end %>

          <%= link "Log out", to: session_path(@conn, :delete, @current_user),
                              method: "delete" %>

    <% else %>

<%= link "Register", to: user_path(@conn, :new) %>

<%= link "Log in", to: session_path(@conn, :new) %>

    <% end %>


Security: disable ReactDevTools in prod

Security: disable ReactDevTools in prod

<!DOCTYPE html>

    <%= if Application.get_env(:remote_retro, :env) == :prod do %>

    <% else %>

    <% end %>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="A real-time application for conducting Agile retrospectives">
    <meta name="google-site-verification" content="T5W8sjrjt-BmTK5SYTjPM-FQZD8oGNatTNAJSyRex7o" />
    <meta name="author" content="">
    <title>RemoteRetro | Free. World-class. Retrospectives.</title>

    <link rel="preload" href="<%= Routes.static_path(@conn, "/css/semantic-ui/font/lato-v14-latin-regular.woff2") %>" as="font" crossorigin="anonymous" />
    <link rel="preload" href="<%= Routes.static_path(@conn, "/css/semantic-ui/themes/default/assets/fonts/icons.woff2") %>" as="font" crossorigin="anonymous" />
    <link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/semantic-ui/semantic.min.css") %>">
    <link rel="stylesheet" href="<%= app_css(@conn) %>">
    <link rel="apple-touch-icon" href="<%= Routes.static_path(@conn, "/images/apple-touch-icon.png") %>">

    <%= if Application.get_env(:remote_retro, :env) == :test do %>

    <% end %>

  <body class="<%= if assigns[:is_landing_page], do: "landing-page" %>">

    <%= unless assigns[:omit_header] do %>

RemoteRetro

Built by

<img src="<%= Routes.static_path(@conn, "/images/stride_logo.png") %>" alt="Stride" />

          <%= if @current_user do %>

              Log Out

          <% end %>

    <% end %>
      <%= render @view_module, @view_template, assigns %>

    <%= if assigns[:include_js] do %>

    <% end %>


test fix

test fix

<!DOCTYPE html>

	<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
	<meta content="width=device-width, initial-scale=1" name="viewport">
	<meta content="BeyondBOINC displays the recently created content from a curated list of Steemit authors on the topics of cryptocurrency, distributed computing and technology." name="description">
	<meta content="Gridcoin, Bitshares, Steemit, Cryptocurrency, Blog, Aggregator, Glasnost, BOINC, BeyondBitcoin, BeyondBOINC, Distributed Computing, Cloud computing, Science, Peerplays, Blockchain, Decentralization, money, science, technology, crypto" name="keywords">
	<meta content="Customminer aka @cm-steem" name="author">
	<meta content="index, follow" name="robots">
	<meta content="1 days" name="revisit-after">

	<link rel="apple-touch-icon" sizes="57x57" href="/images/apple-icon-57x57.png">
	<link rel="apple-touch-icon" sizes="60x60" href="/images/apple-icon-60x60.png">
	<link rel="apple-touch-icon" sizes="72x72" href="/images/apple-icon-72x72.png">
	<link rel="apple-touch-icon" sizes="76x76" href="/images/apple-icon-76x76.png">
	<link rel="apple-touch-icon" sizes="114x114" href="/images/apple-icon-114x114.png">
	<link rel="apple-touch-icon" sizes="120x120" href="/images/apple-icon-120x120.png">
	<link rel="apple-touch-icon" sizes="144x144" href="/images/apple-icon-144x144.png">
	<link rel="apple-touch-icon" sizes="152x152" href="/images/apple-icon-152x152.png">
	<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-icon-180x180.png">
	<link rel="icon" type="image/png" sizes="192x192"  href="/images/android-icon-192x192.png">
	<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
	<link rel="icon" type="image/png" sizes="96x96" href="/images/favicon-96x96.png">
	<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
	<link rel="manifest" href="/images/manifest.json">
	<meta name="msapplication-TileColor" content="#ffffff">
	<meta name="msapplication-TileImage" content="/images/ms-icon-144x144.png">
	<meta name="theme-color" content="#ffffff">

	<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

	<link href="https://beyondboinc.net" rel="canonical">
	<title>BeyondBOINC: <%= naive_translate("head title", @conn.assigns[:lang])%></title>
 	<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
 	<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.10/semantic.css" rel="stylesheet">

          			<img class="logo" src="/images/<%=naive_image_chooser("logo", @conn.assigns[:lang])%>">
          			BeyondBOINC

	        	<a href="/authors/<%=@conn.assigns[:about_blog_author]%>/<%=@conn.assigns[:about_blog_permlink]%>" class="item"><%=naive_translate("about", @conn.assigns[:lang])%>

					Trade GRC

							Decentralized Exchanges

							BitSquare

							OpenLedger

							BTSABC

							BTSBOTS

							Bitshares-Light

							Centralized Exchanges

							HolyTransactions

							Poloniex

							C-Cex

							Bittrex

							Explorers

							GridcoinStats

							GridResearchCorp

							Explorer.Gridcoin.Asia

							HolyTransactions

							Exchange stats

							CoinMarketCap

							CoinGecko

							CoinCap

					Community links

							 Gridcoin

									Website

									Forums

									GitHub

									Twitter

									Steemit

									Telegram

									Reddit

									IRC

									Wiki

							 BOINC

									BOINC Website

									BOINC Forums

									FormulaBOINC

									User of the day

									Rechenkraft

									Desktop Grid Federation

									SETI Germany

									SETI USA

							 Bitshares

									Official website

									Forums

									Telegram

									Explorer

							 Peerplays

									Official website

									Telegram

									Peerplays.chat

									GitHub

				<%= if get_flash(@conn, :info) do %>

					<%= get_flash(@conn, :info) %>

<%end %><%= if get_flash(@conn, :error) do %>

					<%= get_flash(@conn, :error) %>

<%end %>

<%= render @view_module, @view_template, assigns %>

Promoted Tags

	            Gridcoin
	            BOINC
	            BeyondBitcoin
	            Cryptocurrency

Promoted Authors

	            CM-Steem
	            OfficialFuzzy
	            Erkan
	            Chris4210

Affiliate links

	            Vultr
	            Namecheap
	            NordVPN
	            Purse.IO

About

BeyondBOINC is a Steemit backed blog, powered by the  Glasnost  library & is actively maintained by @CM-STEEM.

	      <img class="ui centered mini image" src="/images/<%=naive_image_chooser("logo", @conn.assigns[:lang])%>">

	        Home
	        Site Map
	        Gridcoin Chat

<!DOCTYPE html>

	<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
	<meta content="width=device-width, initial-scale=1" name="viewport">
	<meta content="BeyondBOINC displays the recently created content from a curated list of Steemit authors on the topics of cryptocurrency, distributed computing and technology." name="description">
	<meta content="Gridcoin, Bitshares, Steemit, Cryptocurrency, Blog, Aggregator, Glasnost, BOINC, BeyondBitcoin, BeyondBOINC, Distributed Computing, Cloud computing, Science, Peerplays, Blockchain, Decentralization, money, science, technology, crypto" name="keywords">
	<meta content="Customminer aka @cm-steem" name="author">
	<meta content="index, follow" name="robots">
	<meta content="1 days" name="revisit-after">

	<link rel="apple-touch-icon" sizes="57x57" href="/images/apple-icon-57x57.png">
	<link rel="apple-touch-icon" sizes="60x60" href="/images/apple-icon-60x60.png">
	<link rel="apple-touch-icon" sizes="72x72" href="/images/apple-icon-72x72.png">
	<link rel="apple-touch-icon" sizes="76x76" href="/images/apple-icon-76x76.png">
	<link rel="apple-touch-icon" sizes="114x114" href="/images/apple-icon-114x114.png">
	<link rel="apple-touch-icon" sizes="120x120" href="/images/apple-icon-120x120.png">
	<link rel="apple-touch-icon" sizes="144x144" href="/images/apple-icon-144x144.png">
	<link rel="apple-touch-icon" sizes="152x152" href="/images/apple-icon-152x152.png">
	<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-icon-180x180.png">
	<link rel="icon" type="image/png" sizes="192x192"  href="/images/android-icon-192x192.png">
	<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
	<link rel="icon" type="image/png" sizes="96x96" href="/images/favicon-96x96.png">
	<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
	<link rel="manifest" href="/images/manifest.json">
	<meta name="msapplication-TileColor" content="#ffffff">
	<meta name="msapplication-TileImage" content="/images/ms-icon-144x144.png">
	<meta name="theme-color" content="#ffffff">

	<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

	<link href="https://beyondboinc.net" rel="canonical">
	<title>BeyondBOINC: <%= naive_translate("head title", @conn.assigns[:lang])%></title>
 	<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
 	<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.10/semantic.css" rel="stylesheet">

          			<img class="logo" src="/images/<%=naive_image_chooser("logo", @conn.assigns[:lang])%>">
          			BeyondBOINC

	        	<a href="/authors/<%=@conn.assigns[:about_blog_author]%>/<%=@conn.assigns[:about_blog_permlink]%>" class="item"><%=naive_translate("about", @conn.assigns[:lang])%>

					Trade GRC

							Decentralized Exchanges

							BitSquare

							OpenLedger

							BTSABC

							BTSBOTS

							Bitshares-Light

							Centralized Exchanges

							HolyTransactions

							Poloniex

							C-Cex

							Bittrex

							Explorers

							GridcoinStats

							GridResearchCorp

							Explorer.Gridcoin.Asia

							HolyTransactions

							Exchange stats

							CoinMarketCap

							CoinGecko

							CoinCap

					Community links

							 Gridcoin

									Website

									Forums

									GitHub

									Twitter

									Steemit

									Telegram

									Reddit

									IRC

									Wiki

							 BOINC

									BOINC Website

									BOINC Forums

									FormulaBOINC

									User of the day

									Rechenkraft

									Desktop Grid Federation

									SETI Germany

									SETI USA

							 Bitshares

									Official website

									Forums

									Telegram

									Explorer

							 Peerplays

									Official website

									Telegram

									Peerplays.chat

									GitHub

				<gcse:search></gcse:search>

				<%= if get_flash(@conn, :info) do %>

					<%= get_flash(@conn, :info) %>

<%end %><%= if get_flash(@conn, :error) do %>

					<%= get_flash(@conn, :error) %>

<%end %>

<%= render @view_module, @view_template, assigns %>

Promoted Tags

	            Gridcoin
	            BOINC
	            BeyondBitcoin
	            Cryptocurrency

Promoted Authors

	            CM-Steem
	            OfficialFuzzy
	            Erkan
	            Chris4210

Affiliate links

	            Vultr
	            Namecheap
	            NordVPN
	            Purse.IO

About

BeyondBOINC is a Steemit backed blog, powered by the  Glasnost  library & is actively maintained by @CM-STEEM.

	      <img class="ui centered mini image" src="/images/<%=naive_image_chooser("logo", @conn.assigns[:lang])%>">

	        Home
	        Site Map
	        Gridcoin Chat


Add Twitter link

Add Twitter link

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="<%= assigns[:page_description] %>">
    <meta name="author" content="Dataskydd.net">
    <meta name="referrer" content="no-referrer">
    <meta property="og:image" content="<%= Routes.static_path(@conn, "/images/dataskydd_eye2.png") %>">
    <%= if @view_template == "status.html" do %>
      <meta http-equiv="refresh" content="5">
    <% end %>
    <title><%= assigns[:page_title] %> | Webbkoll - dataskydd.net</title>
    <link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>">
    <link rel="apple-touch-icon" sizes="57x57" href="/images/apple-touch-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="114x114" href="/images/apple-touch-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="72x72" href="/images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="144x144" href="/images/apple-touch-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="60x60" href="/images/apple-touch-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="120x120" href="/images/apple-touch-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="76x76" href="/images/apple-touch-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="152x152" href="/images/apple-touch-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-180x180.png">
    <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
    <link rel="icon" type="image/png" href="/images/favicon-160x160.png" sizes="160x160">
    <link rel="icon" type="image/png" href="/images/favicon-96x96.png" sizes="96x96">
    <link rel="icon" type="image/png" href="/images/favicon-16x16.png" sizes="16x16">
    <link rel="icon" type="image/png" href="/images/favicon-32x32.png" sizes="32x32">

    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="msapplication-TileImage" content="/images/mstile-144x144.png">

              <a href="/<%= @conn.assigns.locale %>">

                webbkoll | dataskydd.net

              <%= link gettext("News"), to: Routes.page_path(@conn, :news, @conn.assigns.locale) %>

              <%= link gettext("About"), to: Routes.page_path(@conn, :about, @conn.assigns.locale) %>

              <%= link gettext("FAQ"), to: Routes.page_path(@conn, :faq, @conn.assigns.locale) %>

            <% current_lang = @conn.assigns.locale %>

              <%= link language_from_code(current_lang), to: path_helper(@conn, current_lang), aria_haspopup: "true", class: "language-select" %>

                <%= for lang <- Map.keys(Application.get_env(:webbkoll, :locales)) |> Enum.reject(& &1 == current_lang) do %>

                  <%= link language_from_code(lang), to: path_helper(@conn, lang) %>

                <% end %>

           <form role="search" method="get" action="/<%= @conn.assigns.locale %>/check">
              <input name="url" type="search" placeholder="example.com" aria-label="<%= gettext("URL to check") %>">
              <button type="submit" aria-label="<%= gettext("Search") %>" title="<%= gettext("Search") %>">

              </button>
            </form>

      <%= render @view_module, @view_template, assigns %>

            <%= gettext "Test results are stored in memory on our server for 24 hours. We don't show a list of tested URLs. We don't use URLs or test results. We don't log IP addresses and we don't use cookies." %>

            <%= gettext "Developed by" %> dataskydd.net.

<%= gettext("The code is available on GitHub.") |> raw %>

<%= gettext("Feedback? Questions? info@dataskydd.net") |> raw %>

Twitter: @dataskyddnet

<%= link gettext("Support us"), to: Routes.page_path(@conn, :donate, @conn.assigns.locale) %>

<%= Application.get_env(:webbkoll, :version) %>

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="<%= assigns[:page_description] %>">
    <meta name="author" content="Dataskydd.net">
    <meta name="referrer" content="no-referrer">
    <meta property="og:image" content="<%= Routes.static_path(@conn, "/images/dataskydd_eye2.png") %>">
    <%= if @view_template == "status.html" do %>
      <meta http-equiv="refresh" content="5">
    <% end %>
    <title><%= assigns[:page_title] %> | Webbkoll - dataskydd.net</title>
    <link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>">
    <link rel="apple-touch-icon" sizes="57x57" href="/images/apple-touch-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="114x114" href="/images/apple-touch-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="72x72" href="/images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="144x144" href="/images/apple-touch-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="60x60" href="/images/apple-touch-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="120x120" href="/images/apple-touch-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="76x76" href="/images/apple-touch-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="152x152" href="/images/apple-touch-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-180x180.png">
    <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
    <link rel="icon" type="image/png" href="/images/favicon-160x160.png" sizes="160x160">
    <link rel="icon" type="image/png" href="/images/favicon-96x96.png" sizes="96x96">
    <link rel="icon" type="image/png" href="/images/favicon-16x16.png" sizes="16x16">
    <link rel="icon" type="image/png" href="/images/favicon-32x32.png" sizes="32x32">

    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="msapplication-TileImage" content="/images/mstile-144x144.png">

              <a href="/<%= @conn.assigns.locale %>">

                webbkoll | dataskydd.net

              <%= link gettext("News"), to: Routes.page_path(@conn, :news, @conn.assigns.locale) %>

              <%= link gettext("About"), to: Routes.page_path(@conn, :about, @conn.assigns.locale) %>

              <%= link gettext("FAQ"), to: Routes.page_path(@conn, :faq, @conn.assigns.locale) %>

            <% current_lang = @conn.assigns.locale %>

              <%= link language_from_code(current_lang), to: path_helper(@conn, current_lang), aria_haspopup: "true", class: "language-select" %>

                <%= for lang <- Map.keys(Application.get_env(:webbkoll, :locales)) |> Enum.reject(& &1 == current_lang) do %>

                  <%= link language_from_code(lang), to: path_helper(@conn, lang) %>

                <% end %>

           <form role="search" method="get" action="/<%= @conn.assigns.locale %>/check">
              <input name="url" type="search" placeholder="example.com" aria-label="<%= gettext("URL to check") %>">
              <button type="submit" aria-label="<%= gettext("Search") %>" title="<%= gettext("Search") %>">

              </button>
            </form>

      <%= render @view_module, @view_template, assigns %>

            <%= gettext "Test results are stored in memory on our server for 24 hours. We don't show a list of tested URLs. We don't use URLs or test results. We don't log IP addresses and we don't use cookies." %>

            <%= gettext "Developed by" %> dataskydd.net.

<%= gettext("The code is available on GitHub.") |> raw %>

<%= gettext("Feedback? Questions? info@dataskydd.net") |> raw %>

<%= link gettext("Support us"), to: Routes.page_path(@conn, :donate, @conn.assigns.locale) %>

<%= Application.get_env(:webbkoll, :version) %>


add styling to the admin page

add styling to the admin page

  <%= if @password_saved do %>

 Visit your admin link

    <% else %>

            Password
            <input placeholder="<%= @password %>" readonly="" type="text">

      <%= form_tag "/admin/mark_password_as_saved", [csrf_token: true] do %>
      <%= submit "Submit", class: "ui submit button" %>

    <% end %>
  <% end %>

  <%= if @password_saved do %>

 Visit your admin link

    <% else %>

 Your password is: <%= @password %>

      <%= form_tag "/admin/mark_password_as_saved", [csrf_token: true] do %>
      <%= submit "Submit" %>
    <% end %>
  <% end %>


Replace +1 from phone number

Replace +1 from phone number

<%# Prefix is either "From" or "To" %>
<%# Address1 is actually line 2 %>
<%# Zip4 can be blank %>
<% prefix = String.capitalize("#{@address}") %>
<% address = Map.get(@shipment, @address) %>

<%= if @shipment.international? do %>
  <<%= prefix %>FirstName><%= address.first_name %></<%= prefix %>FirstName>
  <<%= prefix %>LastName><%= address.last_name %></<%= prefix %>LastName>
<% else %>
  <<%= prefix %>Name><%= address.first_name %> <%= address.last_name %></<%= prefix %>Name>
<% end %>

<<%= prefix %>Firm><%= address.company_name %></<%= prefix %>Firm>
<<%= prefix %>Address1><%= address.address_line_2 %></<%= prefix %>Address1>
<<%= prefix %>Address2><%= address.address %></<%= prefix %>Address2>
<<%= prefix %>City><%= address.city %></<%= prefix %>City>

<%= if @shipment.international? and @address == :to do %>
  <<%= prefix %>Province><%= address.state %></<%= prefix %>Province>
  <<%= prefix %>Country><%= Util.abbreviation_to_country_name(address.country) %></<%= prefix %>Country>
  <<%= prefix %>PostalCode><%= address.zip %></<%= prefix %>PostalCode>
  <<%= prefix %>POBoxFlag>N</<%= prefix %>POBoxFlag>
  <<%= prefix %>Phone><%= address.phone %></<%= prefix %>Phone>
<% else %>
  <<%= prefix %>State><%= address.state %></<%= prefix %>State>
  <<%= prefix %>Zip5><%= address.zip %></<%= prefix %>Zip5>
  <<%= prefix %>Zip4></<%= prefix %>Zip4>
  <<%= prefix %>Phone><%= address.phone |> String.replace(~r/^\+1/, "") |> String.replace(~r/\D+/, "") %></<%= prefix %>Phone>
<% end %>

<%# Prefix is either "From" or "To" %>
<%# Address1 is actually line 2 %>
<%# Zip4 can be blank %>
<% prefix = String.capitalize("#{@address}") %>
<% address = Map.get(@shipment, @address) %>

<%= if @shipment.international? do %>
  <<%= prefix %>FirstName><%= address.first_name %></<%= prefix %>FirstName>
  <<%= prefix %>LastName><%= address.last_name %></<%= prefix %>LastName>
<% else %>
  <<%= prefix %>Name><%= address.first_name %> <%= address.last_name %></<%= prefix %>Name>
<% end %>

<<%= prefix %>Firm><%= address.company_name %></<%= prefix %>Firm>
<<%= prefix %>Address1><%= address.address_line_2 %></<%= prefix %>Address1>
<<%= prefix %>Address2><%= address.address %></<%= prefix %>Address2>
<<%= prefix %>City><%= address.city %></<%= prefix %>City>

<%= if @shipment.international? and @address == :to do %>
  <<%= prefix %>Province><%= address.state %></<%= prefix %>Province>
  <<%= prefix %>Country><%= Util.abbreviation_to_country_name(address.country) %></<%= prefix %>Country>
  <<%= prefix %>PostalCode><%= address.zip %></<%= prefix %>PostalCode>
  <<%= prefix %>POBoxFlag>N</<%= prefix %>POBoxFlag>
  <<%= prefix %>Phone><%= address.phone %></<%= prefix %>Phone>
<% else %>
  <<%= prefix %>State><%= address.state %></<%= prefix %>State>
  <<%= prefix %>Zip5><%= address.zip %></<%= prefix %>Zip5>
  <<%= prefix %>Zip4></<%= prefix %>Zip4>
  <<%= prefix %>Phone><%= String.replace(address.phone, ~r/\D+/, "") %></<%= prefix %>Phone>
<% end %>


Correct vertical alignment of companies in trusted-by section

  <iframe scrolling="no" frameborder="0" allowtransparency="true" class="twitter-share-button twitter-share-button-rendered twitter-tweet-button" style="position: static; visibility: visible; width: 61px; height: 20px;" title="Twitter Tweet Button" src="https://platform.twitter.com/widgets/tweet_button.2e798283373a8137c24e277b9b9620d6.en.html#dnt=false&id=twitter-widget-0&lang=en&original_referer=https%3A%2F%2Fsemantic-ui.com%2F&size=m&text=I%20%E2%9D%A4%20RemoteRetro!%20Like,%20big%20time.&time=1519956156939&type=share&url=http%3A%2F%2Fremoteretro.org&via=StrideDev&hashtags=myelixirstatus,opensource" data-url="http://remoteretro.org">

    Remote

    Retro

    Get Better With Your Team

RemoteRetro lets you get together, even when you're far apart.

    Sign in with Google to Get Started

            Free!

Costs less than a song!

            Collaborative!

Interact with teammates in real time!

            Guided!

A retro on rails!

            Completely Open Source!

            GitHub

Trusted By

        Sign in with Google to Get Started

        F.A.Q.


Make erl_connect executable

Make erl_connect executable

#!/usr/bin/env bash

# This uses `$app@localhost` address to connect to the erlang node.
# That is meant to be executed from the same machine where the erlang node lives
#
# To connect to your app from another machine, you should set the same cookie
# for both, set node's name to sommething like `$app@$IPaddr`
# and ensure networks are visible.

#     To connect (interactive elixir, using app's own `iex`):
#     ```
#         erl -remsh $app@localhost -sname connector
#         # and then ...
#         ($app@localhost)1> 'Elixir.IEx':start().
#     ```

app="<%= app %>"
cookie="<%= cookie %>"
dir="/home/$user/$app/current"

# connect with interactive erlang via iex
cmd="erl -env ERL_LIBS $dir/lib -name connector@127.0.0.1 -remsh $app@127.0.0.1 -setcookie $cookie"
$cmd

########################################
#
#     Some ways to run your app:
#
#     To run (embedded erlang):
#     ```
#         run_erl -daemon /home/$user/$app/pipes/ /home/$user/$app/log
#           "erl -boot $dir/boot/start
#                -config $dir/boot/sys
#                -env ERL_LIBS $dir/lib
#                -sname $app"
#     ```
#
#     To connect (embedded erlang):
#     ```
#         to_erl /home/$user/$app/pipes/erlang.pipe.1
#     ```
#
#     To run (interactive erlang):
#     ```
#         erl -boot $dir/boot/start
#             -config $dir/boot/sys
#             -env ERL_LIBS $dir/lib
#             -name $app@localhost
#     ```
#
#     To run (interactive elixir, using app's own `iex`):
#     ```
#         erl -boot $dir/boot/start
#             -config $dir/boot/sys
#             -env ERL_LIBS $dir/lib
#             -name $app@localhost
#             -noshell -user Elixir.IEx.CLI -extra --no-halt
#     ```
#
#     To run (detached elixir):
#     ```
#         iex --erl "-boot $dir/boot/start
#                    -config $dir/boot/sys
#                    -env ERL_LIBS $dir/lib"
#             --name $app@localhost
#             --detached
#     ```
#
#     To run (detached erlang):
#     ```
#         erl -boot $dir/boot/start
#             -config $dir/boot/sys
#             -env ERL_LIBS $dir/lib
#             -name $app@localhost
#             -detached
#     ```
#
#     To connect (interactive elixir):
#     ```
#         iex --remsh $app@localhost --sname connector
#     ```
#
#     To connect (interactive erlang):
#     ```
#         erl -remsh $app@localhost -sname connector
#     ```
#
#     To connect (interactive elixir, using app's own `iex`):
#     ```
#         erl -remsh $app@localhost -sname connector
#         # and then ...
#         ($app@localhost)1> 'Elixir.IEx':start().
#     ```
#


recommendation timestamp format

recommendation timestamp format

<%= if @podcast.recommendations != [] do %>

      Recommendations
      <%= complain_link() %>

      <%= for recommendation <- @podcast.recommendations do %>

          <%= recommendation.user.name %>: <%= recommendation.comment %>

            <%= Timex.format!(@recommendation.inserted_at, "{ISOdate} {h24}:{m}") %>

      <% end %>

<% end %>

<%= if @podcast.recommendations != [] do %>

      Recommendations
      <%= complain_link() %>

      <%= for recommendation <- @podcast.recommendations do %>

          <%= recommendation.user.name %>: <%= recommendation.comment %>
          <%= recommendation.inserted_at %>

      <% end %>

<% end %>


fix end date label

fix end date label

<%= form_for @changeset, @action, fn f -> %>
  <%= if @changeset.action do %>

Oops, something went wrong! Please check the errors below.

  <% end %>

    <%= label f, :name, class: "control-label" %>
    <%= text_input f, :name, class: "form-control" %>
    <%= error_tag f, :name %>

    <%= label f, :start_date, class: "control-label" %>
    <%= datetime_select f, :start_date, class: "form-control" %>
    <%= error_tag f, :start_date %>

    <%= label f, :end_date, class: "control-label" %>
    <%= datetime_select f, :end_date, class: "form-control" %>
    <%= error_tag f, :end_date %>

    <%= submit "Submit", class: "btn btn-primary" %>

<% end %>

<%= form_for @changeset, @action, fn f -> %>
  <%= if @changeset.action do %>

Oops, something went wrong! Please check the errors below.

  <% end %>

    <%= label f, :name, class: "control-label" %>
    <%= text_input f, :name, class: "form-control" %>
    <%= error_tag f, :name %>

    <%= label f, :start_date, class: "control-label" %>
    <%= datetime_select f, :start_date, class: "form-control" %>
    <%= error_tag f, :start_date %>

    <%= label f, :start_date, class: "control-label" %>
    <%= datetime_select f, :end_date, class: "form-control" %>
    <%= error_tag f, :start_date %>

    <%= submit "Submit", class: "btn btn-primary" %>

<% end %>


Silence output from WHERE

Silence output from WHERE

:: Discover the current release directory from the directory
:: of this script and the start_erl.data file
@echo off
set script_dir=%~dp0
for %%A in ("%script_dir%\..") do (
  set release_root_dir=%%~fA
)
set rel_name=<%= release_name %>
set rel_vsn=<%= release_version %>
set boot_script=%release_root_dir%\releases\%rel_vsn%\%rel_name%.ps1

:: Use pwsh.exe rather than powershell.exe if available
set prog=powershell
where pwsh >nul 2>nul
if %ERRORLEVEL% eq 0 (
  set prog=pwsh
)
%prog% -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command "& "%boot_script%" @args" %*

:: Discover the current release directory from the directory
:: of this script and the start_erl.data file
@echo off
set script_dir=%~dp0
for %%A in ("%script_dir%\..") do (
  set release_root_dir=%%~fA
)
set rel_name=<%= release_name %>
set rel_vsn=<%= release_version %>
set boot_script=%release_root_dir%\releases\%rel_vsn%\%rel_name%.ps1

:: Use pwsh.exe rather than powershell.exe if available
set prog=powershell
where pwsh
if %ERRORLEVEL% eq 0 (
  set prog=pwsh
)
%prog% -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command "& "%boot_script%" @args" %*


chipped away at new form year ranges are now up to current year, need to switch to date ranges so up to current date

Create Skill

<%= form_for @conn, skill_path(@conn, :create), [as: :skill], fn f  -> %>

    <%= label f, :name, class: "control-label" %>
    <%= text_input f, :name, class: "form-control", required: "" %>
    <%= error_tag f, :name %>

    <%= label f, :category, class: "control-label" %>
    <%= text_input f, :category, class: "form-control", required: "" %>
    <%= error_tag f, :category %>

    <%= label f, :description, class: "control-label" %>
    <%= text_input f, :description, class: "form-control", required: "" %>
    <%= error_tag f, :description %>

    <%= label f, :start_date, class: "control-label" %>
    <%= date_select f, :start_date, year: [options: (DateTime.utc_now.year - 100)..DateTime.utc_now.year] %>
    <%= error_tag f, :start_date %>

    <%= label f, :end_date, class: "control-label" %>
    <%= date_select f, :end_date , year: [options: (DateTime.utc_now.year - 100)..DateTime.utc_now.year] %>
    <%= error_tag f, :end_date %>

    <%= submit "Create Skill", class: "btn btn-primary" %>
    <%= link "Cancel", to: registration_path(@conn, :show), class: "btn" %>

<% end %>

Create Skill

<%= form_for @conn, skill_path(@conn, :create), [as: :skill], fn f  -> %>

    <%= label f, :name, class: "control-label" %>
    <%= text_input f, :name, class: "form-control", required: "" %>
    <%= error_tag f, :name %>

    <%= label f, :description, class: "control-label" %>
    <%= password_input f, :description, class: "form-control", required: "" %>
    <%= error_tag f, :description %>

    <%= submit "Create Skill", class: "btn btn-primary" %>
    <%= link "Cancel", to: registration_path(@conn, :show), class: "btn" %>

<% end %>


Simplify HTML structure in app layout

Simplify HTML structure in app layout

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title><%= gettext("Jumu Nordost") %></title>

    <link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i" rel="stylesheet">
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
  </head>

  <body>
    <header class="header">
      <%= render "nav.html", conn: @conn, current_user: @current_user %>
    </header>

    <main role="main" class="container">
      <%= if assigns[:breadcrumbs] do %>
        <%= render "breadcrumbs.html", conn: @conn, breadcrumbs: @breadcrumbs %>
      <% end %>

      <%= render "flash.html", conn: @conn %>

      <%= render @view_module, @view_template, assigns %>
    </main>

    <script src="<%= static_path(@conn, "/js/app.js") %>"></script>
    <%= render_existing @view_module, "scripts." <> @view_template, assigns %>
  </body>
</html>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title><%= gettext("Jumu Nordost") %></title>

    <link href="https://fonts.googleapis.com/css?family=Lato:300,300i,400,400i,700,700i" rel="stylesheet">
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
  </head>

  <body>
    <div class="container">
      <header class="header">
        <%= render "nav.html", conn: @conn, current_user: @current_user %>
      </header>

      <%= if assigns[:breadcrumbs] do %>
        <%= render "breadcrumbs.html", conn: @conn, breadcrumbs: @breadcrumbs %>
      <% end %>

      <%= render "flash.html", conn: @conn %>

      <main role="main">
        <%= render @view_module, @view_template, assigns %>
      </main>
    </div>

    <script src="<%= static_path(@conn, "/js/app.js") %>"></script>
    <%= render_existing @view_module, "scripts." <> @view_template, assigns %>
  </body>
</html>


Use our URLs on the XML

Use our URLs on the XML

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title><%= gettext("Elixir Jobs") %></title>
    <description><%= gettext "Find your next Elixir job." %></description>
    <link><%= offer_url(@conn, :index) %></link>
    <%= for offer <- @offers do %>
      <item>
        <title><![CDATA[<%= xml_strip_tags(offer.title) %>]]></title>
        <description><![CDATA[

              <%= gettext "Job place:" %> <%= HumanizeHelper.human_get_place(offer.job_place, gettext("Unknown")) %>

              <%= gettext "Job type:" %> <%= HumanizeHelper.human_get_type(offer.job_type, gettext("Unknown")) %>

              <%= gettext "Job location:" %> <%= xml_strip_tags(offer.location) %>

          <%= offer.summary %>
        ]]></description>
        <pubDate><%= xml_readable_date(offer.inserted_at) %></pubDate>
        <link><%= offer_url(@conn, :show, offer.slug) %></link>
        <guid><%= offer_url(@conn, :show, offer.slug) %></guid>
      </item>
    <% end %>
  </channel>
</rss>

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title><%= gettext("Elixir Jobs") %></title>
    <description><%= gettext "Find your next Elixir job." %></description>
    <link><%= offer_url(@conn, :index) %></link>
    <%= for offer <- @offers do %>
      <item>
        <title><![CDATA[<%= xml_strip_tags(offer.title) %>]]></title>
        <description><![CDATA[

              <%= gettext "Job place:" %> <%= HumanizeHelper.human_get_place(offer.job_place, gettext("Unknown")) %>

              <%= gettext "Job type:" %> <%= HumanizeHelper.human_get_type(offer.job_type, gettext("Unknown")) %>

              <%= gettext "Job location:" %> <%= xml_strip_tags(offer.location) %>

          <%= offer.summary %>
        ]]></description>
        <pubDate><%= xml_readable_date(offer.inserted_at) %></pubDate>
        <link><%= offer.url %></link>
        <guid><%= offer.url %></guid>
      </item>
    <% end %>
  </channel>
</rss>


Fixed typo in boot.eex comments (#172)

Fixed typo in boot.eex comments (#172)

#!/bin/sh

set -e

# Set VERBOSE to enable verbose logging of the boot script
#VERBOSE=true
if [ ! -z $DEBUG_BOOT ]; then
    set -x
fi;

my_readlink_f() {
    TARGET_FILE="$1"
    cd $(dirname "$TARGET_FILE")
    TARGET_FILE=$(basename "$TARGET_FILE")

    # Iterate down a (possible) chain of symlinks
    while [ -L "$TARGET_FILE" ]
    do
        TARGET_FILE=$(readlink "$TARGET_FILE")
        cd $(dirname "$TARGET_FILE")
        TARGET_FILE=$(basename "$TARGET_FILE")
    done
    # Compute the canonicalized name by finding the physical path
    # for the directory we're in and appending the target file.
    PHYS_DIR=$(pwd -P)
    RESULT="$PHYS_DIR/$TARGET_FILE"
    echo "$RESULT"
}

# Path to this script
if uname | grep -q 'Darwin'; then
  # on OSX, best to install coreutils from homebrew or similar
  # to get greadlink
  if command -v greadlink >/dev/null 2>&1; then
    SCRIPT=$(greadlink -f "$0")
  else
    SCRIPT=$(my_readlink_f "$0" )
  fi
else
  SCRIPT=$(readlink -f "$0" )
fi

# Parent directory of this script
SCRIPT_DIR=$(dirname "${SCRIPT}")
# Root directory of all releases
RELEASE_ROOT_DIR=$(dirname $(dirname ${SCRIPT_DIR}))

# Disable flow control for run_erl
# Flow control can cause several problems. On Linux, if you
# accidentally hit Ctrl-S (instead of Ctrl-D to detach) and
# then some other key, the entire beam process will hang when
# attempting to write to stdout. On Solaris, the beam process
# will hang on writing if ScrollLock is on.
RUN_ERL_DISABLE_FLOWCNTRL="${RUN_ERL_DISABLE_FLOWCNTRL:-true}"
# Name of the release
REL_NAME="<%= release_name %>"
# Current version of the release
REL_VSN="<%= release_version %>"
# Current version of ERTS being used
# If this is not present/unset, it will be detected
<%= if ((is_binary(include_erts) or include_erts) and not is_nil(erts_vsn)) do %>ERTS_VSN="<%= erts_vsn %>"<% end %>
# VM code loading mode, embedded by default, can also be interactive
# See http://erlang.org/doc/man/code.html
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
# Path to start_erl.data
START_ERL_DATA="$RELEASE_ROOT_DIR/releases/start_erl.data"
# Directory containing the current version of this release
REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN"
# The lib directory for this release
REL_LIB_DIR="$RELEASE_ROOT_DIR/lib"
# Options passed to erl
ERL_OPTS="<%= release.profile.erl_opts %>"
# When stdout is piped to a file, this is the directory those files will
# be stored in. defaults to /log in the release root directory

# RELEASE_MUTABLE_DIR
RELEASE_MUTABLE_DIR="${RELEASE_MUTABLE_DIR:-$RELEASE_ROOT_DIR/var}"

RUNNER_LOG_DIR="${RUNNER_LOG_DIR:-$RELEASE_MUTABLE_DIR/log}"
# A string of extra options to pass to erl, here for plugins
EXTRA_OPTS=""

# Pre-start/stop event hook paths
PRE_START_HOOKS="$REL_DIR/hooks/pre_start.d"
POST_START_HOOKS="$REL_DIR/hooks/post_start.d"
PRE_STOP_HOOKS="$REL_DIR/hooks/pre_stop.d"
POST_STOP_HOOKS="$REL_DIR/hooks/post_stop.d"
PRE_UPGRADE_HOOKS="$REL_DIR/hooks/pre_upgrade.d"
POST_UPGRADE_HOOKS="$REL_DIR/hooks/post_upgrade.d"

# Get node pid
get_pid() {
    if output="$(nodetool rpcterms os getpid)"
    then
        echo "$output" | sed -e 's/"//g'
        return 0
    else
        echo "$output"
        return 1
    fi
}

# Generate a unique nodename
gen_nodename() {
    id="longname$(gen_id)-${NAME}"
    "$BINDIR/erl" -boot start_clean -eval '[Host] = tl(string:tokens(atom_to_list(node()),"@")), io:format("~s~n", [Host]), halt()' -noshell ${NAME_TYPE} $id
}

# Generate a random id
gen_id() {
    od -t x -N 4 /dev/urandom | head -n1 | awk '{print $2}'
}

# Control a node
# Use like `nodetool "ping"`
nodetool() {
    command="$1"; shift
    name=${PEERNAME:-$NAME}
    "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$name" \
                            -setcookie "$COOKIE" "$command" $@
}

# Run an escript in the node's environment
# Use like `escript "path/to/escript"`
escript() {
    shift; scriptpath="$1"; shift
    export RELEASE_ROOT_DIR

    "$ERTS_DIR/bin/escript" "$ROOTDIR/$scriptpath" $@
}

# Private. Load target cookie, either from vm.args or $HOME/.cookie
_load_cookie() {
    COOKIE_ARG="$(grep '^-setcookie' "$VMARGS_PATH" || true)"
    DEFAULT_COOKIE_FILE="$HOME/.erlang.cookie"
    if [ -z "$COOKIE_ARG" ]; then
        if [ -f "$DEFAULT_COOKIE_FILE" ]; then
            COOKIE="$(cat "$DEFAULT_COOKIE_FILE")"
        fi
    else
        # Extract cookie name from COOKIE_ARG
        COOKIE="$(echo "$COOKIE_ARG" | awk '{print $2}')"
    fi
}

# Private. Ensure that cookie is set.
_check_cookie() {
    # Attempt reloading cookie in case it has been set in a hook
    if [ -z "$COOKIE" ]; then
        _load_cookie
    fi
    # Die if cookie is still not set, as connecting via distribution will fail
    if [ -z "$COOKIE" ]; then
        printf "a secret cookie must be provided in one of the following ways:\n  - with vm.args using the -setcookie parameter,\n  or\n  by writing the cookie to '$DEFAULT_COOKIE_FILE', with permissions set to 0400"
        exit 1
    fi
}

# Private. For determining the version of ERTS available to the release
# This is only ever called if ERTS_VSN is not set
_detect_erts_vsn() {
    set +e # temporarily disable so we can display a nice error message to the user
    __erl="$(which erl)"
    set -e
    if [ -z "${__erl}"  ]; then
        echo 'erlang runtime not found. If erlang is installed check your $PATH. aborting.'
        exit 1
    fi
    "$__erl" -boot start_clean -eval 'Ver = erlang:system_info(version), io:format("~s~n", [Ver]), halt()' -noshell
}

# Private. Gets a list of code paths for this release
_get_code_paths() {
    "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/release_utils.escript" "get_code_paths" "$ROOTDIR" "$ERTS_DIR" "$REL_NAME" "$REL_VSN"
}

# Private. For setting ERTS_DIR and ROOTDIR
_find_erts_dir() {
    __erts_dir="$RELEASE_ROOT_DIR/erts-$ERTS_VSN"
    if [ -d "$__erts_dir" ]; then
        ERTS_DIR="$__erts_dir";
        ROOTDIR="$RELEASE_ROOT_DIR"
    else
        set +e # temporarily disable so we can display a nice error message to the user
        __erl="$(which erl)"
        set -e
        if [ -z "${__erl}"  ]; then
          echo 'erlang runtime not found. If erlang is installed check your $PATH. aborting.'
          exit 1
        fi
        code="io:format(\"~s\", [code:root_dir()]), halt()."
        __erl_root="$("$__erl" -noshell -eval "$code")"
        ERTS_DIR="$__erl_root/erts-$ERTS_VSN"
        ROOTDIR="$__erl_root"
    fi
}

# Private. Open a shell on a remote node
_rem_sh() {
    # Generate a unique id used to allow multiple remsh to the same node
    # transparently
    id="remsh$(gen_id)-${NAME}"

    # Get the node's ticktime so that we use the same thing.
    TICKTIME="$(nodetool rpcterms net_kernel get_net_ticktime)"

    # Setup remote shell command to control node
    if [ ! -z "$USE_ERL_SHELL" ]; then
        exec "$BINDIR/erl" \
            -hidden \
            -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -kernel net_ticktime $TICKTIME \
            "$NAME_TYPE" "$id" -remsh "$NAME" -setcookie "$COOKIE"
    else
        __code_paths=$(_get_code_paths)
        exec "$BINDIR/erl" \
            -pa "$CONSOLIDATED_DIR" \
            ${__code_paths} \
            -hidden -noshell \
            -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -kernel net_ticktime $TICKTIME \
            -user Elixir.IEx.CLI "$NAME_TYPE" "$id" -setcookie "$COOKIE" \
            -extra --no-halt +iex -"$NAME_TYPE" "$id" --cookie "$COOKIE" --remsh "$NAME"
    fi
}

# Output a start command for the last argument of run_erl
_start_command() {
    printf "exec \"%s\" \"%s\" -- %s %s" "$RELEASE_ROOT_DIR/bin/$REL_NAME" \
           "$START_OPTION" "${ARGS}" "${EXTRA_OPTS}"
}

# Do a textual replacement of ${VAR} occurrences in $1 and pipe to $2
_replace_os_vars() {
    awk '
        function escape(s) {
            gsub(/'\&'/, "\\\\&", s);
            return s;
        }
        {
            while(match($0,"[$]{[^}]*}")) {
                var=substr($0,RSTART+2,RLENGTH-3);
                gsub("[$]{"var"}", escape(ENVIRON[var]))
            }
        }1' < "$1" > "$1.bak"
    mv -- "$1.bak" "$1"
}

# Private. Run hooks from directory.
_run_hooks_from_dir() {
   if [ -d "$1" ]; then
      for file in $1/[0-9a-zA-Z]*.sh; do
        [ -f "$file" ] || continue
        . "$file"
      done
   fi
}

# If TERM is not set, set it to xterm
if [ -z "$TERM" ]; then
    export TERM=xterm
fi

# If ERTS_VSN is not set, detect it
if [ -z "$ERTS_VSN" ]; then
    ERTS_VSN="$(_detect_erts_vsn)"
    echo "$ERTS_VSN $REL_VSN" > "$START_ERL_DATA"
fi

# Allow override of where to read configuration from
# By default it's RELEASE_ROOT_DIR
if [ -z "$RELEASE_CONFIG_DIR" ]; then
    RELEASE_CONFIG_DIR="$RELEASE_ROOT_DIR"
fi

# Make sure directories exist
mkdir -p "$RELEASE_MUTABLE_DIR"
echo "Files in this directory are regenerated frequently, edits will be lost" \
    > "$RELEASE_MUTABLE_DIR/WARNING_README"
mkdir -p "$RUNNER_LOG_DIR"

# Set VMARGS_PATH, the path to the vm.args file to use
# Use $RELEASE_CONFIG_DIR/vm.args if exists, otherwise releases/VSN/vm.args
if [ -z "$VMARGS_PATH" ]; then
    if [ -f "$RELEASE_CONFIG_DIR/vm.args" ]; then
        VMARGS_PATH="$RELEASE_CONFIG_DIR/vm.args"
    else
        VMARGS_PATH="$REL_DIR/vm.args"
    fi
fi
if [ "$VMARGS_PATH" != "$RELEASE_MUTABLE_DIR/vm.args" ]; then
    echo "#### Generated - edit/create $RELEASE_CONFIG_DIR/vm.args instead." \
        >  "$RELEASE_MUTABLE_DIR/vm.args"
    cat  "$VMARGS_PATH"                              \
        >> "$RELEASE_MUTABLE_DIR/vm.args"
    VMARGS_PATH=$RELEASE_MUTABLE_DIR/vm.args
fi
if [ $REPLACE_OS_VARS ]; then
    _replace_os_vars "$VMARGS_PATH"
fi

# Set SYS_CONFIG_PATH, the path to the sys.config file to use
# Use $RELEASE_CONFIG_DIR/sys.config if exists, otherwise releases/VSN/sys.config
if [ -z "$SYS_CONFIG_PATH" ]; then
    if [ -f "$RELEASE_CONFIG_DIR/sys.config" ]; then
        SYS_CONFIG_PATH="$RELEASE_CONFIG_DIR/sys.config"
    else
        SYS_CONFIG_PATH="$REL_DIR/sys.config"
    fi
fi
if [ "$SYS_CONFIG_PATH" != "$RELEASE_MUTABLE_DIR/sys.config" ]; then
    echo "%% Generated - edit/create $RELEASE_CONFIG_DIR/sys.config instead." \
        >  "$RELEASE_MUTABLE_DIR/sys.config"
    cat  "$SYS_CONFIG_PATH"                              \
        >> "$RELEASE_MUTABLE_DIR/sys.config"
    SYS_CONFIG_PATH=$RELEASE_MUTABLE_DIR/sys.config
fi
if [ $REPLACE_OS_VARS ]; then
    _replace_os_vars "$SYS_CONFIG_PATH"
fi

# Extract the target node name from node.args
# Should be `-sname somename` or `-name somename@somehost`
NAME_ARG=$(egrep '^-s?name' "$VMARGS_PATH" || true)
if [ -z "$NAME_ARG" ]; then
    echo "vm.args needs to have either -name or -sname parameter."
    exit 1
fi

# Extract the name type and name from the NAME_ARG for REMSH
# NAME_TYPE should be -name or -sname
NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')"
# NAME will be either `somename` or `somename@somehost`
NAME="$(echo "$NAME_ARG" | awk '{print $2}')"

# Where the pipe will be stored when using `start`
# This is used so you can attach the running application to the current
# shell using `attach`
PIPE_DIR="${PIPE_DIR:-$RELEASE_MUTABLE_DIR/erl_pipes/$NAME/}"

# Extract the target cookie
_load_cookie

_find_erts_dir
export ROOTDIR="$RELEASE_ROOT_DIR"
export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
ERTS_LIB_DIR="$ERTS_DIR/../lib"
CONSOLIDATED_DIR="$ROOTDIR/lib/${REL_NAME}-${REL_VSN}/consolidated"

cd "$ROOTDIR"

# User can specify an sname without @hostname
# This will fail when creating remote shell
# So here we check for @ and add @hostname if missing
case $NAME in
    *@*)
        # Nothing to do
        ;;
    *)
        NAME=$NAME@$(gen_nodename)
        ;;
esac

# For Elixir runtime
export DISTILLERY_TASK="$1"

# Check the first argument for instructions
case "$1" in
    start|start_boot)

        # Make sure there is not already a node running
        #RES=`$NODETOOL ping`
        #if [ "$RES" = "pong" ]; then
        #    echo "Node is already running!"
        #    exit 1
        #fi
        # Save this for later.
        CMD=$1
        case "$1" in
            start)
                shift
                START_OPTION="console"
                HEART_OPTION="start"
                ;;
            start_boot)
                shift
                START_OPTION="console_boot"
                HEART_OPTION="start_boot"
                ;;
        esac
        ARGS="$@"
        RUN_PARAM="$@"

        _check_cookie
        _run_hooks_from_dir "$PRE_START_HOOKS"

        # Set arguments for the heart command
        set -- "$SCRIPT_DIR/$REL_NAME" "$HEART_OPTION"
        [ "$RUN_PARAM" ] && set -- "$@" "$RUN_PARAM"

        # Export the HEART_COMMAND
        HEART_COMMAND="$RELEASE_ROOT_DIR/bin/$REL_NAME $CMD"
        export HEART_COMMAND

        mkdir -p "$PIPE_DIR"

        "$BINDIR/run_erl" -daemon "$PIPE_DIR" "$RUNNER_LOG_DIR" \
                          "$(_start_command)"

        _run_hooks_from_dir "$POST_START_HOOKS"
        ;;

    stop)
        _check_cookie
        _run_hooks_from_dir "$PRE_STOP_HOOKS"
        # Wait for the node to completely stop...
        PID="$(get_pid)"
        if ! nodetool "stop"; then
            exit 1
        fi
        while $(kill -s 0 "$PID" 2>/dev/null);
        do
            sleep 1
        done
        _run_hooks_from_dir "$POST_STOP_HOOKS"
        ;;

    restart)
        _check_cookie
        _run_hooks_from_dir "$PRE_START_HOOKS"
        ## Restart the VM without exiting the process
        if ! nodetool "restart"; then
            exit 1
        fi
        ;;

    reboot)
        _check_cookie
        _run_hooks_from_dir "$PRE_START_HOOKS"
        ## Restart the VM completely (uses heart to restart it)
        if ! nodetool "reboot"; then
            exit 1
        fi
        ;;

    pid)
        ## Get the VM's pid
        _check_cookie
        if ! get_pid; then
            exit 1
        fi
        ;;

    ping)
        _check_cookie
        ## See if the VM is alive
        if ! nodetool "ping"; then
            exit 1
        fi
        ;;

    pingpeer)
        PEERNAME=$2 nodetool "ping"
        exit_status=$?
        if [ "$exit_status" -ne 0 ]; then
            exit $exit_status
        fi
        ;;

    escript)
        _check_cookie
        ## Run an escript under the node's environment
        if ! escript $@; then
            exit 1
        fi
        ;;

    attach)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        exec "$BINDIR/to_erl" "$PIPE_DIR"
        ;;

    remote_console)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        _rem_sh
        ;;

    upgrade|downgrade|install)
        if [ -z "$2" ]; then
            echo "Missing package argument"
            echo "Usage: $REL_NAME $1 {package base name}"
            echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
            exit 1
        fi

        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        SOURCE_VERSION="$REL_VSN"
        TARGET_VERSION="$2"

        "$BINDIR/escript" "$ROOTDIR/bin/release_utils.escript" \
             "unpack_release" "$REL_NAME" "$NAME_TYPE"  "$NAME" "$COOKIE" "$TARGET_VERSION"

        _run_hooks_from_dir "$PRE_UPGRADE_HOOKS"

        "$BINDIR/escript" "$ROOTDIR/bin/release_utils.escript" \
             "install_release" "$REL_NAME" "$NAME_TYPE"  "$NAME" "$COOKIE" "$TARGET_VERSION"

        _run_hooks_from_dir "$POST_UPGRADE_HOOKS"

        ;;
    unpack)
        if [ -z "$2" ]; then
            echo "Missing package argument"
            echo "Usage: $REL_NAME $1 {package base name}"
            echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
            exit 1
        fi

        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        exec "$BINDIR/escript" "$ROOTDIR/bin/release_utils.escript" \
             "unpack_release" "$REL_NAME" "$NAME_TYPE" "$NAME" "$COOKIE" "$2"
        ;;

    console|console_clean|console_boot)
        # .boot file typically just $REL_NAME (ie, the app name)
        # however, for debugging, sometimes start_clean.boot is useful.
        # For e.g. 'setup', one may even want to name another boot script.
        case "$1" in
            console)
                if [ -f "$REL_DIR/$REL_NAME.boot" ]; then
                  BOOTFILE="$REL_DIR/$REL_NAME"
                else
                  BOOTFILE="$REL_DIR/start"
                fi
                ;;
            console_clean)
                BOOTFILE="$ROOTDIR/bin/start_clean"
                __code_paths=$(_get_code_paths)
                EXTRA_CODE_PATHS=${__code_paths}
                ;;
            console_boot)
                shift
                BOOTFILE="$1"
                shift
                ;;
        esac
        # Setup beam-required vars
        EMU="beam"
        PROGNAME="${0#*/}"

        export EMU
        export PROGNAME

        # Store passed arguments since they will be erased by `set`
        ARGS="$@"

        _check_cookie

        # Start the VM, executing pre_start hook along
        # the way. We can't run the post_start hook because
        # the console will crash with no TTY attached
        _run_hooks_from_dir "$PRE_START_HOOKS"

        # Build an array of arguments to pass to exec later on
        # Build it here because this command will be used for logging.
        set -- "$BINDIR/erlexec" \
            -boot "$BOOTFILE" \
            -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -env ERL_LIBS "$REL_LIB_DIR" \
            -pa "$CONSOLIDATED_DIR" \
            ${EXTRA_CODE_PATHS} \
            -args_file "$VMARGS_PATH" \
            -config "$SYS_CONFIG_PATH" \
            -mode "$CODE_LOADING_MODE" \
            ${ERL_OPTS} \
            -user Elixir.IEx.CLI \
            -extra --no-halt +iex

        # Dump environment info for logging purposes
        if [ ! -z $VERBOSE ]; then
            echo "Exec: $@" -- ${1+$ARGS} ${EXTRA_OPTS}
            echo "Root: $ROOTDIR"

            # Log the startup
            echo "$RELEASE_ROOT_DIR"
        fi;

        logger -t "$REL_NAME[$$]" "Starting up"

        exec "$@" -- ${1+$ARGS} ${EXTRA_OPTS}
        ;;

    foreground)
        # start up the release in the foreground for use by runit
        # or other supervision services

        [ -f "$REL_DIR/$REL_NAME.boot" ] && BOOTFILE="$REL_NAME" || BOOTFILE=start
        FOREGROUNDOPTIONS="-noshell -noinput +Bd"

        # Setup beam-required vars
        EMU=beam
        PROGNAME="${0#*/}"

        export EMU
        export PROGNAME

        # Store passed arguments since they will be erased by `set`
        ARGS="$@"

        _check_cookie

        # Start the VM, executing pre and post start hooks
        _run_hooks_from_dir "$PRE_START_HOOKS"

        # Build an array of arguments to pass to exec later on
        # Build it here because this command will be used for logging.
        set -- "$BINDIR/erlexec" $FOREGROUNDOPTIONS \
            -boot "$REL_DIR/$BOOTFILE" \
            -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -env ERL_LIBS "$REL_LIB_DIR" \
            -pa "$CONSOLIDATED_DIR" \
            -args_file "$VMARGS_PATH" \
            -config "$SYS_CONFIG_PATH" \
            -mode "$CODE_LOADING_MODE" \
            ${ERL_OPTS} \
            -extra ${EXTRA_OPTS}

        # Dump environment info for logging purposes
        if [ ! -z $VERBOSE ]; then
            echo "Exec: $@" -- ${1+$ARGS}
            echo "Root: $ROOTDIR"
        fi;

        "$@" -- ${1+$ARGS} &
        __bg_pid=$!
        _run_hooks_from_dir "$POST_START_HOOKS"
        wait $__bg_pid
        ;;
    rpc)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift

        nodetool rpc $@
        ;;
    rpcterms)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift

        nodetool rpcterms $@
        ;;
    eval)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        nodetool "eval" $@
        ;;
    command)
        # Execute as command-line utility
        #
        # Like the escript command, this does not start the OTP application.
        # If your command depends on a running OTP application,
        # use
        #
        #     {:ok, _} = Application.ensure_all_started(:your_app)

        _check_cookie

        shift
        MODULE="$1"; shift
        FUNCTION="$1"; shift

        # Save extra arguments
        ARGS="$@"

        # Build arguments for erlexec
        __code_paths=$(_get_code_paths)
        set -- "$ERL_OPTS"
        [ "$SYS_CONFIG_PATH" ] && set -- "$@" -config "$SYS_CONFIG_PATH"
        set -- "$@" -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR"
        set -- "$@" -noshell
        set -- "$@" -boot start_clean
        set -- "$@" -pa "$CONSOLIDATED_DIR"
        set -- "$@" ${__code_paths}
        set -- "$@" -s "$MODULE" "$FUNCTION"

        $BINDIR/erlexec $@ -extra $ARGS
        exit "$?"
        ;;
    describe)
        ## Print a summary of information about this release
        echo "$REL_NAME-$REL_VSN\n"
        echo "erts:       $ERTS_VSN"
        echo "path:       $REL_DIR"
        echo "sys.config: $SYS_CONFIG_PATH"
        echo "vm.args:    $VMARGS_PATH"
        echo "name:       $NAME"
        echo "cookie:     $COOKIE"
        echo "erl_opts:   ${ERL_OPTS:-none provided}"
        echo ""
        echo "hooks:"
        __has_hooks=0
        for hook in "$REL_DIR"/hooks/*.d/[0-9a-zA-Z]*.sh; do
            [ -f "$hook" ] || continue
            __has_hooks=1
            echo "$hook"
        done
        if [ $__has_hooks -eq 0 ]; then
            echo "No custom hooks found."
        fi
        echo ""
        echo "commands:"
        __has_commands=0
        for command in "$REL_DIR"/commands/*.sh; do
            [ -f "$command" ] || continue
            __has_commands=1
            echo "$command"
        done
        if [ $__has_commands -eq 0 ]; then
            echo "No custom commands found."
        fi
        exit 0
        ;;
    *)
        __command_path="$REL_DIR/commands/$1"
        if [ -f "$__command_path" ]; then
            _check_cookie
            . "$__command_path"
        else
            echo "Usage: $REL_NAME {start|start_boot <file>|foreground|stop|restart|reboot|pid|ping|pingpeer|console|console_clean|console_boot <file>|attach|remote_console|upgrade|downgrade|install|escript|rpc|rpcterms|eval|command <module> <function> <args>}|describe"
            exit 1
        fi
        ;;
esac

exit 0

#!/bin/sh

set -e

# Set VERBOSE to enable verbose logging of the boot script
#VERBOSE=true
if [ ! -z $DEBUG_BOOT ]; then
    set -x
fi;

my_readlink_f() {
    TARGET_FILE="$1"
    cd $(dirname "$TARGET_FILE")
    TARGET_FILE=$(basename "$TARGET_FILE")

    # Iterate down a (possible) chain of symlinks
    while [ -L "$TARGET_FILE" ]
    do
        TARGET_FILE=$(readlink "$TARGET_FILE")
        cd $(dirname "$TARGET_FILE")
        TARGET_FILE=$(basename "$TARGET_FILE")
    done
    # Compute the canonicalized name by finding the physical path
    # for the directory we're in and appending the target file.
    PHYS_DIR=$(pwd -P)
    RESULT="$PHYS_DIR/$TARGET_FILE"
    echo "$RESULT"
}

# Path to this script
if uname | grep -q 'Darwin'; then
  # on OSX, best to install coreutils from homebrew or similar
  # to get greadlink
  if command -v greadlink >/dev/null 2>&1; then
    SCRIPT=$(greadlink -f "$0")
  else
    SCRIPT=$(my_readlink_f "$0" )
  fi
else
  SCRIPT=$(readlink -f "$0" )
fi

# Parent directory of this script
SCRIPT_DIR=$(dirname "${SCRIPT}")
# Root directory of all releases
RELEASE_ROOT_DIR=$(dirname $(dirname ${SCRIPT_DIR}))

# Disable flow control for run_erl
# Flow control can cause several problems. On Linux, if you
# accidentally hit Ctrl-S (instead of Ctrl-D to detach) and
# then some other key, the entire beam process will hang when
# attempting to write to stdout. On Solaris, the beam process
# will hang on writing if ScrollLock is on.
RUN_ERL_DISABLE_FLOWCNTRL="${RUN_ERL_DISABLE_FLOWCNTRL:-true}"
# Name of the release
REL_NAME="<%= release_name %>"
# Current version of the release
REL_VSN="<%= release_version %>"
# Current version of ERTS being used
# If this is not present/unset, it will be detected
<%= if ((is_binary(include_erts) or include_erts) and not is_nil(erts_vsn)) do %>ERTS_VSN="<%= erts_vsn %>"<% end %>
# VM code loading mode, embedded by default, can also be interactive
# See http://erlang.org/doc/man/code.html
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
# Path to start_erl.data
START_ERL_DATA="$RELEASE_ROOT_DIR/releases/start_erl.data"
# Directory containing the current version of this release
REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN"
# The lib directory for this release
REL_LIB_DIR="$RELEASE_ROOT_DIR/lib"
# Options passed to erl
ERL_OPTS="<%= release.profile.erl_opts %>"
# When stdout is piped to a file, this is the directory those files will
# be stored in. defaults to /log in the release root directory

# RELEASE_MUTABLE_DIR
RELEASE_MUTABLE_DIR="${RELEASE_MUTABLE_DIR:-$RELEASE_ROOT_DIR/var}"

RUNNER_LOG_DIR="${RUNNER_LOG_DIR:-$RELEASE_MUTABLE_DIR/log}"
# A string of extra options to pass to erl, here for plugins
EXTRA_OPTS=""

# Pre-start/stop event hook paths
PRE_START_HOOKS="$REL_DIR/hooks/pre_start.d"
POST_START_HOOKS="$REL_DIR/hooks/post_start.d"
PRE_STOP_HOOKS="$REL_DIR/hooks/pre_stop.d"
POST_STOP_HOOKS="$REL_DIR/hooks/post_stop.d"
PRE_UPGRADE_HOOKS="$REL_DIR/hooks/pre_upgrade.d"
POST_UPGRADE_HOOKS="$REL_DIR/hooks/post_upgrade.d"

# Get node pid
get_pid() {
    if output="$(nodetool rpcterms os getpid)"
    then
        echo "$output" | sed -e 's/"//g'
        return 0
    else
        echo "$output"
        return 1
    fi
}

# Generate a unique nodename
gen_nodename() {
    id="longname$(gen_id)-${NAME}"
    "$BINDIR/erl" -boot start_clean -eval '[Host] = tl(string:tokens(atom_to_list(node()),"@")), io:format("~s~n", [Host]), halt()' -noshell ${NAME_TYPE} $id
}

# Generate a random id
gen_id() {
    od -t x -N 4 /dev/urandom | head -n1 | awk '{print $2}'
}

# Control a node
# Use like `nodetool "ping"`
nodetool() {
    command="$1"; shift
    name=${PEERNAME:-$NAME}
    "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$name" \
                            -setcookie "$COOKIE" "$command" $@
}

# Run an escript in the node's environment
# Use like `escript "path/to/escript"`
escript() {
    shift; scriptpath="$1"; shift
    export RELEASE_ROOT_DIR

    "$ERTS_DIR/bin/escript" "$ROOTDIR/$scriptpath" $@
}

# Private. Load target cookie, either from vm.args or $HOME/.cookie
_load_cookie() {
    COOKIE_ARG="$(grep '^-setcookie' "$VMARGS_PATH" || true)"
    DEFAULT_COOKIE_FILE="$HOME/.erlang.cookie"
    if [ -z "$COOKIE_ARG" ]; then
        if [ -f "$DEFAULT_COOKIE_FILE" ]; then
            COOKIE="$(cat "$DEFAULT_COOKIE_FILE")"
        fi
    else
        # Extract cookie name from COOKIE_ARG
        COOKIE="$(echo "$COOKIE_ARG" | awk '{print $2}')"
    fi
}

# Private. Ensure that cookie is set.
_check_cookie() {
    # Attempt reloading cookie in case it has been set in a hook
    if [ -z "$COOKIE" ]; then
        _load_cookie
    fi
    # Die if cookie is still not set, as connecting via distribution will fail
    if [ -z "$COOKIE" ]; then
        printf "a secret cookie must be provided in one of the following ways:\n  - with vm.args using the -setcookie parameter,\n  or\n  by writing the cookie to '$DEFAULT_COOKIE_FILE', with permissions set to 0400"
        exit 1
    fi
}

# Private. For determining the version of ERTS available to the release
# This is only ever called if ERTS_VSN is not set
_detect_erts_vsn() {
    set +e # temporarily disable so we can display a nice error message to the user
    __erl="$(which erl)"
    set -e
    if [ -z "${__erl}"  ]; then
        echo 'erlang runtime not found. If erlang is installed check your $PATH. aborting.'
        exit 1
    fi
    "$__erl" -boot start_clean -eval 'Ver = erlang:system_info(version), io:format("~s~n", [Ver]), halt()' -noshell
}

# Private. Gets a list of code paths for this release
_get_code_paths() {
    "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/release_utils.escript" "get_code_paths" "$ROOTDIR" "$ERTS_DIR" "$REL_NAME" "$REL_VSN"
}

# Private. For setting ERTS_DIR and ROOTDIR
_find_erts_dir() {
    __erts_dir="$RELEASE_ROOT_DIR/erts-$ERTS_VSN"
    if [ -d "$__erts_dir" ]; then
        ERTS_DIR="$__erts_dir";
        ROOTDIR="$RELEASE_ROOT_DIR"
    else
        set +e # temporarily disable so we can display a nice error message to the user
        __erl="$(which erl)"
        set -e
        if [ -z "${__erl}"  ]; then
          echo 'erlang runtime not found. If erlang is installed check your $PATH. aborting.'
          exit 1
        fi
        code="io:format(\"~s\", [code:root_dir()]), halt()."
        __erl_root="$("$__erl" -noshell -eval "$code")"
        ERTS_DIR="$__erl_root/erts-$ERTS_VSN"
        ROOTDIR="$__erl_root"
    fi
}

# Private. Open a shell on a remote node
_rem_sh() {
    # Generate a unique id used to allow multiple remsh to the same node
    # transparently
    id="remsh$(gen_id)-${NAME}"

    # Get the node's ticktime so that we use the same thing.
    TICKTIME="$(nodetool rpcterms net_kernel get_net_ticktime)"

    # Setup remote shell command to control node
    if [ ! -z "$USE_ERL_SHELL" ]; then
        exec "$BINDIR/erl" \
            -hidden \
            -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -kernel net_ticktime $TICKTIME \
            "$NAME_TYPE" "$id" -remsh "$NAME" -setcookie "$COOKIE"
    else
        __code_paths=$(_get_code_paths)
        exec "$BINDIR/erl" \
            -pa "$CONSOLIDATED_DIR" \
            ${__code_paths} \
            -hidden -noshell \
            -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -kernel net_ticktime $TICKTIME \
            -user Elixir.IEx.CLI "$NAME_TYPE" "$id" -setcookie "$COOKIE" \
            -extra --no-halt +iex -"$NAME_TYPE" "$id" --cookie "$COOKIE" --remsh "$NAME"
    fi
}

# Output a start command for the last argument of run_erl
_start_command() {
    printf "exec \"%s\" \"%s\" -- %s %s" "$RELEASE_ROOT_DIR/bin/$REL_NAME" \
           "$START_OPTION" "${ARGS}" "${EXTRA_OPTS}"
}

# Do a textual replacement of ${VAR} occurances in $1 and pipe to $2
_replace_os_vars() {
    awk '
        function escape(s) {
            gsub(/'\&'/, "\\\\&", s);
            return s;
        }
        {
            while(match($0,"[$]{[^}]*}")) {
                var=substr($0,RSTART+2,RLENGTH-3);
                gsub("[$]{"var"}", escape(ENVIRON[var]))
            }
        }1' < "$1" > "$1.bak"
    mv -- "$1.bak" "$1"
}

# Private. Run hooks from directory.
_run_hooks_from_dir() {
   if [ -d "$1" ]; then
      for file in $1/[0-9a-zA-Z]*.sh; do
        [ -f "$file" ] || continue
        . "$file"
      done
   fi
}

# If TERM is not set, set it to xterm
if [ -z "$TERM" ]; then
    export TERM=xterm
fi

# If ERTS_VSN is not set, detect it
if [ -z "$ERTS_VSN" ]; then
    ERTS_VSN="$(_detect_erts_vsn)"
    echo "$ERTS_VSN $REL_VSN" > "$START_ERL_DATA"
fi

# Allow override of where to read configuration from
# By default it's RELEASE_ROOT_DIR
if [ -z "$RELEASE_CONFIG_DIR" ]; then
    RELEASE_CONFIG_DIR="$RELEASE_ROOT_DIR"
fi

# Make sure directories exist
mkdir -p "$RELEASE_MUTABLE_DIR"
echo "Files in this directory are regenerated frequently, edits will be lost" \
    > "$RELEASE_MUTABLE_DIR/WARNING_README"
mkdir -p "$RUNNER_LOG_DIR"

# Set VMARGS_PATH, the path to the vm.args file to use
# Use $RELEASE_CONFIG_DIR/vm.args if exists, otherwise releases/VSN/vm.args
if [ -z "$VMARGS_PATH" ]; then
    if [ -f "$RELEASE_CONFIG_DIR/vm.args" ]; then
        VMARGS_PATH="$RELEASE_CONFIG_DIR/vm.args"
    else
        VMARGS_PATH="$REL_DIR/vm.args"
    fi
fi
if [ "$VMARGS_PATH" != "$RELEASE_MUTABLE_DIR/vm.args" ]; then
    echo "#### Generated - edit/create $RELEASE_CONFIG_DIR/vm.args instead." \
        >  "$RELEASE_MUTABLE_DIR/vm.args"
    cat  "$VMARGS_PATH"                              \
        >> "$RELEASE_MUTABLE_DIR/vm.args"
    VMARGS_PATH=$RELEASE_MUTABLE_DIR/vm.args
fi
if [ $REPLACE_OS_VARS ]; then
    _replace_os_vars "$VMARGS_PATH"
fi

# Set SYS_CONFIG_PATH, the path to the sys.config file to use
# Use $RELEASE_CONFIG_DIR/sys.config if exists, otherwise releases/VSN/sys.config
if [ -z "$SYS_CONFIG_PATH" ]; then
    if [ -f "$RELEASE_CONFIG_DIR/sys.config" ]; then
        SYS_CONFIG_PATH="$RELEASE_CONFIG_DIR/sys.config"
    else
        SYS_CONFIG_PATH="$REL_DIR/sys.config"
    fi
fi
if [ "$SYS_CONFIG_PATH" != "$RELEASE_MUTABLE_DIR/sys.config" ]; then
    echo "%% Generated - edit/create $RELEASE_CONFIG_DIR/sys.config instead." \
        >  "$RELEASE_MUTABLE_DIR/sys.config"
    cat  "$SYS_CONFIG_PATH"                              \
        >> "$RELEASE_MUTABLE_DIR/sys.config"
    SYS_CONFIG_PATH=$RELEASE_MUTABLE_DIR/sys.config
fi
if [ $REPLACE_OS_VARS ]; then
    _replace_os_vars "$SYS_CONFIG_PATH"
fi

# Extract the target node name from node.args
# Should be `-sname somename` or `-name somename@somehost`
NAME_ARG=$(egrep '^-s?name' "$VMARGS_PATH" || true)
if [ -z "$NAME_ARG" ]; then
    echo "vm.args needs to have either -name or -sname parameter."
    exit 1
fi

# Extract the name type and name from the NAME_ARG for REMSH
# NAME_TYPE should be -name or -sname
NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')"
# NAME will be either `somename` or `somename@somehost`
NAME="$(echo "$NAME_ARG" | awk '{print $2}')"

# Where the pipe will be stored when using `start`
# This is used so you can attach the running application to the current
# shell using `attach`
PIPE_DIR="${PIPE_DIR:-$RELEASE_MUTABLE_DIR/erl_pipes/$NAME/}"

# Extract the target cookie
_load_cookie

_find_erts_dir
export ROOTDIR="$RELEASE_ROOT_DIR"
export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
ERTS_LIB_DIR="$ERTS_DIR/../lib"
CONSOLIDATED_DIR="$ROOTDIR/lib/${REL_NAME}-${REL_VSN}/consolidated"

cd "$ROOTDIR"

# User can specify an sname without @hostname
# This will fail when creating remote shell
# So here we check for @ and add @hostname if missing
case $NAME in
    *@*)
        # Nothing to do
        ;;
    *)
        NAME=$NAME@$(gen_nodename)
        ;;
esac

# For Elixir runtime
export DISTILLERY_TASK="$1"

# Check the first argument for instructions
case "$1" in
    start|start_boot)

        # Make sure there is not already a node running
        #RES=`$NODETOOL ping`
        #if [ "$RES" = "pong" ]; then
        #    echo "Node is already running!"
        #    exit 1
        #fi
        # Save this for later.
        CMD=$1
        case "$1" in
            start)
                shift
                START_OPTION="console"
                HEART_OPTION="start"
                ;;
            start_boot)
                shift
                START_OPTION="console_boot"
                HEART_OPTION="start_boot"
                ;;
        esac
        ARGS="$@"
        RUN_PARAM="$@"

        _check_cookie
        _run_hooks_from_dir "$PRE_START_HOOKS"

        # Set arguments for the heart command
        set -- "$SCRIPT_DIR/$REL_NAME" "$HEART_OPTION"
        [ "$RUN_PARAM" ] && set -- "$@" "$RUN_PARAM"

        # Export the HEART_COMMAND
        HEART_COMMAND="$RELEASE_ROOT_DIR/bin/$REL_NAME $CMD"
        export HEART_COMMAND

        mkdir -p "$PIPE_DIR"

        "$BINDIR/run_erl" -daemon "$PIPE_DIR" "$RUNNER_LOG_DIR" \
                          "$(_start_command)"

        _run_hooks_from_dir "$POST_START_HOOKS"
        ;;

    stop)
        _check_cookie
        _run_hooks_from_dir "$PRE_STOP_HOOKS"
        # Wait for the node to completely stop...
        PID="$(get_pid)"
        if ! nodetool "stop"; then
            exit 1
        fi
        while $(kill -s 0 "$PID" 2>/dev/null);
        do
            sleep 1
        done
        _run_hooks_from_dir "$POST_STOP_HOOKS"
        ;;

    restart)
        _check_cookie
        _run_hooks_from_dir "$PRE_START_HOOKS"
        ## Restart the VM without exiting the process
        if ! nodetool "restart"; then
            exit 1
        fi
        ;;

    reboot)
        _check_cookie
        _run_hooks_from_dir "$PRE_START_HOOKS"
        ## Restart the VM completely (uses heart to restart it)
        if ! nodetool "reboot"; then
            exit 1
        fi
        ;;

    pid)
        ## Get the VM's pid
        _check_cookie
        if ! get_pid; then
            exit 1
        fi
        ;;

    ping)
        _check_cookie
        ## See if the VM is alive
        if ! nodetool "ping"; then
            exit 1
        fi
        ;;

    pingpeer)
        PEERNAME=$2 nodetool "ping"
        exit_status=$?
        if [ "$exit_status" -ne 0 ]; then
            exit $exit_status
        fi
        ;;

    escript)
        _check_cookie
        ## Run an escript under the node's environment
        if ! escript $@; then
            exit 1
        fi
        ;;

    attach)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        exec "$BINDIR/to_erl" "$PIPE_DIR"
        ;;

    remote_console)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        _rem_sh
        ;;

    upgrade|downgrade|install)
        if [ -z "$2" ]; then
            echo "Missing package argument"
            echo "Usage: $REL_NAME $1 {package base name}"
            echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
            exit 1
        fi

        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        SOURCE_VERSION="$REL_VSN"
        TARGET_VERSION="$2"

        "$BINDIR/escript" "$ROOTDIR/bin/release_utils.escript" \
             "unpack_release" "$REL_NAME" "$NAME_TYPE"  "$NAME" "$COOKIE" "$TARGET_VERSION"

        _run_hooks_from_dir "$PRE_UPGRADE_HOOKS"

        "$BINDIR/escript" "$ROOTDIR/bin/release_utils.escript" \
             "install_release" "$REL_NAME" "$NAME_TYPE"  "$NAME" "$COOKIE" "$TARGET_VERSION"

        _run_hooks_from_dir "$POST_UPGRADE_HOOKS"

        ;;
    unpack)
        if [ -z "$2" ]; then
            echo "Missing package argument"
            echo "Usage: $REL_NAME $1 {package base name}"
            echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
            exit 1
        fi

        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        exec "$BINDIR/escript" "$ROOTDIR/bin/release_utils.escript" \
             "unpack_release" "$REL_NAME" "$NAME_TYPE" "$NAME" "$COOKIE" "$2"
        ;;

    console|console_clean|console_boot)
        # .boot file typically just $REL_NAME (ie, the app name)
        # however, for debugging, sometimes start_clean.boot is useful.
        # For e.g. 'setup', one may even want to name another boot script.
        case "$1" in
            console)
                if [ -f "$REL_DIR/$REL_NAME.boot" ]; then
                  BOOTFILE="$REL_DIR/$REL_NAME"
                else
                  BOOTFILE="$REL_DIR/start"
                fi
                ;;
            console_clean)
                BOOTFILE="$ROOTDIR/bin/start_clean"
                __code_paths=$(_get_code_paths)
                EXTRA_CODE_PATHS=${__code_paths}
                ;;
            console_boot)
                shift
                BOOTFILE="$1"
                shift
                ;;
        esac
        # Setup beam-required vars
        EMU="beam"
        PROGNAME="${0#*/}"

        export EMU
        export PROGNAME

        # Store passed arguments since they will be erased by `set`
        ARGS="$@"

        _check_cookie

        # Start the VM, executing pre_start hook along
        # the way. We can't run the post_start hook because
        # the console will crash with no TTY attached
        _run_hooks_from_dir "$PRE_START_HOOKS"

        # Build an array of arguments to pass to exec later on
        # Build it here because this command will be used for logging.
        set -- "$BINDIR/erlexec" \
            -boot "$BOOTFILE" \
            -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -env ERL_LIBS "$REL_LIB_DIR" \
            -pa "$CONSOLIDATED_DIR" \
            ${EXTRA_CODE_PATHS} \
            -args_file "$VMARGS_PATH" \
            -config "$SYS_CONFIG_PATH" \
            -mode "$CODE_LOADING_MODE" \
            ${ERL_OPTS} \
            -user Elixir.IEx.CLI \
            -extra --no-halt +iex

        # Dump environment info for logging purposes
        if [ ! -z $VERBOSE ]; then
            echo "Exec: $@" -- ${1+$ARGS} ${EXTRA_OPTS}
            echo "Root: $ROOTDIR"

            # Log the startup
            echo "$RELEASE_ROOT_DIR"
        fi;

        logger -t "$REL_NAME[$$]" "Starting up"

        exec "$@" -- ${1+$ARGS} ${EXTRA_OPTS}
        ;;

    foreground)
        # start up the release in the foreground for use by runit
        # or other supervision services

        [ -f "$REL_DIR/$REL_NAME.boot" ] && BOOTFILE="$REL_NAME" || BOOTFILE=start
        FOREGROUNDOPTIONS="-noshell -noinput +Bd"

        # Setup beam-required vars
        EMU=beam
        PROGNAME="${0#*/}"

        export EMU
        export PROGNAME

        # Store passed arguments since they will be erased by `set`
        ARGS="$@"

        _check_cookie

        # Start the VM, executing pre and post start hooks
        _run_hooks_from_dir "$PRE_START_HOOKS"

        # Build an array of arguments to pass to exec later on
        # Build it here because this command will be used for logging.
        set -- "$BINDIR/erlexec" $FOREGROUNDOPTIONS \
            -boot "$REL_DIR/$BOOTFILE" \
            -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -env ERL_LIBS "$REL_LIB_DIR" \
            -pa "$CONSOLIDATED_DIR" \
            -args_file "$VMARGS_PATH" \
            -config "$SYS_CONFIG_PATH" \
            -mode "$CODE_LOADING_MODE" \
            ${ERL_OPTS} \
            -extra ${EXTRA_OPTS}

        # Dump environment info for logging purposes
        if [ ! -z $VERBOSE ]; then
            echo "Exec: $@" -- ${1+$ARGS}
            echo "Root: $ROOTDIR"
        fi;

        "$@" -- ${1+$ARGS} &
        __bg_pid=$!
        _run_hooks_from_dir "$POST_START_HOOKS"
        wait $__bg_pid
        ;;
    rpc)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift

        nodetool rpc $@
        ;;
    rpcterms)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift

        nodetool rpcterms $@
        ;;
    eval)
        _check_cookie

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        nodetool "eval" $@
        ;;
    command)
        # Execute as command-line utility
        #
        # Like the escript command, this does not start the OTP application.
        # If your command depends on a running OTP application,
        # use
        #
        #     {:ok, _} = Application.ensure_all_started(:your_app)

        _check_cookie

        shift
        MODULE="$1"; shift
        FUNCTION="$1"; shift

        # Save extra arguments
        ARGS="$@"

        # Build arguments for erlexec
        __code_paths=$(_get_code_paths)
        set -- "$ERL_OPTS"
        [ "$SYS_CONFIG_PATH" ] && set -- "$@" -config "$SYS_CONFIG_PATH"
        set -- "$@" -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR"
        set -- "$@" -noshell
        set -- "$@" -boot start_clean
        set -- "$@" -pa "$CONSOLIDATED_DIR"
        set -- "$@" ${__code_paths}
        set -- "$@" -s "$MODULE" "$FUNCTION"

        $BINDIR/erlexec $@ -extra $ARGS
        exit "$?"
        ;;
    describe)
        ## Print a summary of information about this release
        echo "$REL_NAME-$REL_VSN\n"
        echo "erts:       $ERTS_VSN"
        echo "path:       $REL_DIR"
        echo "sys.config: $SYS_CONFIG_PATH"
        echo "vm.args:    $VMARGS_PATH"
        echo "name:       $NAME"
        echo "cookie:     $COOKIE"
        echo "erl_opts:   ${ERL_OPTS:-none provided}"
        echo ""
        echo "hooks:"
        __has_hooks=0
        for hook in "$REL_DIR"/hooks/*.d/[0-9a-zA-Z]*.sh; do
            [ -f "$hook" ] || continue
            __has_hooks=1
            echo "$hook"
        done
        if [ $__has_hooks -eq 0 ]; then
            echo "No custom hooks found."
        fi
        echo ""
        echo "commands:"
        __has_commands=0
        for command in "$REL_DIR"/commands/*.sh; do
            [ -f "$command" ] || continue
            __has_commands=1
            echo "$command"
        done
        if [ $__has_commands -eq 0 ]; then
            echo "No custom commands found."
        fi
        exit 0
        ;;
    *)
        __command_path="$REL_DIR/commands/$1"
        if [ -f "$__command_path" ]; then
            _check_cookie
            . "$__command_path"
        else
            echo "Usage: $REL_NAME {start|start_boot <file>|foreground|stop|restart|reboot|pid|ping|pingpeer|console|console_clean|console_boot <file>|attach|remote_console|upgrade|downgrade|install|escript|rpc|rpcterms|eval|command <module> <function> <args>}|describe"
            exit 1
        fi
        ;;
esac

exit 0


Change link to embedded feedback form

Change link to embedded feedback form

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noindex">

    <title>Action for Children</title>
    <link href="https://fonts.googleapis.com/css?family=Rubik:400,500" rel="stylesheet">
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">

            This is a trial service. We'd appreciate your <%= link "feedback", to: page_path(@conn, :feedback), class: "white" %>. It will take less than 5 minutes.

          <a href="<%= page_path(@conn, :index) %>">

          <%= unless (@conn.assigns[:user] || @conn.request_path == "/talk-to-us") do %>
            Speak to us
          <% end %>

        <%= render @view_module, @view_template, assigns %>

Contact your local council if you are worried about a child's welfare. Contact 111 if you are worried about your child's health, or 999 in a medical emergency.

          <%= if @conn.assigns[:user] do %>

You are logged in as <%= @conn.assigns.user.email %> –

                <%= link "Logout", to: session_path(@conn, :delete), class: "white" %>

          <% end %>
          <%= link to: page_path(@conn, :privacy), class: "white" do %>
            Privacy Policy
          <% end %>

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noindex">

    <title>Action for Children</title>
    <link href="https://fonts.googleapis.com/css?family=Rubik:400,500" rel="stylesheet">
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">

            This is a trial service. We'd appreciate your feedback. It will take less than 5 minutes.

          <a href="<%= page_path(@conn, :index) %>">

          <%= unless (@conn.assigns[:user] || @conn.request_path == "/talk-to-us") do %>
            Speak to us
          <% end %>

        <%= render @view_module, @view_template, assigns %>

Contact your local council if you are worried about a child's welfare. Contact 111 if you are worried about your child's health, or 999 in a medical emergency.

          <%= if @conn.assigns[:user] do %>

You are logged in as <%= @conn.assigns.user.email %> –

                <%= link "Logout", to: session_path(@conn, :delete), class: "white" %>

          <% end %>
          <%= link to: page_path(@conn, :privacy), class: "white" do %>
            Privacy Policy
          <% end %>


Update backend server location

Update backend server location

    <%= gettext "Server location" %>
    <%= anchor_link("server-location") %>

    <%= if @site.geolocation do %>

<%= gettext(~s|The server %{domain} (%{host_ip}) appears to have been located in %{country} during our test.|, domain: @site.host, host_ip: @site.host_ip, country: country_from_iso(@conn.assigns.locale, @site.geolocation)) |> raw %>

    <% else %>

<%= gettext("Server location for %{domain} (%{host_ip}) could not be determined.", domain: @site.host, host_ip: @site.host_ip) |> raw %>

    <% end %>

<%= gettext(~s|See more information (e.g., provider) about this IP address using KeyCDN's tool.|, ip: @site.host_ip) |> raw() %>

<%= icon(:warn) %> <%= gettext(~s|Some sites use CDNs – content delivery networks – in which case the server location might vary depending on the location of the visitor. This tool, Webbkoll, is currently on a server in Finland.|) |> raw %>

<%= icon(:law) %> <%= gettext(~s|Under the GDPR, all EU/EEA countries are considered equally trustworthy, so there is no particular reason under the GDPR to consider any EU country more or less reliable or desirable than any other. The importance of the location of a server comes into play only under GDPR %{art_23}, Restrictions, where member states may invoke a number of reasons, notably national security, that enable them to void protections for visitors or web service providers.|, art_23: gdpr(~w|art 23|)) |> raw() %>

      <%= gettext(~s|For non-EU/EEA territories, it depends (GDPR %{art_44}). For a website, transfers will probably have to rely on adequacy decisions (%{art_45}) made by the European Commission when a third territory has been deemed to have appropriate data protection safe guards in its legislation. However, adequacy decisions cannot always be trusted, as demonstrated in the EU Court of Justice 2015 (C-362/14). Binding corporate rules (%{art_47}) or standard clauses (%{art_46}) may also be used to transfer data, but in the absence of rulings by courts and data protection authorities this is still legally uncertain territory.|,
      art_44: gdpr(~w|art 44|),
      art_45: gdpr(~w|art 45|),
      art_46: gdpr(~w|art 46|),
      art_47: gdpr(~w|art 47|)
      ) |> raw() %>

    <%= gettext "Server location" %>
    <%= anchor_link("server-location") %>

    <%= if @site.geolocation do %>

<%= gettext(~s|The server %{domain} (%{host_ip}) appears to have been located in %{country} during our test.|, domain: @site.host, host_ip: @site.host_ip, country: country_from_iso(@conn.assigns.locale, @site.geolocation)) |> raw %>

    <% else %>

<%= gettext("Server location for %{domain} (%{host_ip}) could not be determined.", domain: @site.host, host_ip: @site.host_ip) |> raw %>

    <% end %>

<%= gettext(~s|See more information (e.g., provider) about this IP address using KeyCDN's tool.|, ip: @site.host_ip) |> raw() %>

<%= icon(:warn) %> <%= gettext(~s|Some sites use CDNs – content delivery networks – in which case the server location might vary depending on the location of the visitor. This tool, Webbkoll, is currently on a server in France.|) |> raw %>

<%= icon(:law) %> <%= gettext(~s|Under the GDPR, all EU/EEA countries are considered equally trustworthy, so there is no particular reason under the GDPR to consider any EU country more or less reliable or desirable than any other. The importance of the location of a server comes into play only under GDPR %{art_23}, Restrictions, where member states may invoke a number of reasons, notably national security, that enable them to void protections for visitors or web service providers.|, art_23: gdpr(~w|art 23|)) |> raw() %>

      <%= gettext(~s|For non-EU/EEA territories, it depends (GDPR %{art_44}). For a website, transfers will probably have to rely on adequacy decisions (%{art_45}) made by the European Commission when a third territory has been deemed to have appropriate data protection safe guards in its legislation. However, adequacy decisions cannot always be trusted, as demonstrated in the EU Court of Justice 2015 (C-362/14). Binding corporate rules (%{art_47}) or standard clauses (%{art_46}) may also be used to transfer data, but in the absence of rulings by courts and data protection authorities this is still legally uncertain territory.|,
      art_44: gdpr(~w|art 44|),
      art_45: gdpr(~w|art 45|),
      art_46: gdpr(~w|art 46|),
      art_47: gdpr(~w|art 47|)
      ) |> raw() %>