Sha256: 27be76269a0f5ff36dc61e77d050ced8e26119d28891c4067138bf916c8f69fc

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 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") )
      system("sudo -u #{self.user.token} cp /tmp/authorized_keys /home/#{self.user.token}/.ssh/authorized_keys")
      File.delete('/tmp/authorized_keys')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meroku-2.0.8 frontend/app/models/publickey.rb