Esempio n. 1
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'))
Esempio n. 2
0
def lms():
    '''Install and start a Logitech Media Server (lms).

    More infos:
     * http://wiki.slimdevices.com/index.php/Logitech_Media_Server
     * http://wiki.slimdevices.com/index.php/DebianPackage
     * http://www.mysqueezebox.com/download
     * XSqueeze on Kodi:
       * http://kodi.wiki/view/Add-on:XSqueeze
       * http://forum.kodi.tv/showthread.php?tid=122199
    '''
    # cf. http://wiki.slimdevices.com/index.php/DebianPackage#installing_7.9.0
    cmds = '''\
url="http://www.mysqueezebox.com/update/?version=7.9.0&revision=1&geturl=1&os=deb"
latest_lms=$(wget -q -O - "$url")
mkdir -p ~/.logitech_media_server_sources
cd ~/.logitech_media_server_sources
wget $latest_lms
lms_deb=${latest_lms##*/}
sudo dpkg -i $lms_deb
'''
    run(cmds)
    run('sudo usermod -aG audio  squeezeboxserver')
    with warn_only():
        run('sudo addgroup lms')
    run('sudo usermod -aG lms  squeezeboxserver')
    username = env.user
    run(flo('sudo usermod -aG audio  {username}'))
    print('\n    Set correct folder permissions manually, eg:')
    print('    > ' +
          cyan(flo('chown -R {username}.lms  <path/to/your/media>')))
    hostname = env.host
    print(flo('\n    lms frontend available at http://{hostname}:9000'))
Esempio n. 3
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'))
Esempio n. 4
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()
Esempio n. 5
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')
Esempio n. 6
0
def setup_webserver():
    '''Run setup tasks to set up a nicely configured webserver.

    Features:
     * owncloud service
     * fdroid repository
     * certificates via letsencrypt
     * and more

    The task is defined in file fabsetup_custom/fabfile_addtitions/__init__.py
    and could be customized by Your own needs.  More info: README.md
    '''
    run('sudo apt-get update')
    install_packages(packages_webserver)
    execute(custom.latex)
    execute(setup.solarized)
    execute(setup.vim)
    execute(setup.tmux)
    checkup_git_repo_legacy(url='[email protected]:letsencrypt/letsencrypt.git')
    execute(setup.service.fdroid)
    execute(setup.service.owncloud)
    # circumvent circular import, cf. http://stackoverflow.com/a/18486863
    from fabfile import dfh, check_reboot
    dfh()
    check_reboot()
Esempio n. 7
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'))
Esempio n. 8
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'))
Esempio n. 9
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')
Esempio n. 10
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'))
Esempio n. 11
0
def server_customizations():
    '''Customize the server (user, authorized_keys, ...).'''

    username = env.user
    env.user = '******'

    # create user
    all_users = run('cut -d: -f1 /etc/passwd').split()
    if username not in all_users:

        host = env.host

        run(flo('adduser {username}'))

        # add user to the sudo group, cf. http://askubuntu.com/a/7484
        #run('sudo adduser {username} sudo'.format(**locals()))
        # http://jeromejaglale.com/doc/unix/ubuntu_sudo_without_password
        append('/etc/sudoers', flo('{username} ALL=(ALL) NOPASSWD: ALL'),
               use_sudo=True)

        # set up password-less login
        local(flo('ssh-copy-id -i ~/.ssh/id_rsa.pub  {username}@{host}'))

        env.user = username

        # Disable service apache2 httpd, cf. http://askubuntu.com/a/355102
        sudo('update-rc.d apache2 disable')
    else:
        print(magenta(flo(' nothing to do, user {username} already exists')))
        env.user = username
