예제 #1
0
def set_up_vim_addon_xmledit():
    print_msg('\nenable *.html files for vim addon xmledit:')
    ftplugin_dir = '~/.janus/xmledit/ftplugin'
    if exists(ftplugin_dir):
        # enable html file support (cf. http://stackoverflow.com/a/28603924):
        run(flo('cp -n {ftplugin_dir}/html.vim {ftplugin_dir}/html.vim.orig'))
        run(flo('ln -snf xml.vim {ftplugin_dir}/html.vim'))
예제 #2
0
def build_ct(build_dir, branch=None):
    base_dir = '~/repos'
    abs_path = run(flo('readlink -f {base_dir}'), capture=True)

    vars_str = ' '.join([
        flo('PATH="{abs_path}/depot_tools:$PATH"'),  # add depot_tools to PATH
        'CXX=clang++',
        'CC=clang',
    ])

    url = 'https://github.com/google/certificate-transparency.git'
    if branch:
        url = flo('{url}@{branch}')

    cmds = [
        (flo("\n### create gclient config file '{build_dir}/.gclient'\n"),
         flo('gclient config --name="certificate-transparency" {url}')),
        ('\n### retrieve and build dependencies\n', 'gclient sync'),
        ('\n### build CT software & self-test\n',
         'make -C certificate-transparency check'),
    ]
    for msg, cmd in cmds:
        print_msg(msg)
        cmd_yellow = yellow(cmd)
        if query_yes_no(question=flo("run cmd '{cmd_yellow}' ?")):
            run(flo('cd {build_dir} && {vars_str}  {cmd}'))

    print_msg('\n### installed ct commands\n')
    run(
        flo('tree -L 2 {build_dir}/certificate-transparency/cpp/ '
            '-I "*test|*.cc|*.h|*.in|*.a|*.o|*.log|*test.py|*.trs|stamp-h1|'
            'tsan_suppressions" --prune'))
예제 #3
0
파일: revealjs.py 프로젝트: theno/fabsetup
def revealjs_template():
    '''Create or update the template presentation demo using task `revealjs`.
    '''
    from config import basedir, github_user, github_repo

    run(flo('rm -f {basedir}/index.html'))
    run(flo('rm -f {basedir}/slides.md'))
    run(flo('rm -f {basedir}/README.md'))
    run(flo('rm -rf {basedir}/img/'))

    title = 'reveal.js template'
    subtitle = '[reveal.js][3] presentation written ' \
               'in [markdown][4] set up with [fabric][5] & [fabsetup][6]'
    description = '''\
This presentation shows how to create a reveal.js presentation which will be
set up with the fabric task `setup.revealjs` of fabsetup.

Also, you can use this presentation source as a reveal.js template:
* Checkout this repo
* Then set the title in the `index.html` and edit the
  `slides.md`.'''

    execute(revealjs, basedir, title, subtitle, description,
            github_user, github_repo)

    # (README.md was removed, but not the github remote repo)
    print_msg('\n## Re-add github repo infos into README.md')
    basename = os.path.basename(basedir)
    _insert_repo_infos_into_readme(basedir, github_user=_lazy('github_user'),
                                   github_repo=_lazy('github_repo',
                                                     default=basename))

    print_msg('\n## Assure symbolic link not tracked by git exists\n')
    run(flo('ln -snf ../reveal.js  {basedir}/reveal.js/reveal.js'))
예제 #4
0
파일: revealjs.py 프로젝트: theno/fabsetup
def decktape():
    '''Install DeckTape.

    DeckTape is a "high-quality PDF exporter for HTML5 presentation
    frameworks".  It can be used to create PDFs from reveal.js presentations.

    More info:
      https://github.com/astefanutti/decktape
      https://github.com/hakimel/reveal.js/issues/1252#issuecomment-198270915
    '''
    run('mkdir -p ~/bin/decktape')
    if not exists('~/bin/decktape/decktape-1.0.0'):
        print_msg('\n## download decktape 1.0.0\n')
        run('cd ~/bin/decktape && '
            'curl -L https://github.com/astefanutti/decktape/archive/'
            'v1.0.0.tar.gz | tar -xz --exclude phantomjs')
        run('cd ~/bin/decktape/decktape-1.0.0 && '
            'curl -L https://github.com/astefanutti/decktape/releases/'
            'download/v1.0.0/phantomjs-linux-x86-64 -o phantomjs')
        run('cd ~/bin/decktape/decktape-1.0.0 && '
            'chmod +x phantomjs')
    run('ln -snf ~/bin/decktape/decktape-1.0.0 ~/bin/decktape/active',
        msg='\n## link installed decktape version as active')
    print_msg('\nCreate PDF from reveal.js presentation:\n\n    '
              '# serve presentation:\n    '
              'cd ~/repos/my_presi/reveal.js/ && npm start\n\n    '
              '# create pdf in another shell:\n    '
              'cd ~/bin/decktape/active && \\\n    '
              './phantomjs decktape.js --size 1280x800  localhost:8000  '
              '~/repos/my_presi/my_presi.pdf')
예제 #5
0
def letsencrypt():
    '''Create tls-webserver certificates which are trusted by the web pki.

    The wildcard certificates are issued by Let's Encrypt.

    Touched files, dirs, and installed packages:

        /etc/letsencrypt/*
    '''

    repo_dir = checkup_git_repo('https://github.com/certbot/certbot.git',
                                prefix='## ', postfix='\n')

    with stopped_nginx():

        options = ' '.join([
            '--standalone',
            '--rsa-key-size 4096',
        ])

        from config import domain_groups

        for domains in domain_groups:

            domains_str = ', '.join(domains)
            print_msg(flo(
                '\n## Create certificate for: {domains_str}\n'))

            domain_opts = ' '.join([flo(' -d {domain}') for domain in domains])
            # command 'letsencrypt-auto' requests for root by itself via 'sudo'
            run(flo('{repo_dir}/letsencrypt-auto  '
                    '{options} {domain_opts}  certonly'))

    list_cert_files()
