def deploy(path): with repodir(path): if fpath.isdir('.sadm'): for sn in _deployScripts: script = fpath.join('.', '.sadm', sn) if fpath.isfile(script): callCheck(['/bin/sh', script])
def _configure(): global _configDone if _configDone: return sshcmd = ('ssh', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', '-o', 'BatchMode=yes', ) cmd = ['git', 'config', '--global', 'core.sshCommand', ' '.join(sshcmd)] callCheck(cmd) _configDone = True
def _autoconf(env): env.log('autoconf') tmpfh = mktmp(prefix=__name__) tmpfh.write('exit 128') tmpfh.close() tmpfn = tmpfh.name() env.debug("tmpfn %s" % tmpfn) try: call("munin-node-configure --shell >%s 2>&1" % tmpfn) callCheck("/bin/sh -eu %s" % tmpfn) finally: tmpfh.unlink()
def _cmd(service, action, *args, check=True): cmd = [] cmd.extend(_ctlcmd) cmd.extend(args) cmd.append(action) cmd.append(service) if check: return callCheck(cmd) return call(' '.join(cmd))
def uwsgi(): cmd = [ 'uwsgi', '--need-plugin', 'python3', '--set-ph', "sadm-home=%s" % sys.exec_prefix, '--touch-reload', path.join(path.sep, 'etc', 'opt', 'sadm', 'listen.cfg'), '--touch-reload', libdir.fpath('listen', 'wsgi', 'uwsgi.ini'), '--safe-pidfile', path.join(path.sep, 'tmp', 'sadm.listen.uwsgi.pid'), '--ini', libdir.fpath('listen', 'wsgi', 'uwsgi.ini'), ] try: callCheck(cmd) except CommandError as err: return err.rc return 0
def pull(path): with _repodir(path): callCheck(['git', 'pull'])
def checkout(path, commit): with _repodir(path): callCheck(['git', 'checkout', commit])
def clone(path, remote, branch): _configure() cmd = ['git', 'clone', '-b', branch, remote, path] callCheck(cmd)
def _call(cmd): callCheck(cmd, env = _cmdenv)
def _sched(taskfn): log.debug("exec prefix %s" % sys.exec_prefix) cmd = [_pycmd, _selfpath, taskfn] atcmd = "echo '%s' | at now" % ' '.join(cmd) log.debug("run: %s" % atcmd) callCheck(atcmd)