示例#1
0
    def install_project(self, scheduler_file=None):
        if os.path.exists(self.dir()):
            raise SystemExit('Project directory "%s" already exists; this would clobber it!' % self.dir())

        verbose_echo(1, "Creating directories")

        create_project_dirs(self.project_dir)

        if not self.web_only:
            if not self.keys_exist():
                verbose_echo(1, "Generating encryption keys")
                self.create_keys()

        # copy the user and administrative PHP files to the project dir,
        verbose_echo(1, "Copying files")

        # Create the project log directory
        self.create_logdir()

        install_boinc_files(self.dir(), True, not self.web_only)

        # copy sample web files to final names
        install(srcdir("html/user/sample_index.php"), self.dir("html/user/index.php"))
        install(srcdir("html/project.sample/project.inc"), self.dir("html/project/project.inc"))
        install(
            srcdir("html/project.sample/project_specific_prefs.inc"),
            self.dir("html/project/project_specific_prefs.inc"),
        )
        install(srcdir("html/project.sample/cache_parameters.inc"), self.dir("html/project/cache_parameters.inc"))
        install(srcdir("tools/project.xml"), self.dir("project.xml"))
        if not self.production:
            install(srcdir("test/uc_result"), self.dir("templates/uc_result"))
            install(srcdir("test/uc_wu_nodelete"), self.dir("templates/uc_wu"))

        my_symlink(self.config.config.download_dir, self.dir("html", "user", "download"))
        my_symlink("../stats", self.dir("html/user/stats"))

        # Copy the sched server in the cgi directory with the cgi names given
        # source_dir/html/user/schedulers.txt
        #

        if scheduler_file:
            r = re.compile("<scheduler>([^<]+)</scheduler>", re.IGNORECASE)
            f = open(self.dir("html/user", scheduler_file))
            for line in f:
                # not sure if this is what the scheduler file is supposed to
                # mean
                match = r.search(line)
                if match:
                    cgi_name = match.group(1)
                    verbose_echo(2, "Copying " + cgi_name)
                    install(builddir("sched/cgi"), self.dir("cgi-bin", cgi_name, ""))
            f.close()
        else:
            scheduler_file = "schedulers.txt"
            f = open(self.dir("html/user", scheduler_file), "w")
            print >> f, "<!-- <scheduler>" + self.scheduler_url.strip() + "</scheduler> -->"
            print >> f, '<link rel="boinc_scheduler" href="' + self.scheduler_url.strip() + '">'
            f.close()

        verbose_echo(1, "Setting up database")
        database.create_database(srcdir=options.srcdir, config=self.config.config, drop_first=options.drop_db_first)

        verbose_echo(1, "Writing config files")

        self.config.write()

        # create symbolic links to the CGI and HTML directories
        verbose_echo(1, "Linking CGI programs")
        if options.__dict__.get("cgi_dir"):
            force_symlink(self.dir("cgi-bin"), os.path.join(options.cgi_dir, self.short_name))
        if options.__dict__.get("html_dir"):
            force_symlink(self.dir("html/user"), os.path.join(options.html_dir, self.short_name))
            force_symlink(self.dir("html/ops"), os.path.join(options.html_dir, self.short_name + "_admin"))
示例#2
0
    def install_project(self):
        if os.path.exists(self.dest()):
            raise SystemExit('Project directory "%s" already exists; this would clobber it!'%self.dest())

        verbose_echo(1, "Creating directories");

        create_project_dirs(self.project_dir);

        if not self.web_only:
            if not self.keys_exist():
                verbose_echo(1, "Generating encryption keys");
                self.create_keys()

        # copy the user and administrative PHP files to the project dir,
        verbose_echo(1, "Copying files")

        # Create the project log directory
        self.create_logdir()

        install_boinc_files(self.dest(), True, not self.web_only)

        # copy sample web files to final names
        install(srcdir('html/user/sample_index.php'),
            self.dest('html/user/index.php'))
        install(srcdir('html/user/sample_bootstrap.min.css'),
            self.dest('html/user/bootstrap.min.css'))
        install(srcdir('html/user/sample_bootstrap.min.js'),
            self.dest('html/user/bootstrap.min.js'))
        install(srcdir('html/user/sample_jquery.min.js'),
            self.dest('html/user/jquery.min.js'))
        install(srcdir('html/project.sample/project.inc'),
            self.dest('html/project/project.inc'))
        install(srcdir('html/project.sample/project_specific_prefs.inc'),
            self.dest('html/project/project_specific_prefs.inc'))
        install(srcdir('html/project.sample/cache_parameters.inc'),
            self.dest('html/project/cache_parameters.inc'))
        install(srcdir('tools/project.xml'), self.dest('project.xml'))
        install(srcdir('tools/gui_urls.xml'), self.dest('gui_urls.xml'))
        if not self.production:
            install(srcdir('test/uc_result'), self.dest('templates/uc_result'))
            install(srcdir('test/uc_wu_nodelete'), self.dest('templates/uc_wu'))

        content = '''
<!-- <scheduler>{url}</scheduler> -->"
<link rel=\"boinc_scheduler\" href=\"url"\">
        '''.format(url=self.scheduler_url.strip())    
        f = open(self.dest('html/user', 'schedulers.txt'), 'w')
        f.write(content)
        f.close()

        if self.no_db:
            verbose_echo(1, "Not setting up database (--no_db was specified)")
        else:
            verbose_echo(1, "Setting up database")
            database.create_database(
                srcdir = options.srcdir,
                config = self.config.config,
                drop_first = options.drop_db_first
                )

        verbose_echo(1, "Writing config files")
        self.config.write()

        # create symbolic links to the CGI and HTML directories
        verbose_echo(1, "Linking CGI programs")
        if options.__dict__.get('cgi_dir'):
            force_symlink(self.dest('cgi-bin'), os.path.join(options.cgi_dir, self.short_name))
        if options.__dict__.get('html_dir'):
            force_symlink(self.dest('html/user'), os.path.join(options.html_dir, self.short_name))
            force_symlink(self.dest('html/ops'), os.path.join(options.html_dir, self.short_name+'_admin'))