예제 #6
0
def _create_github_remote_repo(basedir):
    '''More info:
      https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
      https://developer.github.com/v3/repos/#create
      https://stackoverflow.com/a/10325316
    '''
    github_user = _lazy('github_user')
    github_repo = _lazy('github_repo', default=os.path.basename(basedir))

    _insert_repo_infos_into_readme(basedir, github_user, github_repo)
    run(flo('cd {basedir} && git add README.md'))
    run(
        flo('cd {basedir} && git commit -am "Add github repo and user '
            'into README.md"'))

    print_msg('create github repo')
    run(
        flo("cd {basedir}  &&  "
            "curl -u '{github_user}' https://api.github.com/user/repos "
            "-d '") + '{"name":"' + flo('{github_repo}"') + "}'")
    run(
        flo('cd {basedir}  &&  '
            'git remote add origin '
            '[email protected]:{github_user}/{github_repo}.git'))
    run(flo('cd {basedir}  &&  git push origin master'))
예제 #7
0
def revealjs_template():
    '''Create or update the template presentation demo using task `revealjs`.
    '''
    from config import basedir, github_user, github_repo

    run(flo('rm -f {basedir}/index.html'))
    run(flo('rm -f {basedir}/slides.md'))
    run(flo('rm -f {basedir}/README.md'))
    run(flo('rm -rf {basedir}/img/'))

    title = 'reveal.js template'
    subtitle = '[reveal.js][3] presentation written ' \
               'in [markdown][4] set up with [fabric][5] & [fabsetup][6]'
    description = '''\
This presentation shows how to create a reveal.js presentation which will be
set up with the fabric task `setup.revealjs` of fabsetup.

Also, you can use this presentation source as a reveal.js template:
* Checkout this repo
* Then set the title in the `index.html` and edit the
  `slides.md`.'''

    execute(revealjs, basedir, title, subtitle, description, github_user,
            github_repo)

    # (README.md was removed, but not the github remote repo)
    print_msg('\n## Re-add github repo infos into README.md')
    basename = os.path.basename(basedir)
    _insert_repo_infos_into_readme(basedir,
                                   github_user=_lazy('github_user'),
                                   github_repo=_lazy('github_repo',
                                                     default=basename))

    print_msg('\n## Assure symbolic link not tracked by git exists\n')
    run(flo('ln -snf ../reveal.js  {basedir}/reveal.js/reveal.js'))
예제 #8
0
파일: revealjs.py 프로젝트: theno/fabsetup
def tweak_css(repo_dir):
    '''Comment out some css settings.'''
    print_msg("* don't capitalize titles (no uppercase headings)")
    files = [
        'beige.css', 'black.css', 'blood.css', 'league.css', 'moon.css',
        'night.css', 'serif.css', 'simple.css', 'sky.css', 'solarized.css',
        'white.css',
    ]
    line = '  text-transform: uppercase;'
    for file_ in files:
        update_or_append_line(filename=flo('{repo_dir}/css/theme/{file_}'),
                              prefix=line, new_line=flo('/*{line}*/'))

    print_msg('* images without border')
    data = [
        {'file': 'beige.css',     'line': '  border: 4px solid #333;'},
        {'file': 'black.css',     'line': '  border: 4px solid #fff;'},
        {'file': 'blood.css',     'line': '  border: 4px solid #eee;'},
        {'file': 'league.css',    'line': '  border: 4px solid #eee;'},
        {'file': 'moon.css',      'line': '  border: 4px solid #93a1a1;'},
        {'file': 'night.css',     'line': '  border: 4px solid #eee;'},
        {'file': 'serif.css',     'line': '  border: 4px solid #000;'},
        {'file': 'simple.css',    'line': '  border: 4px solid #000;'},
        {'file': 'sky.css',       'line': '  border: 4px solid #333;'},
        {'file': 'solarized.css', 'line': '  border: 4px solid #657b83;'},
        {'file': 'white.css',     'line': '  border: 4px solid #222;'},
    ]
    for item in data:
        file_ = item['file']
        lines = [item['line'], ]
        lines.extend(['  box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }',
                      '  box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }'])
        for line in lines:
            update_or_append_line(filename=flo('{repo_dir}/css/theme/{file_}'),
                                  prefix=line, new_line=flo('/*{line}*/'))
예제 #9
0
파일: vim_janus.py 프로젝트: theno/fabsetup
def set_up_vim_addon_xmledit():
    print_msg('\nenable *.html files for vim addon xmledit:')
    ftplugin_dir = '~/.janus/xmledit/ftplugin'
    if exists(ftplugin_dir):
        # enable html file support (cf. http://stackoverflow.com/a/28603924):
        run(flo('cp -n {ftplugin_dir}/html.vim {ftplugin_dir}/html.vim.orig'))
        run(flo('ln -snf xml.vim {ftplugin_dir}/html.vim'))
예제 #10
0
def decktape():
    '''Install DeckTape.

    DeckTape is a "high-quality PDF exporter for HTML5 presentation
    frameworks".  It can be used to create PDFs from reveal.js presentations.

    More info:
      https://github.com/astefanutti/decktape
      https://github.com/hakimel/reveal.js/issues/1252#issuecomment-198270915
    '''
    run('mkdir -p ~/bin/decktape')
    if not exists('~/bin/decktape/decktape-1.0.0'):
        print_msg('\n## download decktape 1.0.0\n')
        run('cd ~/bin/decktape && '
            'curl -L https://github.com/astefanutti/decktape/archive/'
            'v1.0.0.tar.gz | tar -xz --exclude phantomjs')
        run('cd ~/bin/decktape/decktape-1.0.0 && '
            'curl -L https://github.com/astefanutti/decktape/releases/'
            'download/v1.0.0/phantomjs-linux-x86-64 -o phantomjs')
        run('cd ~/bin/decktape/decktape-1.0.0 && ' 'chmod +x phantomjs')
    run('ln -snf ~/bin/decktape/decktape-1.0.0 ~/bin/decktape/active',
        msg='\n## link installed decktape version as active')
    print_msg('\nCreate PDF from reveal.js presentation:\n\n    '
              '# serve presentation:\n    '
              'cd ~/repos/my_presi/reveal.js/ && npm start\n\n    '
              '# create pdf in another shell:\n    '
              'cd ~/bin/decktape/active && \\\n    '
              './phantomjs decktape.js --size 1280x800  localhost:8000  '
              '~/repos/my_presi/my_presi.pdf')
