8095: Make install guide bundle commands more consistent.
authorBrett Smith <brett@curoverse.com>
Thu, 31 Dec 2015 16:23:34 +0000 (11:23 -0500)
committerBrett Smith <brett@curoverse.com>
Tue, 5 Jan 2016 19:53:23 +0000 (14:53 -0500)
* Always instruct the user to use `sudo -u`.  This prevents the
  commands from generating cache files that the web server can't write
  later.
* Always execute the command in the server's main directory.  This
  helps people run on automatic: if they leave a shell session open at
  the API server directory, they can paste in a combination of Rails
  console and script commands without `cd`ing around.
* Always give both RVM and non-RVM instructions.  There might be a
  good way to streamline this, e.g., by telling them to use rvmsudo
  when available, but that can be a later optimization.

doc/_includes/_install_rails_command.liquid [new file with mode: 0644]
doc/install/install-arv-git-httpd.html.textile.liquid
doc/install/install-keep-web.html.textile.liquid
doc/install/install-keepproxy.html.textile.liquid
doc/install/install-sso.html.textile.liquid
doc/install/install-workbench-app.html.textile.liquid

diff --git a/doc/_includes/_install_rails_command.liquid b/doc/_includes/_install_rails_command.liquid
new file mode 100644 (file)
index 0000000..319f564
--- /dev/null
@@ -0,0 +1,41 @@
+{% comment %}
+This template recognizes four variables:
+* railshost: The hostname included in the prompt, to let the user know where to run the command.  If this is the empty string, no hostname will be displayed.  Default "apiserver".
+* railsdir: The directory included in the prompt, to let the user know where to run the command.  Default "/var/www/arvados-api/current".
+* railscmd: The full command to run.  Default "bundle exec rails console".
+* railsout: The expected output of the command, if any.
+{% endcomment %} Change *@webserver-user@* to the user that runs your web server process.  If you install Phusion Passenger as we recommend, this is *@www-data@* on Debian-based systems, and *@nginx@* on Red Hat-based systems.
+
+{% unless railshost %}
+  {% assign railshost = "apiserver" %}
+{% endunless %}
+
+{% unless (railshost == "") or (railshost contains ":") %}
+  {% capture railshost %}{{railshost}}:{% endcapture %}
+{% endunless %}
+
+{% unless railsdir %}
+  {% assign railsdir = "/var/www/arvados-api/current" %}
+{% endunless %}
+
+{% unless railscmd %}
+  {% assign railscmd = "bundle exec rails console" %}
+{% endunless %}
+
+Using RVM:
+
+<notextile>
+<pre><code>{{railshost}}~$ <span class="userinput">cd {{railsdir}}</span>
+{{railshost}}{{railsdir}}$ <span class="userinput">sudo -u <b>webserver-user</b> RAILS_ENV=production `which rvm-exec` default {{railscmd}}</span>
+{% if railsout %}{{railsout}}
+{% endif %}</code></pre>
+</notextile>
+
+Not using RVM:
+
+<notextile>
+<pre><code>{{railshost}}~$ <span class="userinput">cd {{railsdir}}</span>
+{{railshost}}{{railsdir}}$ <span class="userinput">sudo -u <b>webserver-user</b> RAILS_ENV=production {{railscmd}}</span>
+{% if railsout %}{{railsout}}
+{% endif %}</code></pre>
+</notextile>
index e592afc7c2eff88774ef0caa735af1174391da1e..146dbe170b917ff45849ebc018324949dc789cb2 100644 (file)
@@ -34,25 +34,10 @@ DNS and network configuration should be set up so port 443 reaches your HTTPS pr
 
 h2. Generate an API token
 