Esempio n. 12
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')
Esempio n. 13
0
def lms():
    '''Install and start a Logitech Media Server (lms).

    More infos:
     * http://wiki.slimdevices.com/index.php/Logitech_Media_Server
     * http://wiki.slimdevices.com/index.php/DebianPackage
     * http://www.mysqueezebox.com/download
     * XSqueeze on Kodi:
       * http://kodi.wiki/view/Add-on:XSqueeze
       * http://forum.kodi.tv/showthread.php?tid=122199
    '''
    # cf. http://wiki.slimdevices.com/index.php/DebianPackage#installing_7.9.0
    cmds = '''\
url="http://www.mysqueezebox.com/update/?version=7.9.0&revision=1&geturl=1&os=deb"
latest_lms=$(wget -q -O - "$url")
mkdir -p ~/.logitech_media_server_sources
cd ~/.logitech_media_server_sources
wget $latest_lms
lms_deb=${latest_lms##*/}
sudo dpkg -i $lms_deb
'''
    run(cmds)
    run('sudo usermod -aG audio  squeezeboxserver')
    with warn_only():
        run('sudo addgroup lms')
    run('sudo usermod -aG lms  squeezeboxserver')
    username = env.user
    run(flo('sudo usermod -aG audio  {username}'))
    print('\n    Set correct folder permissions manually, eg:')
    print('    > ' + cyan(flo('chown -R {username}.lms  <path/to/your/media>')))
    hostname = env.host
    print(flo('\n    lms frontend available at http://{hostname}:9000'))
Esempio n. 14
0
def test(srcdir, ignore_fail):
    cmd = flo('cd {srcdir}  &&  make test')
    if ignore_fail:
        with warn_only():
            run(cmd)
    else:
        run(cmd)
Esempio n. 15
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'))
Esempio n. 16
0
def upgrade_nvm():
    cmds = '''\
export NVM_DIR="$HOME/.nvm" && (
  cd "$NVM_DIR"
  git fetch origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
) && . "$NVM_DIR/nvm.sh"'''
    run(cmds)
Esempio n. 17
0
def upgrade_nvm():
    cmds = '''\
export NVM_DIR="$HOME/.nvm" && (
  cd "$NVM_DIR"
  git fetch origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
) && . "$NVM_DIR/nvm.sh"'''
    run(cmds)
Esempio n. 18
0
def install_nvm():
    cmds = '''\
export NVM_DIR="$HOME/.nvm" && (
  git clone https://github.com/creationix/nvm.git "$NVM_DIR"
  cd "$NVM_DIR"
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
) && . "$NVM_DIR/nvm.sh"'''
    run(cmds)
Esempio n. 19
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')
Esempio n. 20
0
def install_nvm():
    cmds = '''\
export NVM_DIR="$HOME/.nvm" && (
  git clone https://github.com/creationix/nvm.git "$NVM_DIR"
  cd "$NVM_DIR"
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
) && . "$NVM_DIR/nvm.sh"'''
    run(cmds)
Esempio n. 21
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')
Esempio n. 22
0
def irssi():
    '''Set up irc client irssi.

    More infos:
     * https://wiki.archlinux.org/index.php/Irssi
    '''
    install_packages(['irssi'])
    install_file_legacy('~/.irssi/config')
    run(os.path.expanduser('chmod 600 ~/.irssi/config'))
Esempio n. 23
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'))
Esempio n. 24
0
def export_repo(parent_dir, repo_url, repo_name=None):
    if repo_name:
        repo_dir = flo('{parent_dir}/{repo_name}')
        if exists(repo_dir):
            run(flo('rm -rf {repo_dir}'), msg='delete existing repo dir')
    repo_name = checkup_git_repo_legacy(repo_url,
                                        name=repo_name,
                                        base_dir=parent_dir)
    run(flo('cd {parent_dir}/{repo_name} && rm -rf .git/'),
        msg='delete .git dir (the hole presentation becomes a git repository)')
Esempio n. 25
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'))
Esempio n. 26
0
def i3():
    '''Install and customize the tiling window manager i3.'''
    install_package('i3')
    install_file_legacy(path='~/.i3/config', username=env.user, repos_dir='repos')

    # setup: hide the mouse if not in use
    # in ~/.i3/config: 'exec /home/<USERNAME>/repos/hhpc/hhpc -i 10 &'
    install_packages(['make', 'pkg-config', 'gcc', 'libc6-dev', 'libx11-dev'])
    checkup_git_repo_legacy(url='https://github.com/aktau/hhpc.git')
    run('cd ~/repos/hhpc  &&  make')
Esempio n. 27
0
def restore_tracenv_from_backup_tarball(site_dir, bin_dir):
    # FIXME stop trac if it is running already
    filename_tarball = query_input('tarball path?')
    run(flo('mkdir -p {site_dir}/tmp'))
    run(flo('tar xf {filename_tarball}  --directory={site_dir}/tmp'))
    # save tracenv if it exists
    run(flo('mv {site_dir}/tracenv  {site_dir}/tracenv.before_$(date +%F).bak'
            ' || true'))
    run(flo('mv {site_dir}/tmp/tracenv_hotcopy  {site_dir}/tracenv'))
    run(flo('rmdir {site_dir}/tmp'))
