Sha256: 58930bee84af97cb0b19f62b7b412929668c45f64554a223a075f4485af460c3

Contents?: true

Size: 578 Bytes

Versions: 12

Compression:

Stored size: 578 Bytes

Contents

class Publickey < ApplicationRecord
  belongs_to :user
  after_commit :do_refresh, on: [:create]

  # Updates /home/git/.ssh/authorized_keys
  # called when something added/?/etc to publickeys table 
  def do_refresh
    Rails.logger.debug "DB8 publickey.rb:def self.refresh called"
    if Publickey.all.size > 0
      File.write('/tmp/authorized_keys', Publickey.pluck(:data).join("\n") )
      Cmd.run(%Q[sudo -u #{self.user.apiusername} cp /tmp/authorized_keys /home/#{self.user.apiusername}/.ssh/authorized_keys])
      File.delete('/tmp/authorized_keys')
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
meroku-2.0.22 frontend/app/models/publickey.rb
meroku-2.0.21 frontend/app/models/publickey.rb
meroku-2.0.20 frontend/app/models/publickey.rb
meroku-2.0.19 frontend/app/models/publickey.rb
meroku-2.0.18 frontend/app/models/publickey.rb
meroku-2.0.17 frontend/app/models/publickey.rb
meroku-2.0.16 frontend/app/models/publickey.rb
meroku-2.0.14 frontend/app/models/publickey.rb
meroku-2.0.13 frontend/app/models/publickey.rb
meroku-2.0.11 frontend/app/models/publickey.rb
meroku-2.0.10 frontend/app/models/publickey.rb
meroku-2.0.9 frontend/app/models/publickey.rb