예제 #11
0
파일: revealjs.py 프로젝트: theno/fabsetup
def symbolic_links(repo_dir):
    print_msg('Create symbolic links in order to be able to start presi '
              'with npm (from the subdir reveal.js as starting point)')
    repo_name = os.path.basename(repo_dir)
    run(flo('ln -snf ../{repo_name}  {repo_dir}/{repo_name}'))
    run(flo('ln -snf ../img  {repo_dir}/img'))
    run(flo('ln -snf ../index.html  {repo_dir}/index.html'))
    run(flo('ln -snf ../slides.md  {repo_dir}/slides.md'))
예제 #12
0
def symbolic_links(repo_dir):
    print_msg('Create symbolic links in order to be able to start presi '
              'with npm (from the subdir reveal.js as starting point)')
    repo_name = os.path.basename(repo_dir)
    run(flo('ln -snf ../{repo_name}  {repo_dir}/{repo_name}'))
    run(flo('ln -snf ../img  {repo_dir}/img'))
    run(flo('ln -snf ../index.html  {repo_dir}/index.html'))
    run(flo('ln -snf ../slides.md  {repo_dir}/slides.md'))
예제 #13
0
def stopped_nginx():
    print_msg('\n## stop nginx\n')
    run('sudo service nginx stop')
    try:
        yield
    finally:
        print_msg('\n## start nginx\n')
        run('sudo service nginx start')
예제 #14
0
def setup_npm(revealjs_dir):
    if query_yes_no('\nSet up npm for serving presentation?', default='no'):
        run(flo('cd {revealjs_dir}  &&  ' 'npm install'))
        print_msg(
            flo('\nServe presentation locally '
                '(monitors source files for changes):\n\n'
                '    cd {revealjs_dir}  &&  npm start\n\n'
                'View presentation in a browser:\n\n'
                '    http://localhost:8000'))
예제 #15
0
def enable_php5_socket_file():
    filename = '/etc/php5/fpm/pool.d/www.conf'
    print_msg('comment out "listen = 127.0.0.1:9000"')
    comment_out_line(filename, comment=';', line='listen = 127.0.0.1:9000')
    line = 'listen = /var/run/php5-fpm.sock'
    print_msg(flo('\nuncomment "{line}"'))
    uncomment_or_update_or_append_line(filename, prefix=line, new_line=line,
                                       comment=';')
    run('sudo service php5-fpm restart', msg='\nrestart php5-fpm daemon')
예제 #16
0
파일: revealjs.py 프로젝트: theno/fabsetup
def setup_npm(revealjs_dir):
    if query_yes_no('\nSet up npm for serving presentation?',
                    default='no'):
        run(flo('cd {revealjs_dir}  &&  '
                'npm install'))
        print_msg(flo('\nServe presentation locally '
                      '(monitors source files for changes):\n\n'
                      '    cd {revealjs_dir}  &&  npm start\n\n'
                      'View presentation in a browser:\n\n'
                      '    http://localhost:8000'))
예제 #17
0
파일: revealjs.py 프로젝트: theno/fabsetup
def install_readme(basedir):
    readme_path = flo('{basedir}/README.md')
    if exists(readme_path):
        print_msg('already exists (skip)')
    else:
        presi_title = _lazy('presi_title', os.path.basename(basedir))
        presi_subtitle = _lazy('presi_subtitle')
        presi_description = _lazy('presi_description')
        install_file_legacy(path=readme_path, from_path='~/repos/my_presi/README.md',
                     presi_title=presi_title, presi_subtitle=presi_subtitle,
                     presi_description=presi_description, basedir=basedir)
예제 #18
0
파일: revealjs.py 프로젝트: theno/fabsetup
def init_git_repo(basedir):
    basedir_abs = os.path.expanduser(basedir)
    if os.path.isdir(flo('{basedir_abs}/.git')):
        print_msg('git repo already initialized (skip)')
    else:
        if not exists('{basedir_abs}/.gitignore'):
            install_file_legacy(path=flo('{basedir_abs}/.gitignore'),
                         from_path='~/repos/my_presi/.gitignore')
        run(flo('cd {basedir} && git init'))
        run(flo('cd {basedir} && git add .'))
        run(flo('cd {basedir} && git commit -am "Initial commit"'))
예제 #19
0
def init_git_repo(basedir):
    basedir_abs = os.path.expanduser(basedir)
    if os.path.isdir(flo('{basedir_abs}/.git')):
        print_msg('git repo already initialized (skip)')
    else:
        if not exists('{basedir_abs}/.gitignore'):
            install_file_legacy(path=flo('{basedir_abs}/.gitignore'),
                                from_path='~/repos/my_presi/.gitignore')
        run(flo('cd {basedir} && git init'))
        run(flo('cd {basedir} && git add .'))
        run(flo('cd {basedir} && git commit -am "Initial commit"'))
예제 #20
0
파일: revealjs.py 프로젝트: theno/fabsetup
def install_markdown_slides_template(basedir):
    slides_path = flo('{basedir}/slides.md')
    if exists(slides_path):
        print_msg('already exists (skip)')
    else:
        presi_title = _lazy('presi_title', os.path.basename(basedir))
        presi_subtitle = _lazy('presi_subtitle')
        cur_date = run(r'date +%F', capture=True)
        install_file_legacy(path=slides_path,
                     from_path='~/repos/my_presi/slides.md',
                     presi_title_upper=presi_title.replace('_', ' ').upper(),
                     presi_subtitle=presi_subtitle, cur_date=cur_date)
