Install nginx configuration
325463
def install_nginx(instance, dbhost, dbname, port, hostname=None):
    """"""

    _check_root()

    log("Installing nginx configuration")

    if hostname is None:
        try:
            configuration = _get_system_configuration(dbhost, dbname)
            hostname = configuration.hostname
        except Exception as e:
            log('Exception:', e, type(e), exc=True, lvl=error)
            log("""Could not determine public fully qualified hostname!
Check systemconfig (see db view and db modify commands) or specify
manually with --hostname host.domain.tld

Using 'localhost' for now""", lvl=warn)
            hostname = 'localhost'

    definitions = {
        'instance': instance,
        'server_public_name': hostname,
        'ssl_certificate': cert_file,
        'ssl_key': key_file,
        'host_url': 'http://127.0.0.1:%i/' % port
    }

    if distribution == 'DEBIAN':
        configuration_file = '/etc/nginx/sites-available/hfos.%s.conf' % instance
        configuration_link = '/etc/nginx/sites-enabled/hfos.%s.conf' % instance
    elif distribution == 'ARCH':
        configuration_file = '/etc/nginx/nginx.conf'
        configuration_link = None
    else:
        log('Unsure how to proceed, you may need to specify your '
            'distribution', lvl=error)
        return

    log('Writing nginx HFOS site definition')
    write_template_file(os.path.join('dev/templates', nginx_configuration),
                        configuration_file,
                        definitions)

    if configuration_link is not None:
        log('Enabling nginx HFOS site (symlink)')
        if not os.path.exists(configuration_link):
            os.symlink(configuration_file, configuration_link)

    log('Restarting nginx service')
    Popen([
        'systemctl',
        'restart',
        'nginx.service'
    ])

    log("Done: ")
993690
def configure(service, key, auth, use_syslog):
    """"""
    add_key(service, key)
    create_key_file(service, key)
    hosts = get_ceph_nodes()
    with open('/etc/ceph/ceph.conf', 'w') as ceph_conf:
        ceph_conf.write(CEPH_CONF.format(auth=auth,
                                         keyring=_keyring_path(service),
                                         mon_hosts=",".join(map(str, hosts)),
                                         use_syslog=use_syslog))
    modprobe('rbd')
158943
protected function configure()
    {
        $this->config = array(
            'app_include' => getenv('APP_INCLUDE'),
            'worker_count' => false === getenv('COUNT') ? 1 : getenv('COUNT'),
            'queues' => getenv('QUEUE'),
            'queue_blocking' => (bool)getenv('BLOCKING'),
            'queue_interval' => false === getenv('INTERVAL') ? 5 : getenv('INTERVAL'),
            'redis_prefix' => false === getenv('PREFIX') ? 'resque' : getenv('PREFIX'),
            'redis_dsn' => getenv('REDIS_BACKEND'),
            'logging' => (bool)getenv('LOGGING'),
            'verbose' => (bool)getenv('VERBOSE'),
            'very_verbose' => (bool)getenv('VVERBOSE'),
        );
    }
886978
def _add_index_server(self):
        """"""
        index_servers = '\n\t'.join(self.servers.keys())
        self.conf.set('distutils', 'index-servers', index_servers)
363969
def __install_ssh_config(self, config):
        
        if not config.is_affirmative('use_global_ssh', default="no"):
            ssh_config_injection = self._build_ssh_config(config)

            if not os.path.exists(ssh_config_path):

                if self.injections.in_noninjected_file(ssh_config_path, "Host %s" % config.get('host')):
                    if config.is_affirmative('override'):
                        self.injections.inject(ssh_config_path, ssh_config_injection)
                else:
                    self.injections.inject(ssh_config_path, ssh_config_injection)

            else:
                self.injections.inject(ssh_config_path, ssh_config_injection)

            self.injections.commit()
1189006
def build_files(payload, dirname=None, indent=4, tabs=False, header=False):
    
    if dirname is None:
        dirname = os.getcwd()

    for config in payload['config']:
        path = config['file']
        if not os.path.isabs(path):
            path = os.path.join(dirname, path)

        # make directories that need to be made for the config to be built
        dirpath = os.path.dirname(path)
        if not os.path.exists(dirpath):
            os.makedirs(dirpath)

        # build then create the nginx config file using the json payload
        parsed = config['parsed']
        output = build(parsed, indent=indent, tabs=tabs, header=header)
        output = output.rstrip() + '\n'
        with codecs.open(path, 'w', encoding='utf-8') as fp:
            fp.write(output)