-Use the following command to generate an API token, changing *@webserver-user@* to the user of the web server process.  This is typically *@www-data@* on Debian systems by default, other systems may use different defaults such the name of the web server software (for example, *@nginx@*).
-
-Using RVM:
-
-<notextile>
-<pre><code>gitserver:~$ <span class="userinput">cd /var/www/arvados-api/current</span>
-gitserver:/var/www/arvados-api/current$ <span class="userinput">sudo -u <b>webserver-user</b> RAILS_ENV=production `which rvm-exec` default bundle exec ./script/create_superuser_token.rb</span>
-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
-</code></pre>
-</notextile>
-
-Not using RVM:
-
-<notextile>
-<pre><code>gitserver:~$ <span class="userinput">cd /var/www/arvados-api/current</span>
-gitserver:/var/www/arvados-api/current$ <span class="userinput">sudo -u <b>webserver-user</b> RAILS_ENV=production bundle exec ./script/create_superuser_token.rb</span>
-zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
-</code></pre>
-</notextile>
+{% assign railshost = "gitserver" %}
+{% assign railscmd = "bundle exec ./script/create_superuser_token.rb" %}
+{% assign railsout = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" %}
+Use the following command to generate an API token.  {% include 'install_rails_command' %}
 
 Copy that token; you'll need it in a minute.
 
index 5eb4191e8cab6133944904a6a43c4028b19e39ee..9e271d3c2750f47874b95161411cb63d4db99b07 100644 (file)
@@ -48,18 +48,15 @@ Usage of keep-web:
 </code></pre>
 </notextile>
 
-If you intend to use Keep-web to serve public data to anonymous clients, configure it with an anonymous token. You can use the same one you used when you set up your Keepproxy server, or use the following command on the <strong>API server</strong> to create another:
-
-<notextile>
-<pre><code>/var/www/arvados-api/current/script$ <span class="userinput">RAILS_ENV=production bundle exec ./get_anonymous_user_token.rb</span>
-hoShoomoo2bai3Ju1xahg6aeng1siquuaZ1yae2gi2Uhaeng2r
-</code></pre></notextile>
+{% assign railscmd = "bundle exec ./script/get_anonymous_user_token.rb" %}
+{% assign railsout = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" %}
+If you intend to use Keep-web to serve public data to anonymous clients, configure it with an anonymous token. You can use the same one you used when you set up your Keepproxy server, or use the following command on the <strong>API server</strong> to create another. {% include 'install_rails_command' %}
 
 We recommend running @keep-web@ under "runit":https://packages.debian.org/search?keywords=runit or a similar supervisor. The basic command to start @keep-web@ is:
 
 <notextile>
 <pre><code>export ARVADOS_API_HOST=<span class="userinput">uuid_prefix</span>.your.domain
-export ARVADOS_API_TOKEN="<span class="userinput">hoShoomoo2bai3Ju1xahg6aeng1siquuaZ1yae2gi2Uhaeng2r</span>"
+export ARVADOS_API_TOKEN="<span class="userinput">{{railsout}}</span>"
 exec sudo -u nobody keep-web \
  -listen=<span class="userinput">:9002</span> \
  -attachment-only-host=<span class="userinput">download.uuid_prefix.your.domain</span> \
index 5a5b66aaaef98c1ee2e42525df2c881655baf3ec..14e5ed5741067e0550a450b9d3bf9f24cb264a83 100644 (file)
@@ -51,21 +51,16 @@ Usage of keepproxy:
 
 h3. Create an API token for the Keepproxy server
 
-The Keepproxy server needs a token to talk to the API server.
-
-On the <strong>API server</strong>, use the following command to create the token:
-
-<notextile>
-<pre><code>/var/www/arvados-api/current/script$ <span class="userinput">RAILS_ENV=production bundle exec ./get_anonymous_user_token.rb</span>
-hoShoomoo2bai3Ju1xahg6aeng1siquuaZ1yae2gi2Uhaeng2r
-</code></pre></notextile>
+{% assign railscmd = "bundle exec ./script/get_anonymous_user_token.rb" %}
+{% assign railsout = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" %}
+The Keepproxy server needs a token to talk to the API server.  On the <strong>API server</strong>, use the following command to create the token.  {% include 'install_rails_command' %}
 
 h3. Set up the Keepproxy service
 
 We recommend you run Keepproxy under "runit":http://smarden.org/runit/ or a similar supervisor.  Make sure the launcher sets the envirnoment variables @ARVADOS_API_TOKEN@ (with the token you just generated), @ARVADOS_API_HOST@, and, if needed, @ARVADOS_API_HOST_INSECURE@.  The core keepproxy command to run is:
 
 <notextile>
-<pre><code>ARVADOS_API_TOKEN=<span class="userinput">[generated token]</span> ARVADOS_API_HOST=<span class="userinput">uuid_prefix.your.domain</span> exec keepproxy
+<pre><code>ARVADOS_API_TOKEN=<span class="userinput">{{railsout}}</span> ARVADOS_API_HOST=<span class="userinput">uuid_prefix.your.domain</span> exec keepproxy
 </code></pre>
 </notextile>
 
index ca620f478a8d215066fde5a9ffa157032174f4db..1a3e4b380aefbbd21ed52d5a3e54e41e6add2e53 100644 (file)
@@ -159,17 +159,18 @@ On a Red Hat-based system, we need to reinstall the package instead:
 
 h2(#client). Create arvados-server client
 
-Use @rails console@ to create a @Client@ record that will be used by the Arvados API server.  The values of @app_id@ and @app_secret@ correspond to the values for @sso_app_id@ and @sso_app_secret@ in the "API server's SSO settings.":install-api-server.html#omniauth
+{% assign railshost = "" %}
+{% assign railsdir = "/var/www/arvados-sso/current" %}
+Use @rails console@ to create a @Client@ record that will be used by the Arvados API server.  {% include 'install_rails_command' %}
+
+Enter the following commands at the console.  The values that appear after you assign @app_id@ and @app_secret@ correspond to the values for @sso_app_id@ and @sso_app_secret@, respectively, in the "API server's SSO settings":install-api-server.html#omniauth.
 
 <notextile>
-<pre><code>~$ <span class="userinput">ruby -e 'puts rand(2**400).to_s(36)'</span>
-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-~$ <span class="userinput">cd /var/www/arvados-sso/current</span>
-/var/www/arvados-sso/current$ <span class="userinput">RAILS_ENV=production bundle exec rails console</span>
-:001 &gt; <span class="userinput">c = Client.new</span>
+<pre><code>:001 &gt; <span class="userinput">c = Client.new</span>
 :002 &gt; <span class="userinput">c.name = "joshid"</span>
 :003 &gt; <span class="userinput">c.app_id = "arvados-server"</span>
-:004 &gt; <span class="userinput">c.app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"</span>
+:004 &gt; <span class="userinput">c.app_secret = rand(2**400).to_s(36)</span>
+=&gt; "<strong>save this string for your API server's sso_app_secret</strong>"
 :005 &gt; <span class="userinput">c.save!</span>
 :006 &gt; <span class="userinput">quit</span>
 </code></pre>
@@ -245,11 +246,12 @@ There are two configuration options for local accounts:
 
 For more information about configuring backend support for sending email (required to send email confirmations) see "Configuring Action Mailer":http://guides.rubyonrails.org/configuring.html#configuring-action-mailer
 
-If @allow_account_registration@ is false, you may manually create local accounts on the SSO server from the rails console:
+If @allow_account_registration@ is false, you may manually create local accounts on the SSO server from the Rails console.  {% include 'install_rails_command' %}
+
+Enter the following commands at the console.
 
 <notextile>
-<pre><code>~$ <span class="userinput">RAILS_ENV=production bundle exec rails console</span>
-:001 &gt; <span class="userinput">user = User.new(:email =&gt; "test@example.com")</span>
+<pre><code>:001 &gt; <span class="userinput">user = User.new(:email =&gt; "test@example.com")</span>
 :002 &gt; <span class="userinput">user.password = "passw0rd"</span>
 :003 &gt; <span class="userinput">user.save!</span>
 :004 &gt; <span class="userinput">quit</span>
index 9e8cb7f2ad06d40a84f743fd6e48746f106749a2..7f504a919d55dec472fee62f895ae8ba492fd520 100644 (file)
@@ -183,10 +183,11 @@ h2. Trusted client setting
 
 Log in to Workbench once to ensure that the Arvados API server has a record of the Workbench client. (It's OK if Workbench says your account hasn't been activated yet. We'll deal with that next.)
 
-In the <strong>API server</strong> project root, start the rails console.  Locate the ApiClient record for your Workbench installation (typically, while you're setting this up, the @last@ one in the database is the one you want), then set the @is_trusted@ flag for the appropriate client record:
+In the <strong>API server</strong> project root, start the Rails console.  {% include 'install_rails_command' %}
 
-<notextile><pre><code>/var/www/arvados-api/current$ <span class="userinput">RAILS_ENV=production bundle exec rails console</span>
-irb(main):001:0&gt; <span class="userinput">wb = ApiClient.all.last; [wb.url_prefix, wb.created_at]</span>
+At the console, enter the following commands to locate the ApiClient record for your Workbench installation (typically, while you're setting this up, the @last@ one in the database is the one you want), then set the @is_trusted@ flag for the appropriate client record:
+
+<notextile><pre><code>irb(main):001:0&gt; <span class="userinput">wb = ApiClient.all.last; [wb.url_prefix, wb.created_at]</span>
 =&gt; ["https://workbench.example.com/", Sat, 19 Apr 2014 03:35:12 UTC +00:00]
 irb(main):002:0&gt; <span class="userinput">include CurrentApiClient</span>
 =&gt; true
@@ -197,11 +198,12 @@ irb(main):003:0&gt; <span class="userinput">act_as_system_user do wb.update_attr
 
 h2(#admin-user). Add an admin user
 
-Next, we're going to use the rails console on the <strong>API server</strong> to activate our own account and give yourself admin privileges:
+Next, we're going to use the Rails console on the <strong>API server</strong> to activate your account and give yourself admin privileges.  {% include 'install_rails_command' %}
+
+Enter the following commands at the console:
 
 <notextile>
-<pre><code>/var/www/arvados-api/current$ <span class="userinput">RAILS_ENV=production bundle exec rails console</span>
-irb(main):001:0&gt; <span class="userinput">Thread.current[:user] = User.all.select(&:identity_url).last</span>
+<pre><code>irb(main):001:0&gt; <span class="userinput">Thread.current[:user] = User.all.select(&:identity_url).last</span>
 irb(main):002:0&gt; <span class="userinput">Thread.current[:user].update_attributes is_admin: true, is_active: true</span>
 irb(main):003:0&gt; <span class="userinput">User.where(is_admin: true).collect &:email</span>
 =&gt; ["root", "<b>your_address@example.com</b>"]