예제 #21
0
def install_selfoss(sitename, site_dir, username):
    save_settings_and_data(site_dir)
    run(flo("sudo  rsync -a --delete --force --exclude='.git'  ~/repos/selfoss "
            ' {site_dir}'), msg='\n### install files')
    restored = restore_settings_and_data(site_dir)
    install_spout_fulltextrssGoogleBot(sitename)
    print_msg('\n### set write permissions for group www-data')
    for dirname in ['data/cache', 'data/favicons', 'data/logs',
                    'data/thumbnails', 'data/sqlite', 'public']:
        run(flo('sudo chown --recursive  www-data.www-data  '
                '{site_dir}/selfoss/{dirname}'))
    return restored
예제 #22
0
def install(srcdir, inst_base, version, instdir):
    run(flo('rm -rf {instdir}'),
        msg='remove files from previous installations (if any)')

    run(flo('cd {srcdir}  &&  make install'), msg='install/copy files')

    run(flo('cd {inst_base}  &&  ln -snf  {version}  active'),
        msg='activate installed openssl')

    print_msg('link openssl commands')
    run(flo('cd ~/bin  &&  ln -snf {inst_base}/active/bin/openssl  openssl'))
    run(flo('cd ~/bin  &&  ln -snf {inst_base}/active/bin/c_rehash  c_rehash'))
예제 #23
0
파일: revealjs.py 프로젝트: theno/fabsetup
def install_plugin_toc_progress(plugin_dir):
    export_repo(plugin_dir,
                'https://github.com/e-gor/Reveal.js-TOC-Progress.git',
                repo_name='toc-progress_all')
    run(flo('mv {plugin_dir}/toc-progress_all/plugin/toc-progress  '
            '{plugin_dir}/toc-progress'))
    run(flo('rm -rf {plugin_dir}/toc-progress_all'))
    print_msg('correct css path (because reveal.js is placed in a subdir)')
    update_or_append_line(flo('{plugin_dir}/toc-progress/toc-progress.js'),
                          prefix='\tlink.href="plugin/'
                                 'toc-progress/toc-progress.css"',
                          new_line='\tlink.href="reveal.js/plugin/'
                                   'toc-progress/toc-progress.css"')
예제 #24
0
파일: revealjs.py 프로젝트: theno/fabsetup
def install_plugin_title_footer(plugin_dir):
    export_repo(plugin_dir,
                'https://github.com/e-gor/Reveal.js-Title-Footer.git',
                repo_name='title-footer_all')
    run(flo('mv {plugin_dir}/title-footer_all/plugin/title-footer  '
            '{plugin_dir}/title-footer'))
    run(flo('rm -rf {plugin_dir}/title-footer_all'))
    print_msg('correct css path (because reveal.js is placed in a subdir)')
    update_or_append_line(flo('{plugin_dir}/title-footer/title-footer.js'),
                          prefix='\tlink.href="plugin/'
                                 'title-footer/title-footer.css";',
                          new_line='\tlink.href="reveal.js/plugin/'
                                   'title-footer/title-footer.css";')
예제 #25
0
def install_readme(basedir):
    readme_path = flo('{basedir}/README.md')
    if exists(readme_path):
        print_msg('already exists (skip)')
    else:
        presi_title = _lazy('presi_title', os.path.basename(basedir))
        presi_subtitle = _lazy('presi_subtitle')
        presi_description = _lazy('presi_description')
        install_file_legacy(path=readme_path,
                            from_path='~/repos/my_presi/README.md',
                            presi_title=presi_title,
                            presi_subtitle=presi_subtitle,
                            presi_description=presi_description,
                            basedir=basedir)
예제 #26
0
def install_markdown_slides_template(basedir):
    slides_path = flo('{basedir}/slides.md')
    if exists(slides_path):
        print_msg('already exists (skip)')
    else:
        presi_title = _lazy('presi_title', os.path.basename(basedir))
        presi_subtitle = _lazy('presi_subtitle')
        cur_date = run(r'date +%F', capture=True)
        install_file_legacy(path=slides_path,
                            from_path='~/repos/my_presi/slides.md',
                            presi_title_upper=presi_title.replace('_',
                                                                  ' ').upper(),
                            presi_subtitle=presi_subtitle,
                            cur_date=cur_date)
예제 #27
0
def install_plugin_title_footer(plugin_dir):
    export_repo(plugin_dir,
                'https://github.com/e-gor/Reveal.js-Title-Footer.git',
                repo_name='title-footer_all')
    run(
        flo('mv {plugin_dir}/title-footer_all/plugin/title-footer  '
            '{plugin_dir}/title-footer'))
    run(flo('rm -rf {plugin_dir}/title-footer_all'))
    print_msg('correct css path (because reveal.js is placed in a subdir)')
    update_or_append_line(flo('{plugin_dir}/title-footer/title-footer.js'),
                          prefix='\tlink.href="plugin/'
                          'title-footer/title-footer.css";',
                          new_line='\tlink.href="reveal.js/plugin/'
                          'title-footer/title-footer.css";')
예제 #28
0
def install_plugin_toc_progress(plugin_dir):
    export_repo(plugin_dir,
                'https://github.com/e-gor/Reveal.js-TOC-Progress.git',
                repo_name='toc-progress_all')
    run(
        flo('mv {plugin_dir}/toc-progress_all/plugin/toc-progress  '
            '{plugin_dir}/toc-progress'))
    run(flo('rm -rf {plugin_dir}/toc-progress_all'))
    print_msg('correct css path (because reveal.js is placed in a subdir)')
    update_or_append_line(flo('{plugin_dir}/toc-progress/toc-progress.js'),
                          prefix='\tlink.href="plugin/'
                          'toc-progress/toc-progress.css"',
                          new_line='\tlink.href="reveal.js/plugin/'
                          'toc-progress/toc-progress.css"')