Esempio n. 28
0
def export_repo(parent_dir, repo_url, repo_name=None):
    if repo_name:
        repo_dir = flo('{parent_dir}/{repo_name}')
        if exists(repo_dir):
            run(flo('rm -rf {repo_dir}'),
                msg='delete existing repo dir')
    repo_name = checkup_git_repo_legacy(repo_url, name=repo_name,
                                        base_dir=parent_dir)
    run(flo('cd {parent_dir}/{repo_name} && rm -rf .git/'),
        msg='delete .git dir (the hole presentation becomes a git repository)')
Esempio n. 29
0
def update_virtualenv(site_dir, sitename):
    stop_gunicorn_daemon(sitename)
    create_virtualenv(site_dir)
    run(flo(
        '{site_dir}/virtualenv/bin/'
        'pip install --upgrade  '
        'pip genshi trac gunicorn '

        # https://trac-hacks.org/wiki/MarkdownMacro
        'Markdown '  # required by TracPlugin MarkdownMakro
    ))
Esempio n. 30
0
def setup_selfoss_user(username, sitename, site_dir):
    if not exists(flo('{site_dir}/selfoss/config.ini')):
        chars = 'abcdefghijklmnopqrstuvwxyz0123456789'
        salt = ''.join(random.SystemRandom().choice(chars) for _ in range(150))
        install_file_legacy('~/sites/SITENAME/selfoss/config.ini',
                     SITENAME=sitename, salt=salt)

    run('sudo service nginx reload')
    run('sudo service php5-fpm restart')

    selfoss_username(username, sitename)
    selfoss_password(sitename)
Esempio n. 31
0
def set_up_powerline_fonts():
    checkup_git_repo_legacy('https://github.com/powerline/fonts.git',
                            name='powerline-fonts')
    # install fonts into ~/.local/share/fonts
    run('cd ~/repos/powerline-fonts && ./install.sh')
    prefix = 'URxvt*font: '
    from config import fontlist
    line = prefix + fontlist
    update_or_append_line(filename='~/.Xresources', prefix=prefix,
                          new_line=line)
    if env.host_string == 'localhost':
        run('xrdb  ~/.Xresources')
Esempio n. 32
0
def ripping_of_cds():
    '''Install the tools ripit and burnit in order to rip and burn audio cds.

    More info: http://forums.debian.net/viewtopic.php?f=16&t=36826
    '''
    # install and configure ripit
    install_package('ripit')
    install_file_legacy(path='~/.ripit/config', username=env.user)
    # install burnit
    run('mkdir -p  ~/bin')
    install_file_legacy('~/bin/burnit')
    run('chmod 755 ~/bin/burnit')
Esempio n. 33
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
Esempio n. 34
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'))
Esempio n. 35
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"')
Esempio n. 36
0
def set_up_powerline_fonts():
    checkup_git_repo_legacy('https://github.com/powerline/fonts.git',
                            name='powerline-fonts')
    # install fonts into ~/.local/share/fonts
    run('cd ~/repos/powerline-fonts && ./install.sh')
    prefix = 'URxvt*font: '
    from config import fontlist
    line = prefix + fontlist
    update_or_append_line(filename='~/.Xresources',
                          prefix=prefix,
                          new_line=line)
    if env.host_string == 'localhost':
        run('xrdb  ~/.Xresources')
Esempio n. 37
0
def install_upgrade_powerline():
    '''
    More infos:
      https://powerline.readthedocs.io/en/latest/installation.html#pip-installation
    '''
    checkup_git_repo_legacy('https://github.com/powerline/powerline.git')
    path_to_powerline = os.path.expanduser('~/repos/powerline')
    run(flo('pip install --user --editable={path_to_powerline}'))
    run('pip show powerline-status')  # only for information
    install_special_glyphs()
    bindings_dir = '~/repos/powerline/powerline/bindings'
    scripts_dir = '~/repos/powerline/scripts'
    return bindings_dir, scripts_dir
Esempio n. 38
0
def setup_fonts_for_powerline_shell():
    repo_dir = checkup_git_repo('https://github.com/powerline/fonts.git',
                                name='powerline-fonts')
    run(flo('cd {repo_dir} && ./install.sh'))
    #    run('fc-cache -vf ~/.local/share/fonts')
    prefix = 'URxvt*font: '
    from config import fontlist
    line = prefix + fontlist
    update_or_append_line(filename='~/.Xresources',
                          prefix=prefix,
                          new_line=line)
    if env.host_string == 'localhost':
        run('xrdb  ~/.Xresources')