453168
function configure(alg, pswd, sto) {
  algorithm = alg;
  password = pswd;
  sessionTimeout = sto;
}
587311
def build_network_settings(**settings):
    '''
    
    '''
    changes = []

    # Read current configuration and store default values
    current_network_settings = _parse_current_network_settings()

    # Build settings
    opts = _parse_network_settings(settings, current_network_settings)

    # Ubuntu has moved away from /etc/default/networking
    # beginning with the 12.04 release so we disable or enable
    # the networking related services on boot
    skip_etc_default_networking = (
        __grains__['osfullname'] == 'Ubuntu' and
        int(__grains__['osrelease'].split('.')[0]) >= 12)
    if skip_etc_default_networking:
        if opts['networking'] == 'yes':
            service_cmd = 'service.enable'
        else:
            service_cmd = 'service.disable'

        if __salt__['service.available']('NetworkManager'):
            __salt__[service_cmd]('NetworkManager')

        if __salt__['service.available']('networking'):
            __salt__[service_cmd]('networking')
    else:
        try:
            template = JINJA.get_template('network.jinja')
        except jinja2.exceptions.TemplateNotFound:
            log.error('Could not load template network.jinja')
            return ''
        network = template.render(opts)

        if 'test' in settings and settings['test']:
            return _read_temp(network)
        # Write settings
        _write_file_network(network, _DEB_NETWORKING_FILE, True)

    # Get hostname and domain from opts
    sline = opts['hostname'].split('.', 1)
    opts['hostname'] = sline[0]
    current_domainname = current_network_settings['domainname']
    current_searchdomain = current_network_settings['searchdomain']

    new_domain = False
    if len(sline) > 1:
        new_domainname = sline[1]
        if new_domainname != current_domainname:
            domainname = new_domainname
            opts['domainname'] = new_domainname
            new_domain = True
        else:
            domainname = current_domainname
            opts['domainname'] = domainname
    else:
        domainname = current_domainname
        opts['domainname'] = domainname

    new_search = False
    if 'search' in opts:
        new_searchdomain = opts['search']
        if new_searchdomain != current_searchdomain:
            searchdomain = new_searchdomain
            opts['searchdomain'] = new_searchdomain
            new_search = True
        else:
            searchdomain = current_searchdomain
            opts['searchdomain'] = searchdomain
    else:
        searchdomain = current_searchdomain
        opts['searchdomain'] = searchdomain

    # If the domain changes, then we should write the resolv.conf file.
    if new_domain or new_search:
        # Look for existing domain line and update if necessary
        resolve = _parse_resolve()
        domain_prog = re.compile(r'domain\s+')
        search_prog = re.compile(r'search\s+')
        new_contents = []

        for item in _read_file(_DEB_RESOLV_FILE):
            if domain_prog.match(item):
                item = 'domain {0}'.format(domainname)
            elif search_prog.match(item):
                item = 'search {0}'.format(searchdomain)
            new_contents.append(item)

        # A domain line didn't exist so we'll add one in
        # with the new domainname
        if 'domain' not in resolve:
            new_contents.insert(0, 'domain {0}' . format(domainname))

        # A search line didn't exist so we'll add one in
        # with the new search domain
        if 'search' not in resolve:
            new_contents.insert('domain' in resolve, 'search {0}'.format(searchdomain))

        new_resolv = '\n'.join(new_contents)

        # Write /etc/resolv.conf
        if not ('test' in settings and settings['test']):
            _write_file_network(new_resolv, _DEB_RESOLV_FILE)

    #  used for returning the results back
    try:
        template = JINJA.get_template('display-network.jinja')
    except jinja2.exceptions.TemplateNotFound:
        log.error('Could not load template display-network.jinja')
        return ''
    network = template.render(opts)
    changes.extend(_read_temp(network))

    return changes
482717
def enable_site(site_name):
    """"""

    site_available = u'/etc/nginx/sites-available/%s' % site_name
    site_enabled = u'/etc/nginx/sites-enabled/%s' % site_name
    if files.exists(site_available):
        sudo(u'ln -s -f %s %s' % (site_available, site_enabled))
        restart_service(u'nginx')
    else:
        abort(u'%s site configuration is not available' % site_name)