예제 #29
0
def set_up_vim_addon_vim_instant_markdown():
    print_msg('\ninstall instant-markdown-d with npm (node.js) '
              'for vim addon vim-instant-markdown')
    install_cmd = 'npm install -g instant-markdown-d'
    with warn_only():
        res = run(install_cmd)
        if res.return_code != 0:
            print_msg('npm is not installed')
            query = "Run fabric task 'setup.nvm' in order to install npm?"
            if query_yes_no(query, default='yes'):
                from nvm import nvm
                execute(nvm)
                run('bash -c "source ~/.bashrc_nvm && nvm install node"',
                    msg='\ninstall latest version of npm')
                run(flo('bash -c "source ~/.bashrc_nvm && {install_cmd}"'),
                    msg="\nfabric task 'setup.nvm' finished\n\n"
                    '----\ninstall instant-markdown-d')
예제 #30
0
파일: vim_janus.py 프로젝트: theno/fabsetup
def set_up_vim_addon_vim_instant_markdown():
    print_msg('\ninstall instant-markdown-d with npm (node.js) '
              'for vim addon vim-instant-markdown')
    install_cmd = 'npm install -g instant-markdown-d'
    with warn_only():
        res = run(install_cmd)
        if res.return_code != 0:
            print_msg('npm is not installed')
            query = "Run fabric task 'setup.nvm' in order to install npm?"
            if query_yes_no(query, default='yes'):
                from nvm import nvm
                execute(nvm)
                run('bash -c "source ~/.bashrc_nvm && nvm install node"',
                    msg='\ninstall latest version of npm')
                run(flo('bash -c "source ~/.bashrc_nvm && {install_cmd}"'),
                    msg="\nfabric task 'setup.nvm' finished\n\n"
                        '----\ninstall instant-markdown-d')
예제 #31
0
파일: revealjs.py 프로젝트: theno/fabsetup
def _insert_repo_infos_into_readme(basedir, github_user, github_repo):
    print_msg('\nadd github user and repo name into README.md')
    filename = flo('{basedir}/README.md')
    # FIXME: workaround: line starts with space "trick" for github.io link
    #        correct solution would be: create util function update_line()
    #                                   which will not append if prefix not
    #                                   found in file
    update_or_append_line(filename,
                          #prefix=' https://USER.github.io/REPO',
                          prefix=' https://',
                          new_line=flo(' https://{github_user}.github.io/'
                                       '{github_repo}'))
    update_or_append_line(filename,
                          #prefix='https://github.com/USER/REPO/blob/master/'
                          #       'slides.md',
                          prefix='https://github.com/',
                          new_line=flo('https://github.com/{github_user}/'
                                       '{github_repo}/blob/master/slides.md'))
예제 #32
0
파일: fabfile.py 프로젝트: zzylydx/ctutlz
def uplogs():
    '''Download latest version of `all_logs_list.json`, `log_list.json`
    into dir `tests/data/test_ctlog`.
    '''
    basedir = dirname(__file__)
    test_data_dir = flo('{basedir}/tests/data/test_ctlog')

    tmp_dir = tempfile.mkdtemp(prefix='ctutlz_')

    file_items = [
        ('known-logs.html',
         'http://www.certificate-transparency.org/known-logs'),
        ('all_logs_list.json',
         'https://www.gstatic.com/ct/log_list/all_logs_list.json'),
        ('log_list.json', 'https://www.gstatic.com/ct/log_list/log_list.json'),
    ]
    for filename, url in file_items:
        print_msg(flo('\n## {filename}\n'))

        basename, ending = filename.split('.')
        latest = local(flo('cd {test_data_dir}  &&  '
                           'ls {basename}_*.{ending} | sort | tail -n1'),
                       capture=True)
        print(latest)

        tmp_file = flo('{tmp_dir}/{filename}')

        local(flo('wget {url} -O {tmp_file}'))

        with warn_only():
            res = local(flo('diff -u {test_data_dir}/{latest}  {tmp_file}'),
                        capture=True)
        print(res)
        files_differ = bool(res.return_code != 0)
        if files_differ:
            today = datetime.date.today().strftime('%F')
            local(
                flo('cp {tmp_file} {test_data_dir}/{basename}_{today}.{ending}'
                    ))
        else:
            print('no changes')

    print('')
    local(flo('rm -rf {tmp_dir}'))
예제 #33
0
def pencil3():
    '''Install or update latest Pencil version 3, a GUI prototyping tool.

    While it is the newer one and the GUI is more fancy, it is the "more beta"
    version of pencil.  For exmaple, to display a svg export may fail from
    within a reveal.js presentation.

    More info:
        Homepage: http://pencil.evolus.vn/Next.html
        github repo: https://github.com/evolus/pencil
    '''
    repo_name = 'pencil3'
    repo_dir = flo('~/repos/{repo_name}')
    print_msg('## fetch latest pencil\n')
    checkup_git_repo_legacy(url='https://github.com/evolus/pencil.git',
                            name=repo_name)
    run(flo('cd {repo_dir} && npm install'), msg='\n## install npms\n')
    install_user_command_legacy('pencil3', pencil3_repodir=repo_dir)
    print_msg('\nNow You can start pencil version 3 with this command:\n\n'
              '    pencil3')
예제 #34
0
def restore_settings_and_data(site_dir):
    config_restored = False
    data_dir_restored = False

    if exists(flo('{site_dir}/bak/config.ini')):
        run(flo('cp {site_dir}/bak/config.ini  {site_dir}/selfoss/config.ini'),
            msg='restore config.ini')
        config_restored = True

    if exists(flo('{site_dir}/bak/data')):
        run(flo('sudo  rsync -a --owner --group --delete --force  '
                '{site_dir}/bak/data  {site_dir}/selfoss'),
            msg='restore data dir')

    result = False
    if config_restored or data_dir_restored:
        result = True
    else:
        print_msg('nothing to restore')
    return result
