Brad Bishop | e36358c | 2016-06-08 22:03:59 -0400 | [diff] [blame] | 1 | # Common code for systemd based services. |
| 2 | # |
| 3 | # Prior to inheriting this class, recipes can define services like this: |
| 4 | # |
| 5 | # SYSTEMD_SERVICE_${PN} = "foo.service bar.socket baz@.service" |
| 6 | # |
| 7 | # and these files will be added to the main package if they exist. |
| 8 | # |
| 9 | # Alternatively this class can just be inherited and |
Brad Bishop | 62d676a | 2016-07-11 00:42:58 -0400 | [diff] [blame] | 10 | # ${PN}.service will be added to the main package. |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 11 | # |
| 12 | # Other variables: |
| 13 | # INHIBIT_SYSTEMD_RESTART_POLICY_${unit} |
| 14 | # Inhibit the warning that is displayed if a service unit without a |
| 15 | # restart policy is detected. |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 16 | # |
Brad Bishop | 58ab4a0 | 2016-08-17 15:58:26 -0400 | [diff] [blame] | 17 | # SYSTEMD_SUBSTITUTIONS = "var:val:file" |
| 18 | # A specification for making python style {format} string |
| 19 | # substitutions where: |
| 20 | # var: the format string to search for |
| 21 | # val: the value to replace with |
| 22 | # file: the file in which to make the substitution |
Brad Bishop | f815b2e | 2016-07-14 19:50:19 -0400 | [diff] [blame] | 23 | # |
Brad Bishop | 58700d1 | 2016-08-15 22:35:58 -0400 | [diff] [blame] | 24 | # SYSTEMD_USER_${PN}.service = "foo" |
| 25 | # SYSTEMD_USER_${unit}.service = "foo" |
| 26 | # The user for the unit/package. |
Brad Bishop | afb2e1b | 2016-08-08 09:29:20 -0400 | [diff] [blame] | 27 | # |
| 28 | # SYSTEMD_ENVIRONMENT_FILE_${PN} = "foo" |
| 29 | # One or more environment files to be installed. |
Brad Bishop | 0161aff | 2016-08-17 14:46:41 -0400 | [diff] [blame] | 30 | # |
| 31 | # SYSTEMD_LINK_${PN} = "tgt:name" |
| 32 | # A specification for installing arbitrary links in |
| 33 | # the ${systemd_system_unitdir} namespace, where: |
| 34 | # tgt: the link target |
| 35 | # name: the link name, relative to ${systemd_system_unitdir} |
Brad Bishop | 9ca070c | 2016-08-18 23:59:44 -0400 | [diff] [blame] | 36 | # |
| 37 | # SYSTEMD_OVERRIDE_${PN} = "src:dest" |
| 38 | # A specification for installing unit overrides where: |
| 39 | # src: the override file template |
| 40 | # dest: the override install location, relative to ${systemd_system_unitdir} |
| 41 | # |
| 42 | # Typically SYSTEMD_SUBSTITUTIONS is used to deploy a range |
| 43 | # of overrides from a single template file. To simply install |
| 44 | # a single override use "foo.conf:my-service.d/foo.conf" |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 45 | |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 46 | |
| 47 | inherit obmc-phosphor-utils |
Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 48 | inherit systemd |
Brad Bishop | f815b2e | 2016-07-14 19:50:19 -0400 | [diff] [blame] | 49 | inherit useradd |
Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 50 | |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 51 | _INSTALL_SD_UNITS="" |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 52 | SYSTEMD_DEFAULT_TARGET ?= "obmc-standby.target" |
Brad Bishop | afb2e1b | 2016-08-08 09:29:20 -0400 | [diff] [blame] | 53 | envfiledir ?= "${sysconfdir}/default" |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 54 | |
Brad Bishop | f815b2e | 2016-07-14 19:50:19 -0400 | [diff] [blame] | 55 | # Big ugly hack to prevent useradd.bbclass post-parse sanity checker failure. |
| 56 | # If there are users to be added, we'll add them in our post-parse. |
| 57 | # If not...there don't seem to be any ill effects... |
| 58 | USERADD_PACKAGES ?= " " |
| 59 | USERADD_PARAM_${PN} ?= ";" |
| 60 | |
Brad Bishop | e36358c | 2016-06-08 22:03:59 -0400 | [diff] [blame] | 61 | |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 62 | def SystemdUnit(unit): |
| 63 | class Unit(object): |
| 64 | def __init__(self, unit): |
| 65 | self.unit = unit |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 66 | |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 67 | def __getattr__(self, item): |
| 68 | if item is 'name': |
| 69 | return self.unit |
| 70 | if item is 'is_activated': |
| 71 | return self.unit.startswith('dbus-') |
| 72 | if item is 'is_template': |
| 73 | return '@.' in self.unit |
| 74 | if item is 'is_instance': |
| 75 | return '@' in self.unit and not self.is_template |
| 76 | if item in ['is_service', 'is_target']: |
| 77 | return self.unit.split('.')[-1] == item |
| 78 | if item is 'base': |
| 79 | cls = self.unit.split('.')[-1] |
| 80 | base = self.unit.replace('dbus-', '') |
| 81 | base = base.replace('.%s' % cls, '') |
| 82 | if self.is_instance: |
Robert Lippert | 0ccabae | 2017-11-28 10:59:31 -0800 | [diff] [blame] | 83 | base = base.replace('@%s' % self.instance, '') |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 84 | if self.is_template: |
| 85 | base = base.rstrip('@') |
| 86 | return base |
| 87 | if item is 'instance' and self.is_instance: |
| 88 | inst = self.unit.rsplit('@')[-1] |
| 89 | return inst.rsplit('.')[0] |
| 90 | if item is 'template' and self.is_instance: |
| 91 | cls = self.unit.split('.')[-1] |
| 92 | return '%s@.%s' % (self.base, cls) |
| 93 | if item is 'template' and self.is_template: |
| 94 | return '.'.join(self.base.split('@')[:-1]) |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 95 | |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 96 | raise AttributeError(item) |
| 97 | return Unit(unit) |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 98 | |
| 99 | |
| 100 | def systemd_parse_unit(d, path): |
Saqib Khan | c140158 | 2017-03-07 06:59:20 -0600 | [diff] [blame] | 101 | import configparser |
| 102 | parser = configparser.SafeConfigParser(strict=False) |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 103 | parser.optionxform = str |
| 104 | parser.read('%s' % path) |
| 105 | return parser |
| 106 | |
| 107 | |
Brad Bishop | e36358c | 2016-06-08 22:03:59 -0400 | [diff] [blame] | 108 | python() { |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 109 | def check_sd_unit(d, unit): |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 110 | searchpaths = d.getVar('FILESPATH', True) |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 111 | path = bb.utils.which(searchpaths, '%s' % unit.name) |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 112 | if not os.path.isfile(path): |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 113 | bb.fatal('Did not find unit file "%s"' % unit.name) |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 114 | |
| 115 | parser = systemd_parse_unit(d, path) |
| 116 | inhibit = listvar_to_list(d, 'INHIBIT_SYSTEMD_RESTART_POLICY_WARNING') |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 117 | if unit.is_service and \ |
| 118 | not unit.is_template and \ |
| 119 | unit.name not in inhibit and \ |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 120 | not parser.has_option('Service', 'Restart'): |
| 121 | bb.warn('Systemd unit \'%s\' does not ' |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 122 | 'have a restart policy defined.' % unit.name) |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 123 | |
| 124 | |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 125 | def add_default_subs(d, file): |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 126 | for x in [ |
| 127 | 'base_bindir', |
| 128 | 'bindir', |
| 129 | 'sbindir', |
Brad Bishop | afb2e1b | 2016-08-08 09:29:20 -0400 | [diff] [blame] | 130 | 'envfiledir', |
Xo Wang | d509c4c | 2017-01-18 17:55:50 -0800 | [diff] [blame] | 131 | 'sysconfdir', |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 132 | 'SYSTEMD_DEFAULT_TARGET' ]: |
Brad Bishop | 58ab4a0 | 2016-08-17 15:58:26 -0400 | [diff] [blame] | 133 | set_append(d, 'SYSTEMD_SUBSTITUTIONS', |
| 134 | '%s:%s:%s' % (x, d.getVar(x, True), file)) |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 135 | |
Brad Bishop | f815b2e | 2016-07-14 19:50:19 -0400 | [diff] [blame] | 136 | |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 137 | def add_sd_unit(d, unit, pkg): |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 138 | name = unit.name |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 139 | unit_dir = d.getVar('systemd_system_unitdir', True) |
| 140 | set_append(d, 'SRC_URI', 'file://%s' % name) |
| 141 | set_append(d, 'FILES_%s' % pkg, '%s/%s' % (unit_dir, name)) |
| 142 | set_append(d, '_INSTALL_SD_UNITS', name) |
| 143 | add_default_subs(d, name) |
| 144 | |
| 145 | |
| 146 | def add_sd_user(d, file, pkg): |
Brad Bishop | f815b2e | 2016-07-14 19:50:19 -0400 | [diff] [blame] | 147 | opts = [ |
| 148 | '--system', |
| 149 | '--home', |
| 150 | '/', |
| 151 | '--no-create-home', |
| 152 | '--shell /sbin/nologin', |
| 153 | '--user-group'] |
| 154 | |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 155 | var = 'SYSTEMD_USER_%s' % file |
Brad Bishop | 58700d1 | 2016-08-15 22:35:58 -0400 | [diff] [blame] | 156 | user = listvar_to_list(d, var) |
| 157 | if len(user) is 0: |
| 158 | var = 'SYSTEMD_USER_%s' % pkg |
| 159 | user = listvar_to_list(d, var) |
| 160 | if len(user) is not 0: |
| 161 | if len(user) is not 1: |
| 162 | bb.fatal('Too many users assigned to %s: \'%s\'' % (var, ' '.join(user))) |
| 163 | |
| 164 | user = user[0] |
Brad Bishop | 58ab4a0 | 2016-08-17 15:58:26 -0400 | [diff] [blame] | 165 | set_append(d, 'SYSTEMD_SUBSTITUTIONS', |
| 166 | 'USER:%s:%s' % (user, file)) |
Brad Bishop | 58700d1 | 2016-08-15 22:35:58 -0400 | [diff] [blame] | 167 | if user not in d.getVar('USERADD_PARAM_%s' % pkg, True): |
| 168 | set_append( |
| 169 | d, |
| 170 | 'USERADD_PARAM_%s' % pkg, |
| 171 | '%s' % (' '.join(opts + [user])), |
| 172 | ';') |
Brad Bishop | f815b2e | 2016-07-14 19:50:19 -0400 | [diff] [blame] | 173 | if pkg not in d.getVar('USERADD_PACKAGES', True): |
| 174 | set_append(d, 'USERADD_PACKAGES', pkg) |
| 175 | |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 176 | |
Brad Bishop | afb2e1b | 2016-08-08 09:29:20 -0400 | [diff] [blame] | 177 | def add_env_file(d, name, pkg): |
| 178 | set_append(d, 'SRC_URI', 'file://%s' % name) |
| 179 | set_append(d, 'FILES_%s' % pkg, '%s/%s' \ |
| 180 | % (d.getVar('envfiledir', True), name)) |
| 181 | set_append(d, '_INSTALL_ENV_FILES', name) |
| 182 | |
| 183 | |
Brad Bishop | 0161aff | 2016-08-17 14:46:41 -0400 | [diff] [blame] | 184 | def install_link(d, spec, pkg): |
| 185 | tgt, dest = spec.split(':') |
| 186 | |
| 187 | set_append(d, 'FILES_%s' % pkg, '%s/%s' \ |
| 188 | % (d.getVar('systemd_system_unitdir', True), dest)) |
| 189 | set_append(d, '_INSTALL_LINKS', spec) |
| 190 | |
| 191 | |
Brad Bishop | 9ca070c | 2016-08-18 23:59:44 -0400 | [diff] [blame] | 192 | def add_override(d, spec, pkg): |
| 193 | tmpl, dest = spec.split(':') |
| 194 | set_append(d, '_INSTALL_OVERRIDES', '%s' % spec) |
| 195 | unit_dir = d.getVar('systemd_system_unitdir', True) |
| 196 | set_append(d, 'FILES_%s' % pkg, '%s/%s' % (unit_dir, dest)) |
| 197 | add_default_subs(d, '%s' % dest) |
| 198 | add_sd_user(d, '%s' % dest, pkg) |
| 199 | |
| 200 | |
Brad Bishop | 038b44b | 2018-01-25 07:00:27 -0500 | [diff] [blame] | 201 | if d.getVar('CLASSOVERRIDE', True) != 'class-target': |
| 202 | return |
| 203 | |
| 204 | d.appendVarFlag('do_install', 'postfuncs', ' systemd_do_postinst') |
| 205 | |
Brad Bishop | 62d676a | 2016-07-11 00:42:58 -0400 | [diff] [blame] | 206 | pn = d.getVar('PN', True) |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 207 | if d.getVar('SYSTEMD_SERVICE_%s' % pn, True) is None: |
| 208 | d.setVar('SYSTEMD_SERVICE_%s' % pn, '%s.service' % pn) |
Brad Bishop | e36358c | 2016-06-08 22:03:59 -0400 | [diff] [blame] | 209 | |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 210 | for pkg in listvar_to_list(d, 'SYSTEMD_PACKAGES'): |
Brad Bishop | 1864529 | 2016-08-16 08:18:07 -0400 | [diff] [blame] | 211 | svc = listvar_to_list(d, 'SYSTEMD_SERVICE_%s' % pkg) |
| 212 | svc = [SystemdUnit(x) for x in svc] |
| 213 | tmpl = [x.template for x in svc if x.is_instance] |
| 214 | tmpl = list(set(tmpl)) |
| 215 | tmpl = [SystemdUnit(x) for x in tmpl] |
| 216 | svc = [x for x in svc if not x.is_instance] |
| 217 | |
| 218 | for unit in tmpl + svc: |
Brad Bishop | 687146f | 2016-07-11 13:05:26 -0400 | [diff] [blame] | 219 | check_sd_unit(d, unit) |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 220 | add_sd_unit(d, unit, pkg) |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 221 | add_sd_user(d, unit.name, pkg) |
Brad Bishop | afb2e1b | 2016-08-08 09:29:20 -0400 | [diff] [blame] | 222 | for name in listvar_to_list(d, 'SYSTEMD_ENVIRONMENT_FILE_%s' % pkg): |
| 223 | add_env_file(d, name, pkg) |
Brad Bishop | 0161aff | 2016-08-17 14:46:41 -0400 | [diff] [blame] | 224 | for spec in listvar_to_list(d, 'SYSTEMD_LINK_%s' % pkg): |
| 225 | install_link(d, spec, pkg) |
Brad Bishop | 9ca070c | 2016-08-18 23:59:44 -0400 | [diff] [blame] | 226 | for spec in listvar_to_list(d, 'SYSTEMD_OVERRIDE_%s' % pkg): |
| 227 | add_override(d, spec, pkg) |
Brad Bishop | e36358c | 2016-06-08 22:03:59 -0400 | [diff] [blame] | 228 | } |
Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 229 | |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 230 | |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 231 | python systemd_do_postinst() { |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 232 | def make_subs(d): |
Brad Bishop | 58ab4a0 | 2016-08-17 15:58:26 -0400 | [diff] [blame] | 233 | all_subs = {} |
| 234 | for spec in listvar_to_list(d, 'SYSTEMD_SUBSTITUTIONS'): |
| 235 | spec, file = spec.rsplit(':', 1) |
| 236 | all_subs.setdefault(file, []).append(spec) |
| 237 | |
Saqib Khan | cef980a | 2017-03-07 07:15:29 -0600 | [diff] [blame] | 238 | for f, v in all_subs.items(): |
Brad Bishop | 58ab4a0 | 2016-08-17 15:58:26 -0400 | [diff] [blame] | 239 | subs = dict([ x.split(':') for x in v]) |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 240 | if not subs: |
| 241 | continue |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 242 | |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 243 | path = d.getVar('D', True) |
| 244 | path += d.getVar('systemd_system_unitdir', True) |
| 245 | path += '/%s' % f |
| 246 | with open(path, 'r') as fd: |
| 247 | content = fd.read() |
| 248 | with open(path, 'w+') as fd: |
| 249 | try: |
| 250 | fd.write(content.format(**subs)) |
| 251 | except KeyError as e: |
| 252 | bb.fatal('No substitution found for %s in ' |
| 253 | 'file \'%s\'' % (e, f)) |
| 254 | |
| 255 | |
Brad Bishop | afb2e1b | 2016-08-08 09:29:20 -0400 | [diff] [blame] | 256 | def install_envs(d): |
| 257 | install_dir = d.getVar('D', True) |
| 258 | install_dir += d.getVar('envfiledir', True) |
| 259 | searchpaths = d.getVar('FILESPATH', True) |
| 260 | |
| 261 | for f in listvar_to_list(d, '_INSTALL_ENV_FILES'): |
| 262 | src = bb.utils.which(searchpaths, f) |
| 263 | if not os.path.isfile(src): |
| 264 | bb.fatal('Did not find SYSTEMD_ENVIRONMENT_FILE:' |
| 265 | '\'%s\'' % src) |
| 266 | |
| 267 | dest = os.path.join(install_dir, f) |
| 268 | parent = os.path.dirname(dest) |
| 269 | if not os.path.exists(parent): |
| 270 | os.makedirs(parent) |
| 271 | |
| 272 | with open(src, 'r') as fd: |
| 273 | content = fd.read() |
| 274 | with open(dest, 'w+') as fd: |
| 275 | fd.write(content) |
| 276 | |
| 277 | |
Brad Bishop | 0161aff | 2016-08-17 14:46:41 -0400 | [diff] [blame] | 278 | def install_links(d): |
| 279 | install_dir = d.getVar('D', True) |
| 280 | install_dir += d.getVar('systemd_system_unitdir', True) |
| 281 | |
| 282 | for spec in listvar_to_list(d, '_INSTALL_LINKS'): |
| 283 | tgt, dest = spec.split(':') |
| 284 | dest = os.path.join(install_dir, dest) |
| 285 | parent = os.path.dirname(dest) |
| 286 | if not os.path.exists(parent): |
| 287 | os.makedirs(parent) |
| 288 | os.symlink(tgt, dest) |
| 289 | |
| 290 | |
Brad Bishop | 9ca070c | 2016-08-18 23:59:44 -0400 | [diff] [blame] | 291 | def install_overrides(d): |
| 292 | install_dir = d.getVar('D', True) |
| 293 | install_dir += d.getVar('systemd_system_unitdir', True) |
| 294 | searchpaths = d.getVar('FILESPATH', True) |
| 295 | |
| 296 | for spec in listvar_to_list(d, '_INSTALL_OVERRIDES'): |
| 297 | tmpl, dest = spec.split(':') |
| 298 | source = bb.utils.which(searchpaths, tmpl) |
| 299 | if not os.path.isfile(source): |
| 300 | bb.fatal('Did not find SYSTEMD_OVERRIDE ' |
| 301 | 'template: \'%s\'' % source) |
| 302 | |
| 303 | dest = os.path.join(install_dir, dest) |
| 304 | parent = os.path.dirname(dest) |
| 305 | if not os.path.exists(parent): |
| 306 | os.makedirs(parent) |
| 307 | |
| 308 | with open(source, 'r') as fd: |
| 309 | content = fd.read() |
| 310 | with open('%s' % dest, 'w+') as fd: |
| 311 | fd.write(content) |
| 312 | |
| 313 | |
Brad Bishop | 0161aff | 2016-08-17 14:46:41 -0400 | [diff] [blame] | 314 | install_links(d) |
Brad Bishop | afb2e1b | 2016-08-08 09:29:20 -0400 | [diff] [blame] | 315 | install_envs(d) |
Brad Bishop | 9ca070c | 2016-08-18 23:59:44 -0400 | [diff] [blame] | 316 | install_overrides(d) |
Brad Bishop | 522234c | 2016-08-17 15:42:31 -0400 | [diff] [blame] | 317 | make_subs(d) |
Brad Bishop | 51528fe | 2016-07-14 19:34:06 -0400 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | |
Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 321 | do_install_append() { |
Brad Bishop | e36358c | 2016-06-08 22:03:59 -0400 | [diff] [blame] | 322 | # install systemd service/socket/template files |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 323 | [ -z "${_INSTALL_SD_UNITS}" ] || \ |
Brad Bishop | e36358c | 2016-06-08 22:03:59 -0400 | [diff] [blame] | 324 | install -d ${D}${systemd_system_unitdir} |
Brad Bishop | 9dc5671 | 2016-07-07 15:56:02 -0400 | [diff] [blame] | 325 | for s in ${_INSTALL_SD_UNITS}; do |
| 326 | install -m 0644 ${WORKDIR}/$s \ |
| 327 | ${D}${systemd_system_unitdir}/$s |
Brad Bishop | e36358c | 2016-06-08 22:03:59 -0400 | [diff] [blame] | 328 | sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \ |
| 329 | -e 's,@BINDIR@,${bindir},g' \ |
| 330 | -e 's,@SBINDIR@,${sbindir},g' \ |
| 331 | ${D}${systemd_system_unitdir}/$s |
| 332 | done |
Brad Bishop | 93fb535 | 2015-09-09 03:59:20 +0000 | [diff] [blame] | 333 | } |