示例#1
0
    def install_ontransit(self):
        '''Clones and then installs OnTransit.
        '''

        run('git clone {0}'.format(
            self.ontransit_conf.get('ontransit_git_repo')))

        with cd(self.ontransit_base_folder):
            run('git checkout {0}'.format(
                self.ontransit_conf.get('ontransit_git_branch')))

        # upload server config
        server_data = dict(
            gtfs_static_url=self.gtfs_conf.get('gtfs_static_url'),
            block_delay_delete_threshold=self.ontransit_conf.get(
                'block_delay_delete_threshold'),
            database_name=self.ontransit_conf.get('database_name'),
            nearby_stop_future_padding=self.ontransit_conf.get(
                'nearby_stop_future_padding'),
            nearby_stop_past_padding=self.ontransit_conf.get(
                'nearby_stop_past_padding'),
            pg_worker_username=self.ontransit_conf.get('pg_worker_username'),
            pg_worker_password=self.ontransit_conf.get('pg_worker_password'),
            pg_web_username=self.ontransit_conf.get('pg_web_username'),
            pg_web_password=self.ontransit_conf.get('pg_web_password'),
            trip_end_padding=self.ontransit_conf.get('trip_end_padding'),
            trip_start_padding=self.ontransit_conf.get('trip_start_padding'))

        with (cd(self.ontransit_server_folder)):

            # create config dir and upload file
            run('mkdir config')

            put(
                write_template(server_data, 'server_config_index.js',
                               'index.js'), 'config')

            # install npm stuff
            run('npm install')

        # upload web config
        web_data = dict(
            agency_timezone=self.ontransit_conf.get('agency_timezone'),
            google_analytics_tracking_key=self.ontransit_conf.get(
                'google_analytics_tracking_key'),
            google_maps_api_key=self.ontransit_conf.get('google_maps_api_key'))
        put(write_template(web_data, 'web_config.js', 'config.js'),
            unix_path_join(self.ontransit_web_folder, 'js'))

        with (cd(self.ontransit_web_folder)):
            # install npm stuff
            run('npm install')

            if not exists('dist'):
                run('mkdir dist')

            # build static files
            run('npm run build')
示例#2
0
    def install_ontransit(self):
        '''Clones and then installs OnTransit.
        '''
        
        run('git clone {0}'.format(self.ontransit_conf.get('ontransit_git_repo')))
        
        with cd(self.ontransit_base_folder):
            run('git checkout {0}'.format(self.ontransit_conf.get('ontransit_git_branch')))
        
        # upload server config
        server_data = dict(gtfs_static_url=self.gtfs_conf.get('gtfs_static_url'),
                           block_delay_delete_threshold=self.ontransit_conf.get('block_delay_delete_threshold'),
                           database_name=self.ontransit_conf.get('database_name'),
                           nearby_stop_future_padding=self.ontransit_conf.get('nearby_stop_future_padding'),
                           nearby_stop_past_padding=self.ontransit_conf.get('nearby_stop_past_padding'),
                           pg_worker_username=self.ontransit_conf.get('pg_worker_username'),
                           pg_worker_password=self.ontransit_conf.get('pg_worker_password'),
                           pg_web_username=self.ontransit_conf.get('pg_web_username'),
                           pg_web_password=self.ontransit_conf.get('pg_web_password'),
                           trip_end_padding=self.ontransit_conf.get('trip_end_padding'),
                           trip_start_padding=self.ontransit_conf.get('trip_start_padding'))
        
        with(cd(self.ontransit_server_folder)):

            # create config dir and upload file
            run('mkdir config')

            put(write_template(server_data, 
                               'server_config_index.js', 
                               'index.js'),
                'config')

            # install npm stuff
            run('npm install')
            
        # upload web config
        web_data = dict(agency_timezone=self.ontransit_conf.get('agency_timezone'),
                        google_analytics_tracking_key=self.ontransit_conf.get('google_analytics_tracking_key'),
                        google_maps_api_key=self.ontransit_conf.get('google_maps_api_key'))
        put(write_template(web_data, 
                           'web_config.js', 
                           'config.js'), 
            unix_path_join(self.ontransit_web_folder, 'js'))
                
        with(cd(self.ontransit_web_folder)):
            # install npm stuff
            run('npm install')
            
            if not exists('dist'):
                run('mkdir dist')
            
            # build static files            
            run('npm run build')
