You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2019/11/25 19:22:33 UTC

[whimsy] branch master updated (a27ab24 -> 2d2669b)

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git.


    from a27ab24  Centralise SVN private-public classification
     new 8b99e10  Provide an option to determine how whimsy is to be run
     new 2d2669b  Merge branch 'master' of github.com:apache/whimsy

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 config/setupmymac | 170 ++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 120 insertions(+), 50 deletions(-)


[whimsy] 01/02: Provide an option to determine how whimsy is to be run

Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git

commit 8b99e101dee1895174a655f09a69b6abcdf21bc5
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Mon Nov 25 14:14:53 2019 -0500

    Provide an option to determine how whimsy is to be run
---
 config/setupmymac | 166 ++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 118 insertions(+), 48 deletions(-)

diff --git a/config/setupmymac b/config/setupmymac
index 211d76d..c3c029b 100755
--- a/config/setupmymac
+++ b/config/setupmymac
@@ -1,6 +1,8 @@
 #!/usr/bin/env ruby
 require 'fileutils'
 require 'tmpdir'
+require 'optparse'
+require 'etc'
 
 unless RUBY_PLATFORM.include? 'darwin'
   STDERR.puts "This script is intended to be run on macOS"
@@ -14,45 +16,142 @@ end
 
 WHIMSY = File.realpath File.expand_path('..', __dir__)
 COMMAND = File.realpath($0)
+ARGS = ARGV.dup
 Dir.chdir WHIMSY
 
 restart_apache = false
 
+### Parse options to determine how whimsy code is to be run
+
+option = :www
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: #$0 [options]"
+
+  opts.on('-u', '--user', "Run whimsy under your user") do |opt|
+    option = :user
+  end
+
+  opts.on('-w', '--web', "Run whimsy under the Apache web user") do |opt|
+    option = :web
+  end
+
+  opts.on('-d', '--docker', "Run whimsy on docker") do |opt|
+    option = :docker
+  end
+end.parse!
+
+user = option != :user ? '_www' : (ENV['SUDO_USER'] || Etc.getlogin)
+uid = Etc.getpwnam(user).uid
+gid = Etc.getpwnam(user).gid
+group = Etc.getgrgid(gid).name
+
 ### Install Homebrew
 
-if `which brew`.empty?
-  script = 'https://raw.githubusercontent.com/Homebrew/install/master/install'
-  eval `curl -fsSL #{script}`
-elsif Process.uid != 0
-  `brew update`
+if Process.uid != 0
+  if `which brew`.empty?
+    script = 'https://raw.githubusercontent.com/Homebrew/install/master/install'
+    eval `curl -fsSL #{script}`
+  else
+    `brew update`
+  end
 end
 
 ## Install Node.js
 
-system 'brew install node' if `which node`.empty?
-system 'npm install -g npm' if `which npm`.empty?
+if Process.uid != 0
+  system 'brew install node' if `which node`.empty?
+  system 'npm install -g npm' if `which npm`.empty?
 
-# Prompt for xcode installation
-`svn --version`
+  # Prompt for xcode installation
+  `svn --version`
 
-# Install passenger
+  # Install passenger
 
-if `which passenger`.empty?
-  system 'brew install passenger'
+  if `which passenger`.empty?
+    system 'brew install passenger'
+  end
 end
 
 # Switch to root
 
 def sudo
   if Process.uid != 0
-    system "sudo", RbConfig.ruby, COMMAND, *ARGV
+    system "sudo", RbConfig.ruby, COMMAND, *ARGS
     exit $?.exitstatus unless $?.success?
   else
     yield
   end
 end
 
