Module: OsCtld::SendReceive

Extended by:
OsCtl::Lib::Utils::File
Defined in:
lib/osctld/send_receive.rb

Defined Under Namespace

Modules: Commands Classes: Command, KeyChain, Log, Server, Tokens

Constant Summary collapse

USER =
'osctl-ct-receive'
UID =
Etc.getpwnam(USER).uid
SOCKET =
File.join(RunState::SEND_RECEIVE_DIR, 'control.sock')
AUTHORIZED_KEYS =
File.join(RunState::SEND_RECEIVE_DIR, 'authorized_keys')
HOOK =
File.join(RunState::SEND_RECEIVE_DIR, 'run')

Class Method Summary collapse

Class Method Details

.assets(add) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/osctld/send_receive.rb', line 48

def self.assets(add)
  add.symlink(
    HOOK,
    desc: 'Command run by remote node'
  )
  add.file(
    AUTHORIZED_KEYS,
    desc: 'Keys that are authorized to send containers to this node',
    user: UID,
    group: 0,
    mode: 0400
  )

  Server.assets(add)
end

.deployObject



27
28
29
30
31
32
33
# File 'lib/osctld/send_receive.rb', line 27

def self.deploy
  regenerate_file(AUTHORIZED_KEYS, 0400) do |new, old|
    DB::Pools.get.each { |pool| pool.send_receive_key_chain.deploy(new) }
  end

  File.chown(UID, 0, AUTHORIZED_KEYS)
end

.setupObject



17
18
19
20
21
# File 'lib/osctld/send_receive.rb', line 17

def self.setup
  Server.start

  replace_symlink(HOOK, OsCtld::hook_src('send-receive'))
end

.started_using_key(pool, name) ⇒ Object



35
36
37
38
39
# File 'lib/osctld/send_receive.rb', line 35

def self.started_using_key(pool, name)
  if pool.send_receive_key_chain.started_using_key(name)
    pool.send_receive_key_chain.save
  end
end

.stopObject



23
24
25
# File 'lib/osctld/send_receive.rb', line 23

def self.stop
  Server.stop
end

.stopped_using_key(pool, name) ⇒ Object



41
42
43
44
45
46
# File 'lib/osctld/send_receive.rb', line 41

def self.stopped_using_key(pool, name)
  if pool.send_receive_key_chain.stopped_using_key(name)
    pool.send_receive_key_chain.save
    deploy
  end
end