示例#3
0
    def install_project(self):
        if os.path.exists(self.dir()):
            raise SystemExit('Project directory "%s" already exists; this would clobber it!'%self.dir())

        verbose_echo(1, "Creating directories");

        create_project_dirs(self.project_dir);

        if not self.web_only:
            if not self.keys_exist():
                verbose_echo(1, "Generating encryption keys");
                self.create_keys()

        # copy the user and administrative PHP files to the project dir,
        verbose_echo(1, "Copying files")

        # Create the project log directory
        self.create_logdir()

        install_boinc_files(self.dir(), True, not self.web_only)

        # copy sample web files to final names
        install(srcdir('html/user/sample_index.php'),
            self.dir('html/user/index.php'))
        install(srcdir('html/project.sample/project.inc'),
            self.dir('html/project/project.inc'))
        install(srcdir('html/project.sample/project_specific_prefs.inc'),
            self.dir('html/project/project_specific_prefs.inc'))
        install(srcdir('html/project.sample/cache_parameters.inc'),
            self.dir('html/project/cache_parameters.inc'))
        install(srcdir('tools/project.xml'), self.dir('project.xml'))
        install(srcdir('tools/gui_urls.xml'), self.dir('gui_urls.xml'))
        if not self.production:
            install(srcdir('test/uc_result'), self.dir('templates/uc_result'))
            install(srcdir('test/uc_wu_nodelete'), self.dir('templates/uc_wu'))

        f = open(self.dir('html/user', 'schedulers.txt'), 'w')
        print >>f, "<!-- <scheduler>" + self.scheduler_url.strip() + "</scheduler> -->"
        print >>f, "<link rel=\"boinc_scheduler\" href=\"" + self.scheduler_url.strip()+ "\">"
        f.close()

        if self.no_db:
            verbose_echo(1, "Not setting up database (--no_db was specified)")
        else:
            verbose_echo(1, "Setting up database")
            database.create_database(
                srcdir = options.srcdir,
                config = self.config.config,
                drop_first = options.drop_db_first
                )

        verbose_echo(1, "Writing config files")

        self.config.write()

        # create symbolic links to the CGI and HTML directories
        verbose_echo(1, "Linking CGI programs")
        if options.__dict__.get('cgi_dir'):
            force_symlink(self.dir('cgi-bin'), os.path.join(options.cgi_dir, self.short_name))
        if options.__dict__.get('html_dir'):
            force_symlink(self.dir('html/user'), os.path.join(options.html_dir, self.short_name))
            force_symlink(self.dir('html/ops'), os.path.join(options.html_dir, self.short_name+'_admin'))