예제 #35
0
def uninstall_janus():
    '''Remove all janus files and dirs and (try to) restore previous vim config.
    '''
    if exists('~/.vim/janus'):
        run('rm -rf ~/.vim', msg='delete janus repo dir')
        with warn_only():
            run('rm -rf ~/.janus', msg='delete ~/.janus dir')
            run('bash -c "rm ~/.{,g}vimrc{,.before,.after}"',
                msg='delete ~/.vimrc, ~/.vimrc.before, ~/.vimrc.after, '
                '~/.gvimrc, ~/.gvimrc.before and ~/.gvimrc.after')
            if exists('~/.vim.old'):
                run('mv ~/.vim.old  ~/.vim', msg='restore ~/.vim dir')
            for fname in ['~/.vimrc', '~/.gvimrc']:
                if exists(flo('{fname}.old')):
                    run(flo('mv {fname}.old  {fname}'),
                        msg=flo('restore {fname}'))
        run('ls -hal ~/.*vim*', msg='\nvim config restored:')
    else:
        print_msg('janus is not installed; nothing to do (abort)')
        exit(1)
예제 #36
0
파일: vim_janus.py 프로젝트: theno/fabsetup
def uninstall_janus():
    '''Remove all janus files and dirs and (try to) restore previous vim config.
    '''
    if exists('~/.vim/janus'):
        run('rm -rf ~/.vim', msg='delete janus repo dir')
        with warn_only():
            run('rm -rf ~/.janus', msg='delete ~/.janus dir')
            run('bash -c "rm ~/.{,g}vimrc{,.before,.after}"',
                msg='delete ~/.vimrc, ~/.vimrc.before, ~/.vimrc.after, '
                    '~/.gvimrc, ~/.gvimrc.before and ~/.gvimrc.after')
            if exists('~/.vim.old'):
                run('mv ~/.vim.old  ~/.vim', msg='restore ~/.vim dir')
            for fname in ['~/.vimrc', '~/.gvimrc']:
                if exists(flo('{fname}.old')):
                    run(flo('mv {fname}.old  {fname}'),
                        msg=flo('restore {fname}'))
        run('ls -hal ~/.*vim*', msg='\nvim config restored:')
    else:
        print_msg('janus is not installed; nothing to do (abort)')
        exit(1)
예제 #37
0
def _insert_repo_infos_into_readme(basedir, github_user, github_repo):
    print_msg('\nadd github user and repo name into README.md')
    filename = flo('{basedir}/README.md')
    # FIXME: workaround: line starts with space "trick" for github.io link
    #        correct solution would be: create util function update_line()
    #                                   which will not append if prefix not
    #                                   found in file
    update_or_append_line(
        filename,
        #prefix=' https://USER.github.io/REPO',
        prefix=' https://',
        new_line=flo(' https://{github_user}.github.io/'
                     '{github_repo}'))
    update_or_append_line(
        filename,
        #prefix='https://github.com/USER/REPO/blob/master/'
        #       'slides.md',
        prefix='https://github.com/',
        new_line=flo('https://github.com/{github_user}/'
                     '{github_repo}/blob/master/slides.md'))
예제 #38
0
파일: vim_janus.py 프로젝트: theno/fabsetup
def vim_janus(uninstall=None):
    '''Install or update Janus, a distribution of addons and mappings for vim.

    More info:
      https://github.com/carlhuda/janus
      Customization: https://github.com/carlhuda/janus/wiki/Customization

    Args:
        uninstall: If not None, Uninstall janus and restore old vim config
    '''
    if uninstall is not None:
        uninstall_janus()
    else:
        if not exists('~/.vim/janus'):
            print_msg('not installed => install')
            install_janus()
        else:
            print_msg('already installed => update')
            update_janus()
        customize_janus()
        show_files_used_by_vim_and_janus()
예제 #39
0
def vim_janus(uninstall=None):
    '''Install or update Janus, a distribution of addons and mappings for vim.

    More info:
      https://github.com/carlhuda/janus
      Customization: https://github.com/carlhuda/janus/wiki/Customization

    Args:
        uninstall: If not None, Uninstall janus and restore old vim config
    '''
    if uninstall is not None:
        uninstall_janus()
    else:
        if not exists('~/.vim/janus'):
            print_msg('not installed => install')
            install_janus()
        else:
            print_msg('already installed => update')
            update_janus()
        customize_janus()
        show_files_used_by_vim_and_janus()
예제 #40
0
def pencil2():
    '''Install or update latest Pencil version 2, a GUI prototyping tool.

    Tip: For svg exports displayed proper in other programs (eg. inkscape,
    okular, reveal.js presentations) only use the 'Common Shapes' and
    'Desktop - Sketchy GUI' elements.

    More info:
        github repo (forked version 2): https://github.com/prikhi/pencil
    '''
    repo_name = 'pencil2'
    repo_dir = flo('~/repos/{repo_name}')

    print_msg('## fetch latest pencil\n')
    checkup_git_repo_legacy(url='https://github.com/prikhi/pencil.git',
                            name=repo_name)

    print_msg('\n## build properties\n')
    update_or_append_line(flo('{repo_dir}/build/properties.sh'),
                          prefix='export MAX_VERSION=',
                          new_line="export MAX_VERSION='100.*'")
    run(flo('cat {repo_dir}/build/properties.sh'))

    run(flo('cd {repo_dir}/build && ./build.sh  linux'),
        msg='\n## build pencil\n')
    install_user_command_legacy('pencil2', pencil2_repodir=repo_dir)
    print_msg('\nNow You can start pencil version 2 with this command:\n\n'
              '    pencil2')