示例#3
0
    def install_pg(self):
        '''Downloads and configures PostgreSQL.
        '''

        # get yum squared away
        sudo(
            'rpm -ivh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm'
        )

        # install postgresql
        sudo(
            'yum -y install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel'
        )

        # make sure yum knows about postgis dependencies
        sudo(
            'rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm'
        )

        # install postgis
        sudo('yum -y install postgis2_93')

        # initialize db
        sudo('service postgresql-9.3 initdb')

        # upload insecure pg_hba.conf
        self.upload_pg_hba_conf('trust')

        db_setup_dict = dict(
            pg_worker_username=self.ontransit_conf.get('pg_worker_username'),
            pg_worker_password=self.ontransit_conf.get('pg_worker_password'),
            pg_web_username=self.ontransit_conf.get('pg_web_username'),
            pg_web_password=self.ontransit_conf.get('pg_web_password'),
            pg_worker_groupname=self.ontransit_conf.get('pg_worker_groupname'),
            database_name=self.ontransit_conf.get('database_name'))

        if not exists(self.server_config_dir):
            run('mkdir {0}'.format(self.server_config_dir))

        put(write_template(db_setup_dict, 'db_setup.sql'),
            self.server_config_dir)

        # start postgres
        sudo('service postgresql-9.3 start')

        # execute db setup sql
        sudo('psql -U postgres -f {0}'.format(
            unix_path_join(self.server_config_dir, 'db_setup.sql')))
        sudo('psql -U postgres -d {0} -c "CREATE EXTENSION postgis;"'.format(
            self.ontransit_conf.get('database_name')))

        # switch to more secure pg_hba.conf
        self.upload_pg_hba_conf('md5')

        # restart postgres
        sudo('service postgresql-9.3 restart')

        # start postgresql on boot
        sudo('chkconfig postgresql-9.3 on')
示例#4
0
 def install_pg(self):
     '''Downloads and configures PostgreSQL.
     '''
     
     # get yum squared away
     sudo('rpm -ivh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm')
     
     # install postgresql
     sudo('yum -y install postgresql93 postgresql93-server postgresql93-libs postgresql93-contrib postgresql93-devel')
     
     # make sure yum knows about postgis dependencies
     sudo('rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm')
     
     # install postgis
     sudo('yum -y install postgis2_93')
     
     # initialize db
     sudo('service postgresql-9.3 initdb')
     
     # upload insecure pg_hba.conf
     self.upload_pg_hba_conf('trust')
     
     db_setup_dict = dict(pg_worker_username=self.ontransit_conf.get('pg_worker_username'),
                          pg_worker_password=self.ontransit_conf.get('pg_worker_password'),
                          pg_web_username=self.ontransit_conf.get('pg_web_username'),
                          pg_web_password=self.ontransit_conf.get('pg_web_password'),
                          pg_worker_groupname=self.ontransit_conf.get('pg_worker_groupname'),
                          database_name=self.ontransit_conf.get('database_name'))
     
     if not exists(self.server_config_dir):
         run('mkdir {0}'.format(self.server_config_dir))
     
     put(write_template(db_setup_dict, 'db_setup.sql'),
         self.server_config_dir)
     
     # start postgres
     sudo('service postgresql-9.3 start')
     
     # execute db setup sql
     sudo('psql -U postgres -f {0}'.format(unix_path_join(self.server_config_dir, 'db_setup.sql')))
     sudo('psql -U postgres -d {0} -c "CREATE EXTENSION postgis;"'.
          format(self.ontransit_conf.get('database_name')))
     
     # switch to more secure pg_hba.conf
     self.upload_pg_hba_conf('md5')
     
     # restart postgres
     sudo('service postgresql-9.3 restart')
     
     # start postgresql on boot
     sudo('chkconfig postgresql-9.3 on')
示例#5
0
    def new_user(self):
        '''Setup a non-root user.
        '''

        regular_user_name = self.aws_conf.get('regular_user_name')

        run('adduser {0}'.format(regular_user_name))
        run('echo {0} | passwd {1} --stdin'.format(
            self.aws_conf.get('regular_user_password'), regular_user_name))

        # grant sudo access to regular user
        put(
            write_template(dict(regular_user_name=regular_user_name),
                           'user-init'), '/etc/sudoers.d', True)
示例#6
0
 def new_user(self):
     '''Setup a non-root user.
     '''
     
     regular_user_name = self.aws_conf.get('regular_user_name')
     
     run('adduser {0}'.format(regular_user_name))
     run('echo {0} | passwd {1} --stdin'.
         format(self.aws_conf.get('regular_user_password'),
                regular_user_name))
     
     # grant sudo access to regular user
     put(write_template(dict(regular_user_name=regular_user_name),
                        'user-init'),
         '/etc/sudoers.d',
         True)
示例#7
0
    def upload_pg_hba_conf(self, local_method):
        '''Overwrites pg_hba.conf with specified local method.
        '''

        remote_data_folder = '/var/lib/pgsql/9.3/data'
        remote_pg_hba_conf = '/var/lib/pgsql/9.3/data/pg_hba.conf'

        sudo('rm -rf {0}'.format(remote_pg_hba_conf))

        put(write_template(dict(local_method=local_method), 'pg_hba.conf'),
            remote_data_folder, True)

        with cd(remote_data_folder):
            sudo('chmod 600 pg_hba.conf')
            sudo('chgrp postgres pg_hba.conf')
            sudo('chown postgres pg_hba.conf')
示例#8
0
 def upload_pg_hba_conf(self, local_method):
     '''Overwrites pg_hba.conf with specified local method.
     '''
     
     remote_data_folder = '/var/lib/pgsql/9.3/data'
     remote_pg_hba_conf = '/var/lib/pgsql/9.3/data/pg_hba.conf'
     
     sudo('rm -rf {0}'.format(remote_pg_hba_conf))
     
     put(write_template(dict(local_method=local_method), 'pg_hba.conf'),
         remote_data_folder,
         True)
     
     with cd(remote_data_folder):
         sudo('chmod 600 pg_hba.conf')
         sudo('chgrp postgres pg_hba.conf')
         sudo('chown postgres pg_hba.conf')