diff --git a/frappyman.py b/frappyman.py index 6d35c75..f84f678 100644 --- a/frappyman.py +++ b/frappyman.py @@ -104,13 +104,14 @@ class FrappyManager(ServiceManager): raise UsageError('no wildcards allowed with %s start' % self.group) if cfg and not service and len(self.services) != 1: raise UsageError('need service to start (one of %s)' % ', '.join(self.services)) - if cfg.startswith('~'): - cfg = cfg[1:] - seacfg = self.cfg_from_sea(ins).get(service) - if seacfg: - cfg = seacfg - if not cfg: - return + # TODO: check if we really need this + # if (cfg or '').startswith('~'): + # cfg = cfg[1:] + # seacfg = self.cfg_from_sea(ins).get(service) + # if seacfg: + # cfg = seacfg + # if not cfg: + # return super().do_start(ins, service, cfg, restart, wait, logger) def do_restart(self, ins, service=None, cfg=None, logger=None): @@ -243,16 +244,24 @@ class FrappyManager(ServiceManager): sea.get_info() cfgs = sea.get_cfg(ins, 'sea').split('/') result = {} - if cfgs[0] and cfgs[0] in self.all_cfg(ins, 'main'): - result['main'] = cfgs[0] + + def check_cfg_file(self, cfg, allcfg, stick=''): + if cfg in allcfg: + return cfg + if cfg + stick in allcfg: + return cfg + stick + return cfg + '?' + + if cfgs[0]: + result['main'] = check_cfg_file(cfgs[0], self.all_cfg(ins, 'main')) allsticks = self.all_cfg(ins, 'stick') - stick = cfgs[:2][-1] - if stick: - for s in (stick + 'stick', stick): - if s in allsticks: - result['stick'] = s - break - addons = [a for a in cfgs[2:] if a in self.all_cfg(ins, 'addons')] + if len(cfgs) > 1: + stick = cfgs[1] + if stick: + if stick + 'stick' in allsticks: + cfg = stick + 'stick' + result['stick'] = check_cfg_file(cfg, allsticks) + addons = [check_cfg_file(a) for a in cfgs[2:]] if addons: result['addons'] = ','.join(addons) return result