Class: DanarchyDeploy::System::Debian
- Inherits:
-
Object
- Object
- DanarchyDeploy::System::Debian
- Defined in:
- lib/danarchy_deploy/system/debian.rb
Class Method Summary collapse
Class Method Details
.install_gpgkeys(gpgkeys, options) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/danarchy_deploy/system/debian.rb', line 35 def self.install_gpgkeys(gpgkeys, ) gpgkeys.each do |url| puts "\n > Acquiring GPG key from: #{url}" tmpfile = '/var/tmp/' + `date +%s`.chomp + '.gpgkey.tmp' gpgkey = Net::HTTP.get(URI(url)) if ! gpgkey abort(' ! GPG key download failed!') else puts " |+ GPG key successfully downloaded!" File.write(tmpfile, gpgkey) abort(" ! Failed to write tmpfile for url: #{url} => #{tmpfile}") if ! File.exist?(tmpfile) # Silence noise about non-TTY terminal thanks to apt-key gpgcmd = "export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=false; apt-key add -qq #{tmpfile}" gpg_result = DanarchyDeploy::Helpers.run_command(gpgcmd, { quiet: true }) if gpg_result[:stderr] abort(" ! Failed to write key for: #{url}") elsif gpg_result[:stdout] puts " |+ GPG Key saved!" end end end end |
.new(deployment, options) ⇒ Object
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 |
# File 'lib/danarchy_deploy/system/debian.rb', line 6 def self.new(deployment, ) puts "\n" + self.name puts "#{deployment[:os].capitalize} detected! Using apt." if deployment[:apt] if deployment[:apt][:templates] puts "\nChecking Apt configs." DanarchyDeploy::Templater.new(deployment[:apt][:templates], ) end if deployment[:apt][:gpgkeys] puts "\nInstalling Apt GPG Keys." install_gpgkeys(deployment[:apt][:gpgkeys], ) end end nonint = 'export DEBIAN_FRONTEND=noninteractive ; ' installer = nonint + 'apt-get install -y ' installer += '--dry-run ' if [:pretend] updater = nonint + 'apt-get upgrade -y ' cleaner = nonint + 'apt-get autoclean -y ' puts "\nUpdating Apt repos..." DanarchyDeploy::Helpers.run_command(nonint + 'apt-get update', ) [installer, updater, cleaner] end |