def distroName(): """ Get the name of the distro. """ with quiet(): lsb = run('/usr/bin/lsb_release --id --short', warn_only=True) if lsb.succeeded: return lsb.lower() distros = [ ('centos', '/etc/centos-release'), ('fedora', '/etc/fedora-release'), ('rhel', '/etc/redhat-release'), ('debian', '/etc/debian_version'), ] for distro, sentinel in distros: if succeeds('/usr/bin/test -f {}'.format(sentinel)): return distro os = run('/usr/bin/uname -s', warn_only=True) return os.lower()
def install(user, file): with settings(user=user): run('/usr/bin/crontab {}'.format(file))
def isRoot(): """ Check if the current user is root. """ return run('id -u') == '0'
def arch(): """ Get the architechture of the machine. """ return run('/bin/uname --machine')