mirror of
https://github.com/genebean/dots.git
synced 2026-03-27 01:17:42 -04:00
All functions of 'bundle exec rake dots' now work
This commit is contained in:
parent
48b87f7744
commit
96d067d035
6 changed files with 69 additions and 23 deletions
21
bin/dots.rb
21
bin/dots.rb
|
|
@ -24,20 +24,7 @@ if OS.windows?
|
||||||
puts 'It seems you are on Windows'
|
puts 'It seems you are on Windows'
|
||||||
|
|
||||||
elsif OS.mac?
|
elsif OS.mac?
|
||||||
stdout, _stderr, _status = Open3.capture3('sw_vers -productVersion')
|
mac_vers
|
||||||
if Integer(stdout.strip.split('.')[0]) == 10
|
|
||||||
if Integer(stdout.strip.split('.')[1]) >= 12
|
|
||||||
puts "It seems you are on macOS #{stdout.strip}"
|
|
||||||
else
|
|
||||||
puts "It seems you are on OX X #{stdout.strip}"
|
|
||||||
end
|
|
||||||
|
|
||||||
elsif Integer(stdout.strip.split('.')[0]) < 10
|
|
||||||
puts "Wow... you're sure running an old os (#{stdout.strip} to be exact)"
|
|
||||||
else
|
|
||||||
abort("It seems you are on a Mac but I don't know what to do on \
|
|
||||||
v#{stdout.strip}")
|
|
||||||
end
|
|
||||||
|
|
||||||
@files_copy.concat Dir.glob("#{@dotroot}/copy/mac/*")
|
@files_copy.concat Dir.glob("#{@dotroot}/copy/mac/*")
|
||||||
@files_link.concat Dir.glob("#{@dotroot}/link/mac/*")
|
@files_link.concat Dir.glob("#{@dotroot}/link/mac/*")
|
||||||
|
|
@ -56,6 +43,7 @@ when 'copy'
|
||||||
@files_copy.each do |file|
|
@files_copy.each do |file|
|
||||||
unless @excludes.include?(File.basename(file))
|
unless @excludes.include?(File.basename(file))
|
||||||
puts "Copying #{file} to #{@home}/.#{File.basename(file)}"
|
puts "Copying #{file} to #{@home}/.#{File.basename(file)}"
|
||||||
|
copy_file(file, "#{@home}/.#{File.basename(file)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
@ -78,12 +66,11 @@ when 'link'
|
||||||
link_file(file, "#{@home}/.ssh/#{File.basename(file)}")
|
link_file(file, "#{@home}/.ssh/#{File.basename(file)}")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts 'no linking'
|
puts 'not linking'
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'install'
|
when 'install'
|
||||||
if @prompt.yes?('Are you sure you want to install your base packages?')
|
if @prompt.yes?('Are you sure you want to install your base packages?')
|
||||||
puts 'Here is where Puppet should be run.'
|
cmd.run('bundle exec rake dots:run_puppet')
|
||||||
cmd.run('bundle exec puppet --version')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,32 @@ def existing_symlink(source, destination)
|
||||||
# rubocop:enable Metrics/LineLength
|
# rubocop:enable Metrics/LineLength
|
||||||
end
|
end
|
||||||
|
|
||||||
def rename_file(source, destination)
|
# rubocop:disable Metrics/MethodLength
|
||||||
|
def rename_file(source, destination, action)
|
||||||
puts "#{destination} exists, renaming to #{destination}.predots"
|
puts "#{destination} exists, renaming to #{destination}.predots"
|
||||||
File.rename(destination, "#{destination}.predots")
|
File.rename(destination, "#{destination}.predots")
|
||||||
puts "Linking #{destination} to #{source}"
|
if action.eql?('link')
|
||||||
File.symlink(source, destination)
|
puts "Linking #{destination} to #{source}"
|
||||||
|
File.symlink(source, destination)
|
||||||
|
elsif action.eql?('copy')
|
||||||
|
puts "Copying #{destination} to #{source}"
|
||||||
|
FileUtils.cp_r(source, destination)
|
||||||
|
else
|
||||||
|
raise ArgumentError, "'#{action}' is not a valid action", backtrace
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
|
def copy_file(source, destination)
|
||||||
|
if File.exist?(destination)
|
||||||
|
if @prompt.yes?("#{destination} exists, do you want to replace it?")
|
||||||
|
rename_file(source, destination, 'copy')
|
||||||
|
else
|
||||||
|
puts "#{destination} is unchanged"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
FileUtils.cp_r(source, destination)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_file(source, destination)
|
def link_file(source, destination)
|
||||||
|
|
@ -24,9 +45,28 @@ def link_file(source, destination)
|
||||||
existing_symlink(source, destination)
|
existing_symlink(source, destination)
|
||||||
elsif File.exist?(destination)
|
elsif File.exist?(destination)
|
||||||
# this catches anything that is not a symlink
|
# this catches anything that is not a symlink
|
||||||
rename_file(source, destination)
|
rename_file(source, destination, 'link')
|
||||||
else
|
else
|
||||||
puts "Linking #{destination} to #{source}"
|
puts "Linking #{destination} to #{source}"
|
||||||
File.symlink(source, destination)
|
File.symlink(source, destination)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
||||||
|
def mac_vers
|
||||||
|
stdout, _stderr, _status = Open3.capture3('sw_vers -productVersion')
|
||||||
|
if Integer(stdout.strip.split('.')[0]) == 10
|
||||||
|
if Integer(stdout.strip.split('.')[1]) >= 12
|
||||||
|
puts "It seems you are on macOS #{stdout.strip}"
|
||||||
|
else
|
||||||
|
puts "It seems you are on OX X #{stdout.strip}"
|
||||||
|
end
|
||||||
|
|
||||||
|
elsif Integer(stdout.strip.split('.')[0]) < 10
|
||||||
|
puts "Wow... you're sure running an old os (#{stdout.strip} to be exact)"
|
||||||
|
else
|
||||||
|
abort("It seems you are on a Mac but I don't know what to do on \
|
||||||
|
v#{stdout.strip}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
||||||
|
|
|
||||||
11
puppet/production/hiera.yaml
Normal file
11
puppet/production/hiera.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
version: 5
|
||||||
|
defaults: # Used for any hierarchy level that omits these keys.
|
||||||
|
datadir : hieradata # This path is relative to hiera.yaml's directory.
|
||||||
|
data_hash : yaml_data # Use the built-in YAML backend.
|
||||||
|
|
||||||
|
hierarchy:
|
||||||
|
- name: "Per-node data"
|
||||||
|
path: "nodes/%{trusted.certname}.yaml"
|
||||||
|
- name: "Common data"
|
||||||
|
path: "common.yaml"
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
homedir: '/Users/gliverma'
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
---
|
|
||||||
|
|
@ -8,6 +8,8 @@ class profile::mac {
|
||||||
# creates => '/usr/local/bin/brew',
|
# creates => '/usr/local/bin/brew',
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
$homedir = lookup('homedir')
|
||||||
|
|
||||||
#Package { provider => 'homebrew' }
|
#Package { provider => 'homebrew' }
|
||||||
$homebrew_packages = [
|
$homebrew_packages = [
|
||||||
'bash-completion',
|
'bash-completion',
|
||||||
|
|
@ -40,7 +42,12 @@ class profile::mac {
|
||||||
]
|
]
|
||||||
|
|
||||||
package { $homebrew_packages:
|
package { $homebrew_packages:
|
||||||
ensure => installed,
|
ensure => 'installed',
|
||||||
provider => 'brew',
|
provider => 'brew',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vcsrepo { "${homedir}/.vim/bundle/Vundle.vim":
|
||||||
|
ensure => 'present',
|
||||||
|
provider => 'git',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue