Ejemplo n.º 1
0
def __stop(service):
	if __isRunning(service):
		with hide('everything'):
			execute('service %s stop' % service)
		done("echo 'stopped         : %s'" % service)
	else:
		already("echo 'already stopped : %s'" % service)
Ejemplo n.º 2
0
def __off(service):
	if __isOn(service):
		with hide('everything'):
			execute('chkconfig %s off' % service)
		done("echo 'turn off        : %s'" % service)
	else:
		already("echo 'already off     : %s'" % service)
Ejemplo n.º 3
0
def echo_to_spool(user, line):
    path = '%s/%s' % (spool, user)
    if isExistsLine(path, line):
        error('echo already exists : %s in %s' % (line, path))
    else:
        execute("echo '%s' >> %s" % (line, path))
        __chown(user, path)
        done("echo -n 'create shell : '; ls -l %s" % path)
Ejemplo n.º 4
0
def __addRepository(name, url):
    package = __repository(name)

    if __doesNotHasRepository(package):
        with hide('everything'):
            execute('rpm -iv %s' % url)
        done("echo 'install complete  : %s'" % __repository(name))
    else:
        already("echo 'already installed : %s'" % package)
Ejemplo n.º 5
0
def __addRepository(name, url):
	package = __repository(name)

	if __doesNotHasRepository(package):
		with hide('everything'):
			execute('rpm -iv %s' % url)
		done("echo 'install complete  : %s'" % __repository(name))
	else:
		already("echo 'already installed : %s'" % package)
Ejemplo n.º 6
0
def __install(package, repositories):
	if __isNotInstalled(package):
		with hide('stdout'):
			stdout = execute('yum install -y %s%s; true' % (__enablerepos(repositories), package))
			if 'Error: Nothing to do' in stdout:
				error("echo 'install error     : No package %s available.'" % package)
			else:
				done("echo 'install complete  : %s'" % __version(package))
	else:
		already("echo 'already installed : %s'" % __version(package))
Ejemplo n.º 7
0
def __start(service):
	if __isRunning(service):
		already("echo 'already started : %s'" % service)
	else:
		with hide('everything'):
			stdout = execute('service %s start; true' % service)
			if 'unrecognized' in stdout:
				error("echo 'start error     : %s is unrecognized'" % service)
			else:
				done("echo 'started         : %s'" % service)
Ejemplo n.º 8
0
def __on(service):
	if __isOn(service):
		already("echo 'already on      : %s'" % service)
	else:
		with hide('everything'):
			stdout = execute('chkconfig %s on; true' % service)
			if 'No such file or directory' in stdout:
				error("echo 'turn on error   : %s is unrecognized'" % service)
			else:
				done("echo 'turn on         : %s'" % service)
Ejemplo n.º 9
0
def echo_to_directory(user, directory, shell_line, shell_name):
    path = '%s/%s' % (directory, shell_name)

    if isExists(path):
        error('echo already exists : %s' % path)
    else:
        execute("echo '%s' > %s" % (shell_line, path))
        __chmod(path)
        __chown(user, path)
        done("echo -n 'create shell : '; ls -l %s" % path)
Ejemplo n.º 10
0
def put_to_directory(user, directory, shell, sudo=False):
    path = '%s/%s' % (directory, os.path.basename(shell))

    if isExists(path):
        error('echo already exists : %s' % path)
    else:
        put(shell, directory, use_sudo=sudo)
        __chmod(path)
        __chown(user, path)
        done("echo -n 'send shell   : '; ls -l %s" % path)
Ejemplo n.º 11
0
def __install(package, repositories):
    if __isNotInstalled(package):
        with hide('stdout'):
            stdout = execute('yum install -y %s%s; true' %
                             (__enablerepos(repositories), package))
            if 'Error: Nothing to do' in stdout:
                error("echo 'install error     : No package %s available.'" %
                      package)
            else:
                done("echo 'install complete  : %s'" % __version(package))
    else:
        already("echo 'already installed : %s'" % __version(package))
