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/dlg' if get_linux_flavor() in ('Ubuntu', 'Debian'): opt_file = '/etc/default/dlg' # Script file installation sudo('cp {0}/fabfile/init/sysv/dlg-* /etc/init.d/'.format(nsd)) sudo('chmod 755 /etc/init.d/dlg-*') # Options file installation and edition sudo('cp {0}/fabfile/init/sysv/dlg.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 dlg-nm defaults') sudo('update-rc.d dlg-dim defaults') else: sudo('chkconfig --add dlg-nm') sudo('chkconfig --add dlg-dim') success("{0} init script installed".format(env.APP_NAME))
def start_APP_and_check_status(): """ Starts the APP daemon process and checks that the server is up and running then it shuts down the server """ with cd('{0}/pyvospace/server/deploy'.format(APP_source_dir())): # >>>> Darwin docker shows a permission issue with keychain access <<<< if get_linux_flavor() != 'Darwin': virtualenv('docker-compose build') else: info('>>>> Darwin reuqires to build docker container manually') info('>>>> docker-compose build') virtualenv( 'docker run -d -p 5435:5432 pyvospace/pyvospace-db -h 0.0.0.0') time.sleep(10) with cd('{0}'.format(APP_source_dir())): virtualenv('python -m unittest discover test') # run('mkdir -p /tmp/fuse') # virtualenv('posix_space --cfg test_vo.ini > /tmp/space.log 2>&1') # time.sleep(2) # virtualenv('posix_storage --cfg test_vo.ini > /tmp/storage.log 2>&1') # time.sleep(2) # virtualenv('python -m pyvospace.client.fuse --host localhost --port 8080 --username test --password test --mountpoint /tmp/fuse/`` > /tmp/fusemnt.log 2>&1') # time.sleep(2) # run("cd /tmp/fuse && mkdir -p newdir && cd newdir && echo 'Hello World!' >> data && cat data") success('{0} is working...'.format(env.APP_NAME))
def install_system_packages(): """ Perform the installation of system-level packages needed by APP 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(env.pkgs['YUM_PACKAGES']) if linux_flavor == 'CentOS': sudo('/etc/init.d/iptables stop') # CentOS firewall blocks APP port! elif (linux_flavor in ['Ubuntu', 'Debian']): errmsg = sudo('apt-get -qq -y update', combine_stderr=True, warn_only=True) install_apt(env.pkgs['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(env.pkgs['SLES_PACKAGES']) elif linux_flavor == 'Darwin': pkg_mgr = check_brew_port() if pkg_mgr is None: install_homebrew() pkg_mgr = 'brew' if pkg_mgr == 'brew': for package in env.pkgs['BREW_PACKAGES']: install_brew(package) elif pkg_mgr == 'port': for package in env.pkgs['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 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 = settings['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 YUM_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 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 APP_build_cmd(): # 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@4'.format(cellardir)).split()[-1] db_dir = '{0}/berkeley-db@4/{1}'.format(cellardir, db_version) build_cmd.append('BERKELEYDB_DIR={0}'.format(db_dir)) if not settings['NGAS_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 settings['NGAS_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 settings['NGAS_NO_CRC32C']: build_cmd.append('NGAS_NO_CRC32C=1') build_cmd.append('./build.sh') if not settings['NGAS_NO_CLIENT']: build_cmd.append("-c") if settings['NGAS_DEVELOP']: build_cmd.append("-d") if not settings['NGAS_DOC_DEPENDENCIES']: build_cmd.append('-D') return ' '.join(build_cmd)