示例#4
0
    def install_project(self, scheduler_file=None):
        if os.path.exists(self.dir()):
            raise SystemExit(
                'Project directory "%s" already exists; this would clobber it!'
                % self.dir())

        verbose_echo(1, "Creating directories")

        create_project_dirs(self.project_dir)

        if not self.web_only:
            if not self.keys_exist():
                verbose_echo(1, "Generating encryption keys")
                self.create_keys()

        # copy the user and administrative PHP files to the project dir,
        verbose_echo(1, "Copying files")

        # Create the project log directory
        self.create_logdir()

        install_boinc_files(self.dir(), True, not self.web_only)

        # copy sample web files to final names
        install(srcdir('html/user/sample_index.php'),
                self.dir('html/user/index.php'))
        install(srcdir('html/project.sample/project.inc'),
                self.dir('html/project/project.inc'))
        install(srcdir('html/project.sample/project_specific_prefs.inc'),
                self.dir('html/project/project_specific_prefs.inc'))
        install(srcdir('html/project.sample/cache_parameters.inc'),
                self.dir('html/project/cache_parameters.inc'))
        install(srcdir('tools/project.xml'), self.dir('project.xml'))
        install(srcdir('tools/gui_urls.xml'), self.dir('gui_urls.xml'))
        if not self.production:
            install(srcdir('test/uc_result'), self.dir('templates/uc_result'))
            install(srcdir('test/uc_wu_nodelete'), self.dir('templates/uc_wu'))

        my_symlink(self.config.config.download_dir,
                   self.dir('html', 'user', 'download'))
        my_symlink('../stats', self.dir('html/user/stats'))

        # Copy the sched server in the cgi directory with the cgi names given
        # source_dir/html/user/schedulers.txt
        #

        if scheduler_file:
            r = re.compile('<scheduler>([^<]+)</scheduler>', re.IGNORECASE)
            f = open(self.dir('html/user', scheduler_file))
            for line in f:
                # not sure if this is what the scheduler file is supposed to
                # mean
                match = r.search(line)
                if match:
                    cgi_name = match.group(1)
                    verbose_echo(2, "Copying " + cgi_name)
                    install(builddir('sched/cgi'),
                            self.dir('cgi-bin', cgi_name, ''))
            f.close()
        else:
            scheduler_file = 'schedulers.txt'
            f = open(self.dir('html/user', scheduler_file), 'w')
            print >> f, "<!-- <scheduler>" + self.scheduler_url.strip(
            ) + "</scheduler> -->"
            print >> f, "<link rel=\"boinc_scheduler\" href=\"" + self.scheduler_url.strip(
            ) + "\">"
            f.close()

        verbose_echo(1, "Setting up database")
        database.create_database(srcdir=options.srcdir,
                                 config=self.config.config,
                                 drop_first=options.drop_db_first)

        verbose_echo(1, "Writing config files")

        self.config.write()

        # create symbolic links to the CGI and HTML directories
        verbose_echo(1, "Linking CGI programs")
        if options.__dict__.get('cgi_dir'):
            force_symlink(self.dir('cgi-bin'),
                          os.path.join(options.cgi_dir, self.short_name))
        if options.__dict__.get('html_dir'):
            force_symlink(self.dir('html/user'),
                          os.path.join(options.html_dir, self.short_name))
            force_symlink(
                self.dir('html/ops'),
                os.path.join(options.html_dir, self.short_name + '_admin'))
示例#5
0
print "Setting project URL to: "+URL_BASE
for filename in ["config.xml","html/user/schedulers.txt","boincserver.readme"]:
    filepath = join(PROJHOME,filename)
    if exists(filepath):
        with open(filepath,"r") as f: contents = f.read()
        with open(filepath,"w") as f: f.write(contents.replace("http://url_base/",URL_BASE))