Ejemplo n.º 12
0
def generate():
	from result import done, already

	dst = '%s/my_configure.py' % os.getcwd()
	src = os.path.join(os.path.dirname(__file__), 'default_configure.py')

	if os.path.exists(dst):
		already('echo already exists  : %s' % dst)
	else:
		with hide('everything'):
			local('cp %s %s' % (src, dst))
		done('echo cteate complete : %s' % dst)
Ejemplo n.º 13
0
def generate():
    from result import done, already

    dst = '%s/my_configure.py' % os.getcwd()
    src = os.path.join(os.path.dirname(__file__), 'default_configure.py')

    if os.path.exists(dst):
        already('echo already exists  : %s' % dst)
    else:
        with hide('everything'):
            local('cp %s %s' % (src, dst))
        done('echo cteate complete : %s' % dst)
Ejemplo n.º 14
0
def __backup(path):
	if __hasNoBackup(path):
		if not isExists(path):
			error('echo not exists : %s' % path)
			return False
		else:
			with hide('everything'):
				execute('cp -p %s %s.origin' % (path, path))
			done('echo create backup : %s.origin' % path)
			return True
	else:
		already('echo already exists : %s' % path)
		return True
Ejemplo n.º 15
0
def __backup(path):
    if __hasNoBackup(path):
        if not isExists(path):
            error('echo not exists : %s' % path)
            return False
        else:
            with hide('everything'):
                execute('cp -p %s %s.origin' % (path, path))
            done('echo create backup : %s.origin' % path)
            return True
    else:
        already('echo already exists : %s' % path)
        return True
Ejemplo n.º 16
0
def clone(repository, dst, branch = 'master'):
	if isExists(dst):
		error('echo already exists : %s' % dst)
	else:
		with hide('stdout'):
			stdout = execute('git clone -b %s %s %s; true' % (branch, repository, dst))
			if '403 Forbidden' in stdout:
				error("echo -n 'clone error    : 403 Forbidden'")
			else:
				if 'warning: Remote branch %s not found' % branch in stdout:
					error("echo -n 'warning        : %s dones not found'" % branch)
				done("echo -n 'complete clone : '; ls -ld %s" % dst)
				done("echo -n 'branch         : '; cd %s; git rev-parse --abbrev-ref HEAD" % dst)
Ejemplo n.º 17
0
def clone(repository, dst, branch='master'):
    if isExists(dst):
        error('echo already exists : %s' % dst)
    else:
        with hide('stdout'):
            stdout = execute('git clone -b %s %s %s; true' %
                             (branch, repository, dst))
            if '403 Forbidden' in stdout:
                error("echo -n 'clone error    : 403 Forbidden'")
            else:
                if 'warning: Remote branch %s not found' % branch in stdout:
                    error("echo -n 'warning        : %s dones not found'" %
                          branch)
                done("echo -n 'complete clone : '; ls -ld %s" % dst)
                done(
                    "echo -n 'branch         : '; cd %s; git rev-parse --abbrev-ref HEAD"
                    % dst)
Ejemplo n.º 18
0
def link(origin, link):
	if not isExists(origin):
		error('echo not exists : %s' % origin)
	else:
		execute('ln --symbolic --force %s %s' % (origin, link))
		done("echo -n 'link   : '; ls -l %s" % link)
Ejemplo n.º 19
0
def __diff(path):
	done("echo 'diff'; diff %s %s.origin; true" % (path, path))
Ejemplo n.º 20
0
def update():
    with hide('stdout'):
        execute('yum update -y')
    done('echo complete : yum update')
Ejemplo n.º 21
0
def __diff(path):
    done("echo 'diff'; diff %s %s.origin; true" % (path, path))
Ejemplo n.º 22
0
def link(origin, link):
    if not isExists(origin):
        error('echo not exists : %s' % origin)
    else:
        execute('ln --symbolic --force %s %s' % (origin, link))
        done("echo -n 'link   : '; ls -l %s" % link)
Ejemplo n.º 23
0
def update():
	with hide('stdout'):
		execute('yum update -y')
	done('echo complete : yum update')