-# Configure passenger
+### Create /srv
+
+mac_version = `sw_vers`[/ProductVersion:\s+(.*)/, 1]
+unless Dir.exist? '/srv'
+  sudo_user = ENV['SUDO_USER']
+  sudo_group = Etc.getpwnam(sudo_user).gid
+  sudo do
+    if (mac_version.split('.').map(&:to_i) <=> [10, 15, 0]) >= 0
+      # Catalina or later
+      Dir.mkdir '/var/whimsy' unless Dir.exist? '/var/whimsy'
+      FileUtils.chown sudo_user, sudo_group, '/var/whimsy'
+      FileUtils.touch '/etc/synthetic.conf'
+      SYNTHETIC = '/etc/synthetic.conf'
+      unless File.read(SYNTHETIC).include? "/var/whimsy"
+        File.write SYNTHETIC, File.read(SYNTHETIC) + "srv\t/var/whimsy\n"
+        STDERR.puts "#{SYNTHETIC} updated; reboot machine and rerun this script"
+        exit 1
+      end
+    else
+      # prior to Catalina
+      Dir.mkdir '/srv'
+      FileUtils.chown sudo_user, sudo_group, '/srv'
+    end
+  end
+end
+
+# relocate whimsy clone
+if not Dir.exist? '/srv/whimsy'
+  sudo do
+    FileUtils.mv WHIMSY, '/srv/whimsy'
+    File.symlink '/srv/whimsy', WHIMSY
+  end
+end
+
+### Define directories
+directories = [
+  '/srv/agenda',
+  '/srv/cache',
+  '/srv/secretary',
+  '/srv/secretary/tlpreq',
+  '/srv/whimsy/www/board/minutes',
+  '/srv/whimsy/www/logs',
+  '/srv/whimsy/www/public',
+]
+
+directories.each do |dir|
+  sudo {FileUtils.mkdir_p dir} unless Dir.exist? dir
+  sudo {FileUtils.chown_R uid, gid, dir} unless File.stat(dir).uid == uid
+end
+
+### Docker installation
+
+if option == :docker
+  unless system 'docker info > /dev/null 2>&1'
+    STDERR.puts "Please start docker and run this command again"
+    exit 1
+  end
+
+  if Process.uid != 0
+    Dir.chdir '/srv/whimsy' do
+      system 'rake docker:update'
+    end
+  end
+
+  exit
+end
+
+### Configure passenger
 
 passenger_conf = '/etc/apache2/other/passenger.conf'
 if Process.uid == 0
@@ -61,8 +160,9 @@ else
   instructions = `brew info passenger`
 end
 section = instructions[/To activate Phusion Passenger for Apache.*(\n\n|\z)/m]
-snippet = section.scan(/^ .*/).join("\n")
+snippet = section.scan(/^ .*/).join("\n") + "\n"
 snippet[/Passenger\w*Ruby\s+(.*)/, 1] = RbConfig.ruby
+snippet += "PassengerUser #{user}\nPassengerGroup #{group}\n" if option != :user
 if not File.exists?(passenger_conf) or File.read(passenger_conf) != snippet
   sudo do
     File.write passenger_conf, snippet
@@ -104,39 +204,6 @@ if Process.uid != 0 and not File.exist?("#{WHIMSY}/Gemfile.lock")
   end
 end
 
-### Create /srv
-
-mac_version = `sw_vers`[/ProductVersion:\s+(.*)/, 1]
-unless Dir.exist? '/srv'
-  group = `id #{ENV['SUDO_USER']}`[/gid=\d+\((\w+)\)/, 1]
-  sudo do
-    if (mac_version.split('.').map(&:to_i) <=> [10, 15, 0]) >= 0
-      # Catalina or later
-      Dir.mkdir '/var/whimsy' unless Dir.exist? '/var/whimsy'
-      FileUtils.chown ENV['SUDO_USER'], group, '/var/whimsy'
-      FileUtils.touch '/etc/synthetic.conf'
-      SYNTHETIC = '/etc/synthetic.conf'
-      unless File.read(SYNTHETIC).include? "/var/whimsy"
-        File.write SYNTHETIC, File.read(SYNTHETIC) + "srv\t/var/whimsy\n"
-        STDERR.puts "#{SYNTHETIC} updated; reboot machine and rerun this script"
-        exit 1
-      end
-    else
-      # prior to Catalina
-      Dir.mkdir '/srv'
-      FileUtils.chown ENV['SUDO_USER'], group, '/srv'
-    end
-  end
-end
-
-# relocate whimsy clone
-if not Dir.exist? '/srv/whimsy'
-  sudo do
-    FileUtils.mv WHIMSY, '/srv/whimsy'
-    File.symlink '/srv/whimsy', WHIMSY
-  end
-end
-
 ### Configure LDAP
 
 if File.exist? "#{WHIMSY}/Gemfile.lock"
@@ -185,6 +252,9 @@ add.scan(/^\S.*/).each do |line|
   end
 end
 
+config[/^User\s+(.*)/, 1] = user
+config[/^Group\s+(.*)/, 1] = group
+
 if config != File.read(HTTPD_CONF)
   sudo do
     File.rename HTTPD_CONF, HTTPD_CONF + ".original"


