Module: OsCtld::RunState

Defined in:
lib/osctld/run_state.rb

Constant Summary collapse

RUNDIR =
'/run/osctl'
POOL_DIR =
File.join(RUNDIR, 'pools')
USER_CONTROL_DIR =
File.join(RUNDIR, 'user-control')
MIGRATION_DIR =
File.join(RUNDIR, 'migration')
REPOSITORY_DIR =
File.join(RUNDIR, 'repository')
CONFIG_DIR =
File.join(RUNDIR, 'configs')
LXC_CONFIG_DIR =
File.join(CONFIG_DIR, 'lxc')
APPARMOR_DIR =
File.join(CONFIG_DIR, 'apparmor')

Class Method Summary collapse

Class Method Details

.assets(add) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/osctld/run_state.rb', line 38

def self.assets(add)
  add.directory(
    RunState::RUNDIR,
    desc: 'Runtime configuration',
    user: 0,
    group: 0,
    mode: 0711
  )
  add.directory(
    RunState::POOL_DIR,
    desc: 'Runtime pool configuration',
    user: 0,
    group: 0,
    mode: 0711
  )
  add.directory(
    RunState::USER_CONTROL_DIR,
    desc: 'Runtime user configuration',
    user: 0,
    group: 0,
    mode: 0711
  )
  add.directory(
    RunState::MIGRATION_DIR,
    desc: 'Migration configuration',
    user: Migration::UID,
    group: 0,
    mode: 0100,
    optional: true
  )
  add.directory(
    RunState::REPOSITORY_DIR,
    desc: 'Home directory for the repository user',
    user: Repository::UID,
    group: 0,
    mode: 0700
  )
  add.directory(
    RunState::CONFIG_DIR,
    desc: 'Global LXC configuration files',
    user: 0,
    group: 0,
    mode: 0755
  )
  add.directory(
    RunState::APPARMOR_DIR,
    desc: 'Shared AppArmor files',
    user: 0,
    group: 0,
    mode: 0755
  )

  Migration.assets(add)
end

.createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/osctld/run_state.rb', line 12

def self.create
  Dir.mkdir(RUNDIR, 0711) unless Dir.exists?(RUNDIR)
  Dir.mkdir(POOL_DIR, 0711) unless Dir.exists?(POOL_DIR)
  Dir.mkdir(USER_CONTROL_DIR, 0711) unless Dir.exists?(USER_CONTROL_DIR)

  unless Dir.exists?(MIGRATION_DIR)
    Dir.mkdir(MIGRATION_DIR, 0100)
    File.chown(Migration::UID, 0, MIGRATION_DIR)
  end

  # Bundler needs to have some place to store its temp files
  unless Dir.exists?(REPOSITORY_DIR)
    Dir.mkdir(REPOSITORY_DIR, 0700)
    File.chown(Repository::UID, 0, REPOSITORY_DIR)
  end

  # LXC configs
  Dir.mkdir(CONFIG_DIR, 0755) unless Dir.exists?(CONFIG_DIR)
  Dir.mkdir(LXC_CONFIG_DIR, 0755) unless Dir.exists?(LXC_CONFIG_DIR)

  Lxc.install_lxc_configs(LXC_CONFIG_DIR)

  # AppArmor files
  Dir.mkdir(APPARMOR_DIR, 0755) unless Dir.exists?(APPARMOR_DIR)
end