123096
function setupForCorporateProxy(proxyConfig) {
  if (!Array.isArray(proxyConfig)) {
    proxyConfig = [proxyConfig];
  }

  const proxyServer = process.env.http_proxy || process.env.HTTP_PROXY;
  let agent = null;

  if (proxyServer) {
    console.log(`Using corporate proxy server: ${proxyServer}`);
    agent = new HttpsProxyAgent(proxyServer);
    proxyConfig.forEach(entry => { entry.agent = agent; });
  }

  return proxyConfig;
}
390066
def setup():
    """"""
    install_requirements = ["attrdict"]
    if sys.version_info[:2] < (3, 4):
        install_requirements.append("pathlib")
    setup_requirements = ['six', 'setuptools>=17.1', 'setuptools_scm']
    needs_sphinx = {
        'build_sphinx',
        'docs',
        'upload_docs',
    }.intersection(sys.argv)
    if needs_sphinx:
        setup_requirements.append('sphinx')
    setuptools.setup(
        author="David Gidwani",
        author_email="david.gidwani@gmail.com",
        classifiers=[
            "Development Status :: 4 - Beta",
            "Intended Audience :: Developers",
            "License :: OSI Approved :: BSD License",
            "Operating System :: OS Independent",
            "Programming Language :: Python",
            "Programming Language :: Python :: 2",
            "Programming Language :: Python :: 2.7",
            "Programming Language :: Python :: 3",
            "Programming Language :: Python :: 3.3",
            "Programming Language :: Python :: 3.4",
            "Topic :: Software Development",
            "Topic :: Software Development :: Libraries :: Python Modules",
        ],
        description="Painless access to namespaced environment variables",
        download_url="https://github.com/darvid/biome/tarball/0.1",
        install_requires=install_requirements,
        keywords="conf config configuration environment",
        license="BSD",
        long_description=readme(),
        name="biome",
        package_dir={'': 'src'},
        packages=setuptools.find_packages('./src'),
        setup_requires=setup_requirements,
        tests_require=["pytest"],
        url="https://github.com/darvid/biome",
        use_scm_version=True,
    )
76664
public static function configure(): void
    {
        $filesystem = new Filesystem();
        $config     = [
            'colors'          => '1',
            'installed_paths' => implode(',', [
                Path::VENDOR_DIR . '/hostnet/phpcs-tool/src/',
                Path::VENDOR_DIR . '/slevomat/coding-standard/SlevomatCodingStandard',
            ]),
        ];

        if (!$filesystem->exists(['phpcs.xml', 'phpcs.xml.dist'])) {
            $config['default_standard'] = 'Hostnet';
        }

        $filesystem->dumpFile(
            Path::VENDOR_DIR . '/squizlabs/php_codesniffer/CodeSniffer.conf',
            sprintf('<?php $phpCodeSnifferConfig = %s;', var_export($config, true))
        );

        $filesystem->dumpFile(__DIR__ . '/../../../HostnetPaths/ruleset.xml', self::generateHostnetPathsXml());
    }
191562
private function setup()
    {
        self::$version = '3.1.7';
        self::$src = dirname(__FILE__);
        self::$dir = dirname(dirname(__FILE__));
        self::$url = $this->getCuztomUrl(self::$src);

        // Do
        do_action('cuztom_setup');
    }
393358
def _configure_connection(self, name, value):
    
    self.update("pg_settings", dict(setting=value), dict(name=name))
1136824
def deploy_webconf():
    
    deployed = []
    log_dir = '/'.join([deployment_root(),'log'])
    #TODO - incorrect - check for actual package to confirm installation
    if webserver_list():
        if env.verbosity:
            print env.host,"DEPLOYING webconf:"
        if not exists(log_dir):
            run('ln -s /var/log log')
        #deploys confs for each domain based on sites app
        if 'apache2' in get_packages():
            deployed += _deploy_webconf('/etc/apache2/sites-available','django-apache-template.txt')
            deployed += _deploy_webconf('/etc/nginx/sites-available','nginx-template.txt')
        elif 'gunicorn' in get_packages():
            deployed += _deploy_webconf('/etc/nginx/sites-available','nginx-gunicorn-template.txt')
        
        if not exists('/var/www/nginx-default'):
            sudo('mkdir /var/www/nginx-default')
        upload_template('woven/maintenance.html','/var/www/nginx-default/maintenance.html',use_sudo=True)
        sudo('chmod ugo+r /var/www/nginx-default/maintenance.html')
    else:
        print env.host,"""WARNING: Apache or Nginx not installed"""
        
    return deployed
1001008
def install_config(self):
        
        text = templ_config.render(**self.options)
        config = Configuration(self.buildout, 'supervisord.conf', {
            'deployment': self.deployment_name,
            'text': text})
        return [config.install()]
67214
function install()
    {
        if (! $this->brew->hasInstalledPhp()) {
            $this->brew->ensureInstalled('php', [], $this->taps);
        }

        $this->files->ensureDirExists('/usr/local/var/log', user());

        $this->updateConfiguration();

        $this->restart();
    }