Skip to content

Commit

Permalink
Merge branch 'master' into livenotice
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbASF committed Aug 30, 2024
2 parents 23b4ea1 + f0526c2 commit 51e8e5f
Show file tree
Hide file tree
Showing 244 changed files with 3,421 additions and 3,203 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/unittestlib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-20.04, ubuntu-22.04]
os: [macos-13, ubuntu-20.04, ubuntu-22.04]
ruby: [2.7, 3.1]
# 2.7 not supported on 22.04
exclude:
- os: ubuntu-22.04
ruby: 2.7
include:
- os: ubuntu-24.04
ruby: 3.2
# LDAP does not work on 24.04 (needs patch)
# include:
# - os: ubuntu-24.04
# ruby: 3.2
runs-on: ${{ matrix.os }}
steps:
- name: setup non-macOS # needed for installing ruby-ldap
Expand Down
2 changes: 1 addition & 1 deletion DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ If a developer needs such access, they should use a local SVN repository.
Using a local SVN repository
----------------------------
Create a directory called REPO (must agree with docker-config/whimsy.conf) under the whimsy parent directory
(i.e. alonside the gems/ directory)
(i.e. alongside the gems/ directory)
Set up 3 local SVN repositories under the REPO directory using `svnadmin create` with the names: asf, private, infra
Under each of these, create the directories and files you need.

Expand Down
40 changes: 20 additions & 20 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end

# Run system and abort if it fails
def system!(*args)
system(*args) or raise "system!() failed!"
system(*args) or raise 'system!() failed!'
end

# update gems and restart applications as needed
Expand Down Expand Up @@ -56,9 +56,9 @@ task :update, [:command] do |_task, args|
gemlines = Dir['**/Gemfile'].
map {|file| File.read file}.join.scan(/^\s*gem\s.*/)

if File.exist? "asf.gemspec"
if File.exist? 'asf.gemspec'
gemlines +=
File.read("asf.gemspec").scan(/add_dependency\((.*)\)/).
File.read('asf.gemspec').scan(/add_dependency\((.*)\)/).
map {|(line)| "gem #{line}"}
end

Expand All @@ -71,19 +71,19 @@ task :update, [:command] do |_task, args|
Dir.chdir dir do
contents = [
"source 'https://rubygems.org'",
"ldapversion = nil", # Needed for initial gem setup
'ldapversion = nil', # Needed for initial gem setup
gems.values
].join("\n")
File.write "Gemfile", contents
$stderr.puts "* Preloading gems..."
File.write 'Gemfile', contents
$stderr.puts '* Preloading gems...'
system!('bundle', 'install')
$stderr.puts "* ... done"
$stderr.puts '* ... done'
end
end
end