Esempio n. 39
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";')
Esempio n. 40
0
def install_upgrade_powerline():
    '''
    More infos:
      https://powerline.readthedocs.io/en/latest/installation.html#pip-installation
    '''
    checkup_git_repo_legacy('https://github.com/powerline/powerline.git')
    path_to_powerline = os.path.expanduser('~/repos/powerline')
    run(flo('pip install --user --editable={path_to_powerline}'))
    run('pip show powerline-status')  # only for information
    install_special_glyphs()
    bindings_dir = '~/repos/powerline/powerline/bindings'
    scripts_dir = '~/repos/powerline/scripts'
    return bindings_dir, scripts_dir
Esempio n. 41
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";')
Esempio n. 42
0
def nginx_site_config(username, sitename, hostname):
#    filename = 'trac_site_config.template'  # TODO DEBUG
    filename = 'trac_site_config_gunicorn.template'
#    filename = 'trac_site_config_gunicorn2.template'
#    filename = 'trac_site_config_wsgi.template'
    fabfile_data_dir = FABFILE_DATA_DIR
    path = flo('{fabfile_data_dir}/files/etc/nginx/sites-available/{filename}')
#    dn_cn = query_input('Common Name (CN) of the Distinguished Named (DN) '
#                        'of the webserver certificate?',
#                        default=flo('haw2icalendar.{hostname}'))
    # dn_cn = flo('{hostname}')
    dn_cn = dn_cn_of_certificate_with_san(sitename)
    from_str = filled_out_template(path, username=username, sitename=sitename,
                                   hostname=hostname, dn_cn=dn_cn)
    with tempfile.NamedTemporaryFile(prefix=filename) as tmp_file:
        with open(tmp_file.name, 'w') as fp:
            fp.write(from_str)
        put(tmp_file.name, flo('/tmp/{filename}'))
    to = flo('/etc/nginx/sites-available/{sitename}')
    run(flo('sudo mv /tmp/{filename} {to}'))
    run(flo('sudo chown root.root {to}'))
    run(flo('sudo chmod 644 {to}'))
    run(flo(' '.join([
            'sudo  ln -snf ../sites-available/{sitename}',
            '/etc/nginx/sites-enabled/{sitename}',
    ])))
Esempio n. 43
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"')
Esempio n. 44
0
def solarized():
    '''Set solarized colors in urxvt, tmux, and vim.

    More Infos:
    * Getting solarized colors right with urxvt, st, tmux and vim:
      https://bbs.archlinux.org/viewtopic.php?id=164108

    * Creating ~/.Xresources:
      https://wiki.archlinux.org/index.php/Rxvt-unicode#Creating_.7E.2F.Xresources

    * Select a good font on Ubuntu:
      https://michaelheap.com/getting-solarized-working-on-ubuntu/

    * tmux and 256 colors:
      http://unix.stackexchange.com/a/118903
    '''
    install_packages(['rxvt-unicode', 'tmux', 'vim'])
    install_file_legacy('~/.Xresources')
    if env.host_string == 'localhost':
        run('xrdb  ~/.Xresources')

    # install and call term_colors
    run('mkdir -p  ~/bin')
    install_file_legacy('~/bin/term_colors')
    run('chmod 755 ~/bin/term_colors')
    run('~/bin/term_colors')
Esempio n. 45
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'))
Esempio n. 46
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)
Esempio n. 47
0
def download(inst_dir):
    url_script = 'https://www.cs.auckland.ac.nz/~pgut001/dumpasn1.c'
    url_config = 'https://www.cs.auckland.ac.nz/~pgut001/dumpasn1.cfg'
    url_example = 'https://github.com/openssl/openssl/blob/master/test/' \
                  'recipes/ocsp-response.der?raw=true'
    run(flo('mkdir -p {inst_dir}'))
    run(flo('cd {inst_dir}  &&  wget --backups=1  {url_script}'))
    run(flo('cd {inst_dir}  &&  wget -O dumpasn1.cfg  {url_config}'))
    run(flo('cd {inst_dir}  &&  wget -O example.der  {url_example}'))
Esempio n. 48
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')
Esempio n. 49
0
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')