Make the build script prompt for a shell login name.
authorWard Vandewege <ward@curoverse.com>
Tue, 22 Jul 2014 20:19:53 +0000 (16:19 -0400)
committerWard Vandewege <ward@curoverse.com>
Tue, 22 Jul 2014 20:19:53 +0000 (16:19 -0400)
refs #3219

docker/build_tools/build.rb

index 5e3b1ed68dea63d20143d8419a738660fef26b3b..4fef3568cbabe8d0b0e54647e19d197015bc33e0 100755 (executable)
@@ -64,9 +64,22 @@ def main options
       end
     end
 
+    print "Arvados needs to know the shell login name for the administrative user.\n"
+    print "This will also be used as the name for your git repository.\n"
+    print "\n"
+    user_name = ""
+    until is_valid_user_name? user_name
+      print "Enter a shell login name here: "
+      user_name = gets.strip
+      if not is_valid_user_name? user_name
+        print "That doesn't look like a valid shell login name. Please try again.\n"
+      end
+    end
+
     File.open 'config.yml', 'w' do |config_out|
       config = YAML.load_file 'config.yml.example'
       config['API_AUTO_ADMIN_USER'] = admin_email_address
+      config['ARVADOS_USER_NAME'] = user_name
       config['API_HOSTNAME'] = generate_api_hostname
       config['PUBLIC_KEY_PATH'] = find_or_create_ssh_key(config['API_HOSTNAME'])
       config.each_key do |var|
@@ -114,6 +127,15 @@ def is_valid_email? str
   str.match /^\S+@\S+\.\S+$/
 end
 
+# is_valid_user_name?
+#   Returns true if its arg looks like a valid unix username.
+#   This is a very very loose sanity check.
+#
+def is_valid_user_name? str
+  # borrowed from Debian's adduser (version 3.110)
+  str.match /^[_.A-Za-z0-9][-\@_.A-Za-z0-9]*\$?$/
+end
+
 # generate_api_hostname
 #   Generates a 5-character randomly chosen API hostname.
 #