# update gems
$stderr.puts "* Update Gems" # use stderr so output appears in syslog
$stderr.puts '* Update Gems' # use stderr so output appears in syslog
Dir['**/Gemfile'].each do |gemfile|
Dir.chdir File.dirname(gemfile) do
ruby = File.read('Gemfile')[/^ruby ['"](.*?)['"]/, 1]
Expand All @@ -103,7 +103,7 @@ task :update, [:command] do |_task, args|
# if new gems were installed and this directory contains a passenger
# application, restart it
if (File.mtime('Gemfile.lock') rescue Time.at(0)) != locktime
$stderr.puts "* Gemfile.lock was updated"
$stderr.puts '* Gemfile.lock was updated'
if File.exist?('tmp/restart.txt')
FileUtils.touch 'tmp/.restart.txt'
FileUtils.chmod 0o777, 'tmp/.restart.txt'
Expand Down Expand Up @@ -184,7 +184,7 @@ namespace :svn do

next if arg1 == 'skip'
if noCheckout
puts "Skipping" if depth == 'skip' # Must agree with monitors/svn.rb
puts 'Skipping' if depth == 'skip' # Must agree with monitors/svn.rb
next
end

Expand Down Expand Up @@ -300,7 +300,7 @@ namespace :svn do
if errors > 0
puts "** Found #{errors} error(s) **"
else
puts "** No errors found **"
puts '** No errors found **'
end
end
end
Expand Down Expand Up @@ -387,7 +387,7 @@ LDAP_WHIMSY_PATH = '../.ldap_whimsy.tmp'
def getpass(user_dn)
pw = $stdin.getpass("password for #{user_dn}: ")
return pw unless pw == '*'
if RbConfig::CONFIG["host_os"].start_with? 'darwin'
if RbConfig::CONFIG['host_os'].start_with? 'darwin'
pw, status = Open3.capture2('security', 'find-generic-password', '-a', user_dn, '-w')
raise "ERROR: problem running security: #{status}" unless status.success?
else
Expand All @@ -401,23 +401,23 @@ def ldap_init
require 'io/console' # cannot prompt from container, so need to do this upfront
require 'whimsy/asf/config'

whimsy_dn = ASF::Config.get(:whimsy_dn) or raise "ERROR: Must provide whimsy_dn value in .whimsy"
whimsy_dn = ASF::Config.get(:whimsy_dn) or raise 'ERROR: Must provide whimsy_dn value in .whimsy'
whimsy_pw = getpass(whimsy_dn)
raise "ERROR: Password is required" unless whimsy_pw.size > 1
raise 'ERROR: Password is required' unless whimsy_pw.size > 1

httpd_dn = ASF::Config.get(:httpd_dn)
if httpd_dn
httpd_pw = getpass(httpd_dn)
raise "ERROR: Password is required" unless httpd_pw.size > 1
raise 'ERROR: Password is required' unless httpd_pw.size > 1
else # default to whimsy credentials
httpd_dn = whimsy_dn
httpd_pw = whimsy_pw
end
File.open(LDAP_HTTPD_PATH, "w", 0o600) do |w|
File.open(LDAP_HTTPD_PATH, 'w', 0o600) do |w|
w.puts httpd_dn
w.puts httpd_pw
end
File.open(LDAP_WHIMSY_PATH, "w", 0o600) do |w|
File.open(LDAP_WHIMSY_PATH, 'w', 0o600) do |w|
w.puts whimsy_dn
w.puts whimsy_pw
end
Expand All @@ -427,7 +427,7 @@ end
def filter(src, dst, ldaphosts, ldapbinddn, ldapbindpw)
require 'erb'
template = ERB.new(File.read(src))
File.open(dst, "w") do |w|
File.open(dst, 'w') do |w|
w.write(template.result(binding))
end
end
Expand All @@ -450,9 +450,9 @@ def ldap_setup
$LOAD_PATH.unshift 'lib'
require 'whimsy/asf/config'
hosts = ASF::Config.get(:ldap)
raise "ERROR: Must define :ldap in ../.whimsy" unless hosts
raise 'ERROR: Must define :ldap in ../.whimsy' unless hosts

ldaphosts = hosts.join(" ").gsub('ldaps://', '')
ldaphosts = hosts.join(' ').gsub('ldaps://', '')

filter('docker-config/whimsy.conf',
'/etc/apache2/sites-enabled/000-default.conf', ldaphosts, ldapbinddn, ldapbindpw)
Expand Down
26 changes: 13 additions & 13 deletions asf.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ end
Gem::Specification.new do |s|

# Change these as appropriate
s.name = "whimsy-asf"
s.name = 'whimsy-asf'
s.license = 'Apache-2.0'
s.version = version
s.summary = "Whimsy 'model' of the ASF"
s.author = "Sam Ruby"
s.email = "rubys@intertwingly.net"
s.homepage = "https://whimsy.apache.org/"
s.author = 'Sam Ruby'
s.email = 'rubys@intertwingly.net'
s.homepage = 'https://whimsy.apache.org/'
s.description = <<-EOD
This package contains a set of classes which encapsulate access
to a number of data sources such as LDAP, ICLAs, auth lists, etc.
EOD

# Add any extra files to include in the gem
s.files = Dir.glob(["asf.*", "lib/**/*"])
s.require_paths = ["lib"]
s.files = Dir.glob(['asf.*', 'lib/**/*'])
s.require_paths = ['lib']

# If you want to depend on other gems, add them here, along with any
# relevant versions
s.add_dependency("nokogiri")
s.add_dependency("rack")
s.add_dependency("ruby-ldap", ldapversion)
s.add_dependency("tzinfo")
s.add_dependency("tzinfo-data")
s.add_dependency("wunderbar")
s.add_dependency("rdoc")
s.add_dependency('nokogiri')
s.add_dependency('rack')
s.add_dependency('ruby-ldap', ldapversion)
s.add_dependency('tzinfo')
s.add_dependency('tzinfo-data')
s.add_dependency('wunderbar')
s.add_dependency('rdoc')

# If your tests use any gems, include them here
# s.add_development_dependency("mocha") # for example
Expand Down
60 changes: 30 additions & 30 deletions config/setupmymac
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ $apache_would_have_been_restarted = (ARGV.delete '--apache-restarted')
#########################################################################

unless RUBY_PLATFORM.include? 'darwin'
STDERR.puts "This script is intended to be run on macOS"
STDERR.puts 'This script is intended to be run on macOS'
exit 1
end

unless (RUBY_VERSION.split('.').map(&:to_i) <=> [2, 4, 1]) >= 0
STDERR.puts "Ruby 2.4.1 or later is required"
STDERR.puts 'Ruby 2.4.1 or later is required'
exit 1
end

Expand Down Expand Up @@ -51,7 +51,7 @@ end

# echo a command and run it
def run *args
color "$ " + "#{'sudo ' if $root}" + Array(args).join(' ')
color '$ ' + "#{'sudo ' if $root}" + Array(args).join(' ')
return if $dry_run
Kernel.system(*args)
end
Expand All @@ -77,7 +77,7 @@ def sudo
system RbConfig.ruby, COMMAND, *ARGS, '--sudo'
$apache_would_have_been_restarted = true
else
system "sudo", RbConfig.ruby, COMMAND, *ARGS
system 'sudo', RbConfig.ruby, COMMAND, *ARGS
exit $?.exitstatus unless $?.success?
end
end
Expand All @@ -98,81 +98,81 @@ option = :www
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options]"

opts.on('-u', '--user', "Run whimsy under your user") do |_opt|
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|
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|
opts.on('-d', '--docker', 'Run whimsy on docker') do |_opt|
option = :docker
end

opts.on('--[no-]gem', '--gems', "Upgrade gem dependencies") do |opt|
opts.on('--[no-]gem', '--gems', 'Upgrade gem dependencies') do |opt|
force[:gems] = opt
end

opts.on('--[no-]bundle', '--bundler', "Upgrade bundler") do |opt|
opts.on('--[no-]bundle', '--bundler', 'Upgrade bundler') do |opt|
force[:bundler] = opt
end

opts.on('--[no-]node', "Upgrade to the latest node.js") do |opt|
opts.on('--[no-]node', 'Upgrade to the latest node.js') do |opt|
force[:node] = opt
end

opts.on('--[no-]passenger', "Upgrade to the latest Phusion Passenger") do |opt|
opts.on('--[no-]passenger', 'Upgrade to the latest Phusion Passenger') do |opt|
force[:passenger] = opt
end

opts.on('--[no-]ldap', "Reconfigure LDAP") do |_opt|
opts.on('--[no-]ldap', 'Reconfigure LDAP') do |_opt|
force[:ldap] = opts
end

opts.on('--[no-]svn', "Checkout/update svn repositories") do |_opt|
opts.on('--[no-]svn', 'Checkout/update svn repositories') do |_opt|
force[:svn] = opts
end

opts.on('--[no-]git', "Clone/pull git repositories") do |_opt|
opts.on('--[no-]git', 'Clone/pull git repositories') do |_opt|
force[:git] = opts
end

opts.on('--[no-]source', "Pull the latest changes to the source code") do |opt|
opts.on('--[no-]source', 'Pull the latest changes to the source code') do |opt|
force[:source] = opt
end

opts.on('--[no-]minutes', "Collate board minutes") do |opt|
opts.on('--[no-]minutes', 'Collate board minutes') do |opt|
force[:minutes] = opt
end

opts.on('--update-all', "Update everything") do |_opt|
opts.on('--update-all', 'Update everything') do |_opt|
force.default = true
end

opts.on('--[no-]toucher', "Restart rack applications on source change") do |opt|
opts.on('--[no-]toucher', 'Restart rack applications on source change') do |opt|
force[:toucher] = opt
end

opts.on('--[no-]ws', "Start board agenda websocket") do |opt|
opts.on('--[no-]ws', 'Start board agenda websocket') do |opt|
force[:ws] = opt
end

opts.on('--all', "Update and launch everything") do |_opt|
opts.on('--all', 'Update and launch everything') do |_opt|
force[:ws] = true if force[:ws].nil?
force[:toucher] = true if force[:toucher].nil?
force.default = true
end

opts.on('--[no-]clean', "Clean up source directory") do |opt|
opts.on('--[no-]clean', 'Clean up source directory') do |opt|
force[:clean] = opt
end

opts.on('--[no-]prune', "Prune docker containers and images") do |opt|
opts.on('--[no-]prune', 'Prune docker containers and images') do |opt|
force[:prune] = opt
end

opts.on('--dry-run', "Only indicate what commands would be run") do |_opt|
opts.on('--dry-run', 'Only indicate what commands would be run') do |_opt|
$dry_run = true
end
end.parse!
Expand Down Expand Up @@ -250,14 +250,14 @@ unless Dir.exist? '/srv'
run 'chown', "#{sudo_user.uid}:#{sudo_user.gid}", '/var/whimsy'
run 'touch', '/etc/synthetic.conf'
SYNTHETIC = '/etc/synthetic.conf'
unless File.read(SYNTHETIC).include? "/var/whimsy"
unless File.read(SYNTHETIC).include? '/var/whimsy'
color "$ sudo edit #{SYNTHETIC}"
unless $dry_run
File.write SYNTHETIC, File.read(SYNTHETIC) + "srv\t/var/whimsy\n"
end
STDERR.puts "#{SYNTHETIC} updated; reboot machine and rerun this script"
puts %(\nPress "y" to reboot now, anything else to exit)
run "shutdown -r now" if gets.strip.downcase == "y"
run 'shutdown -r now' if gets.strip.downcase == 'y'
exit 1
end
else
Expand Down Expand Up @@ -417,7 +417,7 @@ end
unless $root
if force[:gems] or not File.exist?("#{WHIMSY}/Gemfile.lock")
Dir.chdir WHIMSY do
run "rake", "update"
run 'rake', 'update'
end
end
end
Expand Down Expand Up @@ -515,7 +515,7 @@ if config != File.read(HTTPD_CONF)
sudo do
color "$ sudo edit #{HTTPD_CONF}"
return if $dry_run
File.rename HTTPD_CONF, HTTPD_CONF + ".original"
File.rename HTTPD_CONF, HTTPD_CONF + '.original'
File.write(HTTPD_CONF, config)
end

Expand Down Expand Up @@ -597,7 +597,7 @@ end

if force[:ws] != nil
sudo do
plist = "/Library/LaunchDaemons/board-agenda-websocket.plist"
plist = '/Library/LaunchDaemons/board-agenda-websocket.plist'

if force[:ws]
contents = File.read("#{__dir__}/board-agenda-websocket.plist")
Expand Down Expand Up @@ -639,9 +639,9 @@ end

if $root and not $apache_would_have_been_restarted
if not `launchctl list`.include? 'org.apache.httpd'
run "launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist"
run 'launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist'
elsif restart_apache
run "apachectl restart"
run 'apachectl restart'
sleep 0.5
end
elsif not $dry_run
Expand Down
Loading

0 comments on commit 51e8e5f

Please sign in to comment.