From 4720a0e94bc77cc42b7ffdbc62aec9feb1386cc8 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 2 Mar 2016 21:00:53 +0100 Subject: Execute the scripts manually Only use run-parts to get the script names and execute the scripts one by one. --- spline-startup | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/spline-startup b/spline-startup index 746e149..d3e1ef3 100755 --- a/spline-startup +++ b/spline-startup @@ -110,27 +110,41 @@ class SplineStartup(object): else: return 0 + def _get_scripts(self, action, directory): + args = [] + if action == 'stop': + args.append('--reverse') + cmd = ['run-parts', '--list'] + args + ['--', directory] + + self._pinfo('Getting scripts: %s' % ' '.join(cmd)) + proc = Popen(cmd, stdout=PIPE, stderr=STDOUT) + output, _ = proc.communicate() + return output.strip().splitlines() + def _run_scripts(self, user, action, use_su=True): self._pdebug("Running scripts for user '%s'" % user.pw_name) directory = os.path.join(user.pw_dir, 'etc', 'rc.d') - args = ['--arg=%s' % quote(action)] - if action == 'stop': - args.append('--reverse') - if not os.path.isdir(directory): return True - if use_su: - returnvalue = self._call(['su', '-', user.pw_name, - '-s', '/bin/sh', - '-c', 'run-parts %s -- %s' % - (' '.join(args), - quote(directory))]) - else: - returnvalue = self._call(['run-parts'] + args + ['--', directory]) + scripts = self._get_scripts(action, directory) + + self._pinfo('Running scripts: %r' % scripts) + error = False + for script in scripts: + if use_su: + exitcode = self._call(['su', '-', user.pw_name, + '-s', '/bin/sh', + '-c', '%s %s' % (quote(script), + quote(action))]) + else: + exitcode = self._call([script, action]) + + if exitcode != 0: + error = True - return returnvalue == 0 + return error == False def run(self): if not is_root(): -- cgit v1.2.3-1-g7c22