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'.freeze
- 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')
- MUTEX =
Mutex.new
Class Method Summary
collapse
Class Method Details
.assets(add) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/osctld/send_receive.rb', line 49
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: 0o400,
optional: true
)
Server.assets(add)
end
|
.deploy ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/osctld/send_receive.rb', line 29
def self.deploy
sync do
regenerate_file(AUTHORIZED_KEYS, 0o400) do |new, _old|
DB::Pools.get.each { |pool| pool.send_receive_key_chain.deploy(new) }
end
File.chown(UID, 0, AUTHORIZED_KEYS)
end
end
|
.setup ⇒ Object
19
20
21
22
23
|
# File 'lib/osctld/send_receive.rb', line 19
def self.setup
Server.start
replace_symlink(HOOK, OsCtld.hook_src('send-receive'))
end
|
.started_using_key(pool, name) ⇒ Object
39
40
41
|
# File 'lib/osctld/send_receive.rb', line 39
def self.started_using_key(pool, name)
pool.send_receive_key_chain.started_using_key(name)
end
|
.stop ⇒ Object
25
26
27
|
# File 'lib/osctld/send_receive.rb', line 25
def self.stop
Server.stop
end
|
.stopped_using_key(pool, name) ⇒ Object
43
44
45
46
47
|
# File 'lib/osctld/send_receive.rb', line 43
def self.stopped_using_key(pool, name)
sync do
deploy if pool.send_receive_key_chain.stopped_using_key(name)
end
end
|
.sync ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/osctld/send_receive.rb', line 66
def self.sync(&)
if MUTEX.owned?
yield
else
MUTEX.synchronize(&)
end
end
|