예제 #41
0
파일: revealjs.py 프로젝트: theno/fabsetup
def custom_index_html(basedir, repo_dir):
    if exists(flo('{repo_dir}/index.html')):
        run(flo('cd {repo_dir} && cp --no-clobber index.html index.html_orig'),
            'save original index.html')
    index_html_path = flo('{basedir}/index.html')
    if exists(index_html_path):
        print_msg('\nalready exists (skip)')
    else:
        presi_title = _lazy('presi_title', os.path.basename(basedir))
        print_msg(flo('\ncustomizations of index.html:\n'
                      " * <title>{presi_title}</title>\n"
                      " * 'solarized' as default theme\n"
                      " * load plugins 'menu', 'solarized', 'toc-progress'\n"
                      " * config for plugins: 'menu', 'math'\n"
                      ""))
        install_file_legacy(path=index_html_path,
                     from_path='~/repos/my_presi/index.html',
                     presi_title_space=presi_title.replace('_', ' '))
        thanks_img_path = flo('{basedir}/img/thanks.jpg')
        if not exists(thanks_img_path):
            install_file_legacy(path=thanks_img_path,
                         from_path='~/repos/my_presi/img/thanks.jpg')
예제 #42
0
파일: revealjs.py 프로젝트: theno/fabsetup
def _create_github_remote_repo(basedir):
    '''More info:
      https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
      https://developer.github.com/v3/repos/#create
      https://stackoverflow.com/a/10325316
    '''
    github_user = _lazy('github_user')
    github_repo = _lazy('github_repo', default=os.path.basename(basedir))

    _insert_repo_infos_into_readme(basedir, github_user, github_repo)
    run(flo('cd {basedir} && git add README.md'))
    run(flo('cd {basedir} && git commit -am "Add github repo and user '
            'into README.md"'))

    print_msg('create github repo')
    run(flo("cd {basedir}  &&  "
            "curl -u '{github_user}' https://api.github.com/user/repos "
            "-d '") + '{"name":"' + flo('{github_repo}"') + "}'")
    run(flo('cd {basedir}  &&  '
            'git remote add origin '
            '[email protected]:{github_user}/{github_repo}.git'))
    run(flo('cd {basedir}  &&  git push origin master'))
예제 #43
0
def set_up_trac_plugins(sitename, site_dir, bin_dir):
    plugins = []
    try:
        from config import trac_plugins_by_sitename
        plugins = trac_plugins_by_sitename.get(sitename, [])
    except ImportError:
        pass  # ignore non-existing config entry
    svn_base_url = 'https://trac-hacks.org/svn'
    plugin_src_basedir = flo('{site_dir}/trac-plugin-src')
    if plugins:
        for plugin in plugins:
            print_msg(flo('### {plugin.name}\n\nInfos: {plugin.homepage}\n'))
            plugin_src_dir = flo('{plugin_src_basedir}/{plugin.name}')
            # FIXME: simplify: All Plugins provide a zip src-file
            # no differing handling between git and svn required here
            if plugin.git_instead_of_svn:
                # git-repo
                if not exists(flo('{plugin_src_dir}/.git')):
                    run(flo('cd {plugin_src_basedir}  &&  '
                            'git clone {plugin.git_repo_url}  {plugin.name}'))
                else:
                    run(flo('cd {plugin_src_dir}  &&  git pull'))

            else:
                # svn-repo
                if exists(plugin_src_dir):
                    run(flo('cd {plugin_src_dir}  &&  svn up'),
                        msg='update plugin repo:')
                else:
                    run(flo('mkdir -p {plugin_src_basedir}'),
                        msg='checkout plugin repo:')
                    run(flo('svn checkout  '
                            '{svn_base_url}/{plugin.name}/{plugin.svn_version} '
                            ' {plugin_src_dir}'))
            run(flo('{bin_dir}/pip install --upgrade {plugin_src_dir}'),
                msg='install plugin:')
    else:
        print_msg('plugins not configured in fabsetup_custom/setup.py:  '
                  'nothing to do')
예제 #44
0
파일: __init__.py 프로젝트: theno/fabsetup
def build_ct(build_dir, branch=None):
    base_dir = '~/repos'
    abs_path = run(flo('readlink -f {base_dir}'), capture=True)

    vars_str = ' '.join([
        flo('PATH="{abs_path}/depot_tools:$PATH"'),  # add depot_tools to PATH
        'CXX=clang++',
        'CC=clang',
    ])

    url = 'https://github.com/google/certificate-transparency.git'
    if branch:
        url = flo('{url}@{branch}')

    cmds = [
        (
            flo("\n### create gclient config file '{build_dir}/.gclient'\n"),
            flo('gclient config --name="certificate-transparency" {url}')
        ),
        (
            '\n### retrieve and build dependencies\n',
            'gclient sync'
        ),
        (
            '\n### build CT software & self-test\n',
            'make -C certificate-transparency check'
        ),
    ]
    for msg, cmd in cmds:
        print_msg(msg)
        cmd_yellow = yellow(cmd)
        if query_yes_no(question=flo("run cmd '{cmd_yellow}' ?")):
            run(flo('cd {build_dir} && {vars_str}  {cmd}'))

    print_msg('\n### installed ct commands\n')
    run(flo('tree -L 2 {build_dir}/certificate-transparency/cpp/ '
            '-I "*test|*.cc|*.h|*.in|*.a|*.o|*.log|*test.py|*.trs|stamp-h1|'
            'tsan_suppressions" --prune'))
예제 #45
0
def custom_index_html(basedir, repo_dir):
    if exists(flo('{repo_dir}/index.html')):
        run(flo('cd {repo_dir} && cp --no-clobber index.html index.html_orig'),
            'save original index.html')
    index_html_path = flo('{basedir}/index.html')
    if exists(index_html_path):
        print_msg('\nalready exists (skip)')
    else:
        presi_title = _lazy('presi_title', os.path.basename(basedir))
        print_msg(
            flo('\ncustomizations of index.html:\n'
                " * <title>{presi_title}</title>\n"
                " * 'solarized' as default theme\n"
                " * load plugins 'menu', 'solarized', 'toc-progress'\n"
                " * config for plugins: 'menu', 'math'\n"
                ""))
        install_file_legacy(path=index_html_path,
                            from_path='~/repos/my_presi/index.html',
                            presi_title_space=presi_title.replace('_', ' '))
        thanks_img_path = flo('{basedir}/img/thanks.jpg')
        if not exists(thanks_img_path):
            install_file_legacy(path=thanks_img_path,
                                from_path='~/repos/my_presi/img/thanks.jpg')
