def install_homebrew(): """ Task to install homebrew on Mac OSX. NOTE: This should not be done if macports is installed already. """ lf = get_linux_flavor() if lf != 'Darwin': puts( red("Potentially this is not a Mac OSX installation: {0}".format( lf))) raise (ValueError) if check_command('port'): puts( red('MacPorts is installed and it is not recommended to mix it with homebrew!!' )) puts(red('Bailing out!')) raise (ValueError) return if not check_command('brew'): run('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"' ) else: puts( red('Homebrew is installed already! New installation not required.' ))
def install_system_packages(): """ Perform the installation of system-level packages needed by NGAS to work. """ # Install required packages linux_flavor = get_linux_flavor() if (linux_flavor in ['CentOS','Amazon Linux']): # Update the machine completely errmsg = sudo('yum --assumeyes --quiet update', combine_stderr=True, warn_only=True) processCentOSErrMsg(errmsg) install_yum(YUM_PACKAGES) if linux_flavor == 'CentOS': sudo('/etc/init.d/iptables stop') # CentOS firewall blocks NGAS port! elif (linux_flavor in ['Ubuntu', 'Debian']): errmsg = sudo('apt-get -qq -y update', combine_stderr=True, warn_only=True) install_apt(APT_PACKAGES) elif linux_flavor in ['SUSE','SLES-SP2', 'SLES-SP3', 'SLES', 'openSUSE']: errmsg = sudo('zypper -n -q patch', combine_stderr=True, warn_only=True) install_zypper(SLES_PACKAGES) elif linux_flavor == 'Darwin': pkg_mgr = check_brew_port() if pkg_mgr == None: install_homebrew() pkg_mgr = 'brew' if pkg_mgr == 'brew': for package in BREW_PACKAGES: install_brew(package) elif pkg_mgr == 'port': for package in PORT_PACKAGES: install_port(package) else: abort("Unsupported linux flavor detected: {0}".format(linux_flavor))
def install_sysv_init_script(nsd, nuser, cfgfile): """ Install the APP init script for an operational deployment. The init script is an old System V init system. In the presence of a systemd-enabled system we use the update-rc.d tool to enable the script as part of systemd (instead of the System V chkconfig tool which we use instead). The script is prepared to deal with both tools. """ # Different distros place it in different directories # The init script is prepared for both opt_file = '/etc/sysconfig/{0}'.format(APP_name()) if get_linux_flavor() in ('Ubuntu', 'Debian'): opt_file = '/etc/default/{0}'.format(APP_name()) # Script file installation sudo('cp {0}/fabfile/init/sysv/{1}-server /etc/init.d/'.format( nsd, APP_name())) sudo('chmod 755 /etc/init.d/{0}-server'.format(APP_name())) # Options file installation and edition sudo('cp {0}/fabfile/init/sysv/APP-server.options {1}'.format( nsd, opt_file)) sudo('chmod 644 %s' % (opt_file, )) # Enabling init file on boot if check_command('update-rc.d'): sudo('update-rc.d {0}-server defaults'.format(APP_name())) else: sudo('chkconfig --add {0}-server'.format(APP_name())) success("{0} init script installed".format(APP_name()))
def install_sysv_init_script(nsd, nuser, cfgfile): """ Install the NGAS init script for an operational deployment. The init script is an old System V init system. In the presence of a systemd-enabled system we use the update-rc.d tool to enable the script as part of systemd (instead of the System V chkconfig tool which we use instead). The script is prepared to deal with both tools. """ # Different distros place it in different directories # The init script is prepared for both opt_file = '/etc/sysconfig/ngas' if get_linux_flavor() in ('Ubuntu', 'Debian'): opt_file = '/etc/default/ngas' # Script file installation sudo('cp %s/fabfile/init/sysv/ngas-server /etc/init.d/' % (nsd, )) sudo('chmod 755 /etc/init.d/ngas-server') # Options file installation and edition ntype = ngas_server_type() sudo('cp %s/fabfile/init/sysv/ngas-server.options %s' % (nsd, opt_file)) sudo('chmod 644 %s' % (opt_file, )) sed(opt_file, '^USER=.*', 'USER=%s' % (nuser, ), use_sudo=True, backup='') sed(opt_file, '^CFGFILE=.*', 'CFGFILE=%s' % (cfgfile, ), use_sudo=True, backup='') if ntype == 'cache': sed(opt_file, '^CACHE=.*', 'CACHE=YES', use_sudo=True, backup='') elif ntype == 'data-mover': sed(opt_file, '^DATA_MOVER=.*', 'DATA_MOVER=YES', use_sudo=True, backup='') # Enabling init file on boot if check_command('update-rc.d'): sudo('update-rc.d ngas-server defaults') else: sudo('chkconfig --add ngas-server') success("NGAS init script installed")
def system_check(): """ Check for existence of system level packages NOTE: This requires sudo access on the machine(s) """ linux_flavor = get_linux_flavor() ok = True if (linux_flavor in ['CentOS', 'Amazon Linux']): ok = all([check_yum(p) for p in YUM_PACKAGES]) elif (linux_flavor == 'Ubuntu'): ok = all([check_apt(p) for p in APT_PACKAGES]) else: abort("Unknown linux flavor detected: {0}".format(linux_flavor)) if ok: puts("All required packages are installed.") else: puts("At least one package is missing!")
def ngas_build_cmd(no_client, develop, no_doc_dependencies): # The installation of the bsddb package (needed by ngamsCore) is in # particular difficult because it requires some flags to be passed on # (particularly if using MacOSX's port build_cmd = [] linux_flavor = get_linux_flavor() if linux_flavor == 'Darwin': pkgmgr = check_brew_port() if pkgmgr == 'brew': cellardir = check_brew_cellar() db_version = run( 'ls -tr1 {0}/berkeley-db'.format(cellardir)).split()[-1] db_dir = '{0}/berkeley-db/{1}'.format(cellardir, db_version) build_cmd.append('BERKELEYDB_DIR={0}'.format(db_dir)) if not no_client: build_cmd.append('CFLAGS=-I{0}/include'.format(db_dir)) build_cmd.append('LDFLAGS=-L{0}/lib'.format(db_dir)) else: incdir = MACPORT_DIR + '/include/db60' libdir = MACPORT_DIR + '/lib/db60' build_cmd.append('BERKELEYDB_INCDIR=' + incdir) build_cmd.append('BERKELEYDB_LIBDIR=' + libdir) if not no_client: build_cmd.append('CFLAGS=-I' + incdir) build_cmd.append('LDFLAGS=-L' + libdir) build_cmd.append( 'YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=1') if ngas_no_crc32c(): build_cmd.append('NGAS_NO_CRC32C=1') build_cmd.append('./build.sh') if not no_client: build_cmd.append("-c") if develop: build_cmd.append("-d") if not no_doc_dependencies: build_cmd.append('-D') return ' '.join(build_cmd)