summaryrefslogtreecommitdiff
path: root/util/preflight_check
blob: faa85a4ba7921fcb4cf7c7efca6109e4e827c3a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env ruby
# frozen_string_literal: true
# Make sure we can access all the binaries the site needs - otherwise, it's gonna be a bad day.
quiet = ARGV.include?('-q')

BINARIES = {
  'gifsicle'          => '--version',
  'jpegtran'          => '-version',
  'optipng'           => '--version',
  'safe-rsvg-convert' => nil,
  'mediastat'         => '-v',
  'mediathumb'        => '-v',
  'ffmpeg'            => '-version',
  'convert'           => '--version',
  'identify'          => '--version'
}.freeze

BINARIES.each do |bin, version_args|
  path = `bash -c "command -v #{bin}"`.strip

  if $? == 0
    next if quiet

    version = if version_args
                `#{bin} #{version_args} 2>&1 | head -n1`.strip
              else
                'unknown'
              end
    puts "[+] Found #{bin} OK: #{path} (#{version})"
  else
    puts "[-] Error: #{bin} doesn't seem to be installed or in PATH."
    exit 1
  end
end