예제 #46
0
def install_calibre(instdir):
    inst_parent = dirname(instdir)
    inst_tmp = join(inst_parent, 'calibre-tmp')

    run(flo('mkdir -p {inst_tmp}'),
        msg='### assure, inst base-dir exists\n')

    run(flo('wget -nv -O- '
            'https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/'
            'linux-installer.py | '
            'python -c "import sys; '
            'main=lambda x,y:sys.stderr.write(\'Download failed\\n\'); '
            'exec(sys.stdin.read()); main(\'{inst_tmp}\', True)"'),
        msg='\n### download and run calibre installer script\n')

    # calibre-installer installs into {inst_tmp}/calibre/; needs to be moved
    print_msg('\n### replace old install (if exists) by new installation\n')
    run(flo('rm -rf  {instdir}'))
    run(flo('mv  {inst_tmp}/calibre  {instdir}'))
    run(flo('rmdir  {inst_tmp}'))

    run(flo('ln -snf  {instdir}/calibre  ~/bin/calibre'),
        msg='\n### link calibre command to dir `~/bin` (should be in PATH)\n')
예제 #47
0
def selfoss(reset_password=False):
    '''Install, update and set up selfoss.

    This selfoss installation uses sqlite (selfoss-default), php5-fpm and nginx.

    The connection is https-only and secured by a letsencrypt certificate.  This
    certificate must be created separately with task setup.server_letsencrypt.

    More infos:
      https://selfoss.aditu.de/
      https://github.com/SSilence/selfoss/wiki
      https://www.heise.de/ct/ausgabe/2016-13-RSS-Reader-Selfoss-hat-die-Nachrichtenlage-im-Blick-3228045.html
      https://ct.de/yqp7
    '''
    hostname = re.sub(r'^[^@]+@', '', env.host)  # without username if any
    sitename = query_input(
                   question='\nEnter site-name of Your trac web service',
                   default=flo('selfoss.{hostname}'))
    username = env.user

    site_dir = flo('/home/{username}/sites/{sitename}')

    checkout_latest_release_of_selfoss()
    create_directory_structure(site_dir)

    restored = install_selfoss(sitename, site_dir, username)

    nginx_site_config(username, sitename, hostname)
    enable_php5_socket_file()

    if not restored or reset_password:
        setup_selfoss_user(username, sitename, site_dir)

    print_msg('\n## reload nginx and restart php\n')
    run('sudo service nginx reload')
    run('sudo service php5-fpm restart')
예제 #48
0
def compile(inst_dir):
    installed = flo('{inst_dir}/dumpasn1.c.1')
    latest = flo('{inst_dir}/dumpasn1.c')
    if isfile(expanduser(installed)):
        # wget has downloaded the latest version and moved the existing
        # (installed) version to dumpasn1.c.1
        if filecmp.cmp(expanduser(latest), expanduser(installed)):
            print_msg('no new version of dumpasn1.c (skip)')
        else:
            print_msg('new version of dumpasn1.c  ->  compile it')
            _compile(inst_dir)
        run(flo('rm {installed}'))
    else:
        print_msg('compile dumpasn1.c')
        _compile(inst_dir)
예제 #49
0
파일: __init__.py 프로젝트: theno/fabsetup
def vim():
    '''Customize vim, install package manager pathogen and some vim-packages.

    pathogen will be installed as a git repo at ~/repos/vim-pathogen and
    activated in vim by a symbolic link at ~/.vim/autoload/pathogen.vim

    A ~/.vimrc will be installed which loads the package manager within of vim.

    The vim packages vim-colors-solarized, nerdtree, and tagbar are installed
    as git repos placed at dir ~/.vim/bundle/

    If you want to install more vim packages also place them at this dir, cf.
    https://logicalfriday.com/2011/07/18/using-vim-with-pathogen/
    '''
    install_package('vim')

    print_msg('## install ~/.vimrc\n')
    install_file_legacy('~/.vimrc')

    print_msg('\n## set up pathogen\n')
    run('mkdir -p  ~/.vim/autoload  ~/.vim/bundle')
    checkup_git_repo_legacy(url='https://github.com/tpope/vim-pathogen.git')
    run('ln -snf  ~/repos/vim-pathogen/autoload/pathogen.vim  '
        '~/.vim/autoload/pathogen.vim')

    print_msg('\n## install vim packages\n')
    install_package('ctags')  # required by package tagbar
    repos = [
        {
            'name': 'vim-colors-solarized',
            'url': 'git://github.com/altercation/vim-colors-solarized.git',
        },
        {
            'name': 'nerdtree',
            'url': 'https://github.com/scrooloose/nerdtree.git',
        },
        {
            'name': 'vim-nerdtree-tabs',
            'url': 'https://github.com/jistr/vim-nerdtree-tabs.git',
        },
        {
            'name': 'tagbar',
            'url': 'https://github.com/majutsushi/tagbar.git',
        },
    ]
    checkup_git_repos_legacy(repos, base_dir='~/.vim/bundle')
예제 #50
0
파일: revealjs.py 프로젝트: theno/fabsetup
def create_github_remote_repo(basedir):
    '''Create a remote origin repo at github.com if wanted.'''
    if remote_origin_configured(basedir):
        print_msg('remote origin already configured (skip)')
    elif query_yes_no('Create remote repo at github.com?', default='no'):
        _create_github_remote_repo(basedir)
예제 #51
0
파일: dumpasn1.py 프로젝트: theno/fabsetup
def usage():
    run('dumpasn1 -h  || true')
    print('\nFor example, run:\n')
    print_msg('    dumpasn1  ~/bin/dumpasn1-tool/example.der')
    print_msg('    hexdump -C  ~/bin/dumpasn1-tool/example.der')