if not '--copy-only' in sys.argv:
    
    print "Creating database..."
    waited=False
    while True:
        try:
            database.create_database(srcdir='/root/boinc', 
                                     config=configxml.ConfigFile(filename=join(PROJHOME,'config.xml')).read().config, 
                                     drop_first=False)
        except _mysql_exceptions.ProgrammingError as e:
            if e[0]==1007: 
                print "Database exists, not overwriting."
                break
            else:
                raise
        except _mysql_exceptions.OperationalError as e:
            if e[0]==2003:  
                if waited: sys.stdout.write('.'); sys.stdout.flush()
                else: 
                    sys.stdout.write("Waiting for mysql server to start..."); sys.stdout.flush()
                    waited=True
                sleep(1)
            else: 
    def install_project(self, scheduler_file = None):
        if os.path.exists(self.dir()):
            raise SystemExit('Project directory "%s" already exists; this would clobber it!'%self.dir())

        verbose_echo(1, "Setting up server: creating directories");

        create_project_dirs(self.project_dir);

        if not self.web_only:
            if not self.keys_exist():
                if self.query_create_keys():
                    verbose_echo(1, "Setting up server files: generating keys");
                    self.create_keys()

        # copy the user and administrative PHP files to the project dir,
        verbose_echo(1, "Setting up server files: copying files")

        # Create the project log directory
        self.create_logdir()

        install_boinc_files(self.dir(), self.web_only)

        # copy sample web files to final names
        install(srcdir('html/user/sample_index.php'),
            self.dir('html/user/index.php'))
        install(srcdir('html/project.sample/project.inc'),
            self.dir('html/project/project.inc'))
        install(srcdir('html/project.sample/project_specific_prefs.inc'),
            self.dir('html/project/project_specific_prefs.inc'))
        install(srcdir('html/project.sample/project_news.inc'),
            self.dir('html/project/project_news.inc'))
        install(srcdir('html/project.sample/cache_parameters.inc'),
            self.dir('html/project/cache_parameters.inc'))
        install(srcdir('html/user', 'sample_rss_main.php'),
            self.dir('html/user/rss_main.php'))
        install(srcdir('html/ops', 'sample_server_status.php'),
            self.dir('html/user/server_status.php'))
        install(srcdir('tools/project.xml'), self.dir('project.xml'))
        if not self.production:
            install(srcdir('test/uc_result'), self.dir('templates/uc_result'))
            install(srcdir('test/uc_wu_nodelete'), self.dir('templates/uc_wu'))

        my_symlink(self.config.config.download_dir, self.dir('html', 'user', 'download'))
        my_symlink('../stats', self.dir('html/user/stats'))

        # Copy the sched server in the cgi directory with the cgi names given
        # source_dir/html/user/schedulers.txt
        #

        if scheduler_file:
            r = re.compile('<scheduler>([^<]+)</scheduler>', re.IGNORECASE)
            f = open(self.dir('html/user', scheduler_file))
            for line in f:
                # not sure if this is what the scheduler file is supposed to
                # mean
                match = r.search(line)
                if match:
                    cgi_name = match.group(1)
                    verbose_echo(2, "Setting up server files: copying " + cgi_name);
                    install(builddir('sched/cgi'), self.dir('cgi-bin', cgi_name,''))
            f.close()
        else:
            scheduler_file = 'schedulers.txt'
            f = open(self.dir('html/user', scheduler_file), 'w')
            print >>f, "<!-- <scheduler>" + self.scheduler_url.strip() + "</scheduler> -->"
            print >>f, "<link rel=\"boinc_scheduler\" href=\"" + self.scheduler_url.strip()+ "\">"
            f.close()

        verbose_echo(1, "Setting up database")
        database.create_database(
            srcdir = options.srcdir,
            config = self.config.config,
            drop_first = options.drop_db_first
            )

        verbose_echo(1, "Setting up server files: writing config files")

        self.config.write()

        # create symbolic links to the CGI and HTML directories
        verbose_echo(1, "Setting up server files: linking cgi programs")
        if options.__dict__.get('cgi_dir'):
            force_symlink(self.dir('cgi-bin'), os.path.join(options.cgi_dir, self.short_name))
        if options.__dict__.get('html_dir'):
            force_symlink(self.dir('html/user'), os.path.join(options.html_dir, self.short_name))
            force_symlink(self.dir('html/ops'), os.path.join(options.html_dir, self.short_name+'_admin'))

print "Copying project files to data volume..."
for f in glob(join(PROJHOME,'*'))+glob(join(PROJHOME,'.*')): 
    sh('cp -rp "{f}" {PROJHOME_DST}')
sh('rm -rf {PROJHOME}; ln -s {PROJHOME_DST} {PROJHOME}')


if not '--copy-only' in sys.argv:
    
    print "Creating database..."
    waited=False
    while True:
        try:
            database.create_database(srcdir='/root/boinc', 
                                     config=configxml.ConfigFile(filename=join(PROJHOME,'config.xml')).read().config, 
                                     drop_first=False)
        except _mysql_exceptions.ProgrammingError as e:
            if e[0]==1007: 
                print "Database exists, not overwriting."
                break
            else:
                raise
        except _mysql_exceptions.OperationalError as e:
            if e[0]==2003:  
                if waited: sys.stdout.write('.'); sys.stdout.flush()
                else: 
                    sys.stdout.write("Waiting for mysql server to start..."); sys.stdout.flush()
                    waited=True
                sleep(1)
            else: 
示例#8
0
for x in ['html', 'html/cache', 'upload', 'log_cosmohome']: 
    sh('chmod -R g+w /root/projects/cosmohome/'+x)


print "Linking httpd.conf..."
conf_file = '/root/projects/cosmohome/cosmohome.httpd.conf'
sym_target = osp.join("/etc/apache2/sites-enabled/",osp.basename(conf_file))
if not osp.exists(sym_target): os.symlink(os.path.abspath(conf_file),sym_target)

if not '--copy-only' in sys.argv:
    
    print "Creating database..."
    try:
        database.create_database(
            srcdir = '/root/boinc',
            config = configxml.ConfigFile(filename='/root/projects/cosmohome/config.xml').read().config,
            drop_first = False
        )
    except _mysql_exceptions.ProgrammingError as e:
        if e[0]==1007: print "Database exists, not overwriting."
        else: raise
    else:
        sh('cd /root/projects/cosmohome/html/ops; ./db_schemaversion.php > /root/projects/cosmohome/db_revision')



    print "Running BOINC update scripts..."
    os.chdir('/root/projects/cosmohome')
    sh('bin/xadd')
    sh('(%s) | bin/update_versions'%('; '.join(['echo y']*10)))