Class: OSX

Inherits:
Object
  • Object
show all
Defined in:
lib/osx.rb

Class Method Summary collapse

Class Method Details

.check_mac_store_updatesObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/osx.rb', line 40

def check_mac_store_updates
  check_update_message('Mac App Store')
  if run?
    Open3.popen3('softwareupdate -l') do |stdin, stdout, stderr|
      output = stdout.read
      error = stderr.read
      updates = output.split(/\r\n|\r|\n/, 5).last
      if output.include?('Software Update found')
        puts updates
        # %x(softwareupdate -i -a) - Commented out as we dont want to auto update yet.
      end
      puts '  - No new software updates available.' if error.include?('No new software available')
    end
  else
    puts '  - Skipped.'.colorize(:red)
  end
  break_output
end

.introObject



7
8
9
10
11
12
13
14
# File 'lib/osx.rb', line 7

def intro
  puts "  -------------------\n  # OSX Maintenance #\n  -------------------\n  EOS\n  break_output\nend\n".undent

.repair_disk_permissionsObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/osx.rb', line 59

def repair_disk_permissions
  puts '| Repairing OSX disk permissions...'.bold
  if run?
    Open3.popen2e('diskutil repairPermissions /') do |stdin, stdout_err, wait_thr|
      while line = stdout_err.gets
        puts line.delete!("\n").indent(4).colorize(:green)
        break_output
      end

      exit_status = wait_thr.value
      unless exit_status.success?
        abort "FAILED !!! #{cmd}"
      end
    end
  else
    puts '  - Skipped.'.colorize(:red)
    break_output
  end
end

.system_infoObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/osx.rb', line 16

def system_info
  cpu = %x(sysctl -n machdep.cpu.brand_string).delete!("\n")
  osx = %x(sw_vers | awk -F':\t' '{print $2}' | paste -d ' ' - - -).delete!("\n")
  hostname = %x(scutil --get ComputerName).delete!("\n")
  ram = %x(sysctl -n hw.memsize | awk '{print $0/1073741824" GB"}').delete!("\n")
  ruby = %x(ruby -e 'puts RUBY_DESCRIPTION').delete!("\n")

  break_output

  puts "    Mac OSX updater version: \#{DevOsxUpdater::VERSION}\n    ------------------------------\n\n    System information:\n      - CPU:   \#{cpu}\n      - OSX:   \#{osx}\n      - Host:  \#{hostname}\n      - RAM:   \#{ram}\n      - Ruby:  \#{ruby}\n  EOS\n\n  break_output\nend\n".undent.bold