[whimsy] 02/02: Merge branch 'master' of github.com:apache/whimsy

Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git

commit 2d2669b5c150836da385f143b2eef1bf8b66f19a
Merge: 8b99e10 a27ab24
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Mon Nov 25 14:20:28 2019 -0500

    Merge branch 'master' of github.com:apache/whimsy

 Gemfile                         |  2 +-
 config/setupmymac               |  2 ++
 lib/spec/lib/svn_spec.rb        | 65 +++++++++++++++++++++++++++++++++++++++++
 lib/whimsy/asf/svn.rb           | 55 ++++++++++++++++++++++++++++++++--
 tools/wwwdocs.rb                | 20 +++----------
 www/board/agenda/Gemfile        |  6 ++--
 www/committers/config_info.cgi  | 12 ++++++++
 www/committers/tools.cgi        |  2 +-
 www/members/repo-use.cgi        |  2 +-
 www/project/icla/Gemfile        |  4 +--
 www/racktest/config.ru          | 15 +++++++++-
 www/roster/Gemfile              |  2 +-
 www/secretary/Gemfile           |  2 +-
 www/secretary/workbench/Gemfile |  2 +-
 www/status/Gemfile              |  2 +-
 www/test.cgi                    |  1 +
 www/treasurer/statements.cgi    |  1 -
 17 files changed, 162 insertions(+), 33 deletions(-)

diff --cc config/setupmymac
index c3c029b,beb697f..6382142
--- a/config/setupmymac
+++ b/config/setupmymac
@@@ -84,74 -52,7 +84,76 @@@ def sud
    end
  end
  
 -# Configure passenger
 +### Create /srv
 +
 +mac_version = `sw_vers`[/ProductVersion:\s+(.*)/, 1]
 +unless Dir.exist? '/srv'
 +  sudo_user = ENV['SUDO_USER']
 +  sudo_group = Etc.getpwnam(sudo_user).gid
 +  sudo do
 +    if (mac_version.split('.').map(&:to_i) <=> [10, 15, 0]) >= 0
 +      # Catalina or later
 +      Dir.mkdir '/var/whimsy' unless Dir.exist? '/var/whimsy'
 +      FileUtils.chown sudo_user, sudo_group, '/var/whimsy'
 +      FileUtils.touch '/etc/synthetic.conf'
 +      SYNTHETIC = '/etc/synthetic.conf'
 +      unless File.read(SYNTHETIC).include? "/var/whimsy"
 +        File.write SYNTHETIC, File.read(SYNTHETIC) + "srv\t/var/whimsy\n"
 +        STDERR.puts "#{SYNTHETIC} updated; reboot machine and rerun this script"
++        puts %(\nPress "y" to reboot now, anything else to exit)
++        system "shutdown -r now" if gets.strip.downcase == "y"
 +        exit 1
 +      end
 +    else
 +      # prior to Catalina
 +      Dir.mkdir '/srv'
 +      FileUtils.chown sudo_user, sudo_group, '/srv'
 +    end
 +  end
 +end
 +
 +# relocate whimsy clone
 +if not Dir.exist? '/srv/whimsy'
 +  sudo do
 +    FileUtils.mv WHIMSY, '/srv/whimsy'
 +    File.symlink '/srv/whimsy', WHIMSY
 +  end
 +end
 +
 +### Define directories
 +directories = [
 +  '/srv/agenda',
 +  '/srv/cache',
 +  '/srv/secretary',
 +  '/srv/secretary/tlpreq',
 +  '/srv/whimsy/www/board/minutes',
 +  '/srv/whimsy/www/logs',
 +  '/srv/whimsy/www/public',
 +]
 +
 +directories.each do |dir|
 +  sudo {FileUtils.mkdir_p dir} unless Dir.exist? dir
 +  sudo {FileUtils.chown_R uid, gid, dir} unless File.stat(dir).uid == uid
 +end
 +
 +### Docker installation
 +
 +if option == :docker
 +  unless system 'docker info > /dev/null 2>&1'
 +    STDERR.puts "Please start docker and run this command again"
 +    exit 1
 +  end
 +
 +  if Process.uid != 0
 +    Dir.chdir '/srv/whimsy' do
 +      system 'rake docker:update'
 +    end
 +  end
 +
 +  exit
 +end
 +
 +### Configure passenger
  
  passenger_conf = '/etc/apache2/other/passenger.conf'
  if Process.uid == 0