示例#1
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()
示例#2
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')
示例#3
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')
示例#4
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')
示例#5
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
示例#6
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
示例#7
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')
示例#8
0
def checkout_latest_release_of_selfoss():
    if not exists('~/repos/selfoss/.git'):
        checkup_git_repo_legacy('https://github.com/SSilence/selfoss.git')
    else:
        run('cd ~/repos/selfoss && git fetch')

    # TODO since selfoss-2.17 Composer is required which needs to be set up
    #      on ubuntu 14.04:
    #      * https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04
    #      * https://getcomposer.org/
    # latest_tag = 'git describe --abbrev=0 --tags --match "[0-9.]*" origin'
    # run(flo('cd ~/repos/selfoss && git checkout $({latest_tag})'))
    latest_working_tag = '2.16'
    run(flo('cd ~/repos/selfoss && git checkout {latest_working_tag}'))

    run(flo('cd ~/repos/selfoss && git status'))  # show latest version
示例#9
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')
示例#10
0
def latex():
    '''Install all packages and tools required to compile my latex documents.

    * Install or update a lot of latex packages.
    * Install or update pencil, dia, inkscape, xsltproc for diagrams and
      images.
    * Install or update util commands for conversion of dia, ep, svg into pdf
      files.
    * Checkout or update a haw-thesis template git repository which uses all of
      the upper mentioned tools.
    '''
    users_bin_dir()
    # circumvent circular import, cf. http://stackoverflow.com/a/18486863
    from fabfile.setup import latex
    latex()
    checkup_git_repo_legacy(
        'https://github.com/theno/haw-inf-thesis-template.git')
示例#11
0
def powerline_shell():
    '''Install and set up powerline-shell prompt.

    More infos:
     * https://github.com/banga/powerline-shell
     * https://github.com/ohnonot/powerline-shell
     * https://askubuntu.com/questions/283908/how-can-i-install-and-use-powerline-plugin
    '''
    assert env.host == 'localhost', 'This task cannot run on a remote host'

    # set up fonts for powerline

    checkup_git_repo_legacy('https://github.com/powerline/fonts.git',
                            name='powerline-fonts')
    run('cd ~/repos/powerline-fonts && ./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')

    # set up powerline-shell

    checkup_git_repo_legacy('https://github.com/banga/powerline-shell.git')
#    checkup_git_repo_legacy('https://github.com/ohnonot/powerline-shell.git')
    install_file_legacy(path='~/repos/powerline-shell/config.py')
    run('cd ~/repos/powerline-shell && ./install.py')

    question = 'Use normal question mark (u003F) for untracked files instead '\
        'of fancy "black question mark ornament" (u2753, which may not work)?'
    if query_yes_no(question, default='yes'):
        filename = '~/repos/powerline-shell/powerline-shell.py'
        update_or_append_line(filename, keep_backup=False,
                              prefix="        'untracked': u'\u2753',",
                              new_line="        'untracked': u'\u003F',")
        run(flo('chmod u+x  {filename}'))

    bash_snippet = '~/.bashrc_powerline_shell'
    install_file_legacy(path=bash_snippet)
    prefix = flo('if [ -f {bash_snippet} ]; ')
    enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi')
    uncomment_or_update_or_append_line(filename='~/.bashrc', prefix=prefix,
                                       new_line=enabler)
示例#12
0
def vnc_raspi_osmc():
    '''Install and configure dispmanx_vnc server on osmc (raspberry pi).

    More Infos:
     * https://github.com/patrikolausson/dispmanx_vnc
     * https://discourse.osmc.tv/t/howto-install-a-vnc-server-on-the-raspberry-pi/1517
     * tightvnc:
       * http://raspberry.tips/raspberrypi-einsteiger/raspberry-pi-einsteiger-guide-vnc-einrichten-teil-4/
       * http://jankarres.de/2012/08/raspberry-pi-vnc-server-installieren/
    '''
    print(blue('Install dependencies'))
    install_packages([
        'git',
        'build-essential',
        'rbp-userland-dev-osmc',
        'libvncserver-dev',
        'libconfig++-dev',
    ])

    print(
        blue('Build vnc server for raspberry pi using dispmanx '
             '(dispmanx_vnc)'))
    checkup_git_repo_legacy(
        url='https://github.com/patrikolausson/dispmanx_vnc.git')
    run('mkdir -p ~/repos')
    run('cd ~/repos/dispmanx_vnc  &&  make')

    print(blue('set up dispmanx_vnc as a service'))
    with warn_only():
        run('sudo systemctl  stop  dispmanx_vncserver.service')
    username = env.user
    builddir = flo('/home/{username}/repos/dispmanx_vnc')
    run(flo('sudo  cp  {builddir}/dispmanx_vncserver  /usr/bin'))
    run('sudo  chmod +x  /usr/bin/dispmanx_vncserver')
    fabfile_data_dir = FABFILE_DATA_DIR
    put('{fabfile_data_dir}/files/etc/dispmanx_vncserver.conf', '/tmp/')
    run('sudo mv  /tmp/dispmanx_vncserver.conf  /etc/dispmanx_vncserver.conf')
    put(
        '{fabfile_data_dir}/files/etc/systemd/system/dispmanx_vncserver.service',
        '/tmp/')
    run('sudo mv  /tmp/dispmanx_vncserver.service  '
        '/etc/systemd/system/dispmanx_vncserver.service')
    run('sudo systemctl start dispmanx_vncserver.service')
    run('sudo systemctl enable dispmanx_vncserver.service')
    run('sudo systemctl daemon-reload')
示例#13
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)')
示例#14
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)')
示例#15
0
def vnc_raspi_osmc():
    '''Install and configure dispmanx_vnc server on osmc (raspberry pi).

    More Infos:
     * https://github.com/patrikolausson/dispmanx_vnc
     * https://discourse.osmc.tv/t/howto-install-a-vnc-server-on-the-raspberry-pi/1517
     * tightvnc:
       * http://raspberry.tips/raspberrypi-einsteiger/raspberry-pi-einsteiger-guide-vnc-einrichten-teil-4/
       * http://jankarres.de/2012/08/raspberry-pi-vnc-server-installieren/
    '''
    print(blue('Install dependencies'))
    install_packages([
            'git',
            'build-essential',
            'rbp-userland-dev-osmc',
            'libvncserver-dev',
            'libconfig++-dev',
    ])

    print(blue('Build vnc server for raspberry pi using dispmanx '
               '(dispmanx_vnc)'))
    checkup_git_repo_legacy(
        url='https://github.com/patrikolausson/dispmanx_vnc.git')
    run('mkdir -p ~/repos')
    run('cd ~/repos/dispmanx_vnc  &&  make')

    print(blue('set up dispmanx_vnc as a service'))
    with warn_only():
        run('sudo systemctl  stop  dispmanx_vncserver.service')
    username = env.user
    builddir = flo('/home/{username}/repos/dispmanx_vnc')
    run(flo('sudo  cp  {builddir}/dispmanx_vncserver  /usr/bin'))
    run('sudo  chmod +x  /usr/bin/dispmanx_vncserver')
    fabfile_data_dir = FABFILE_DATA_DIR
    put('{fabfile_data_dir}/files/etc/dispmanx_vncserver.conf', '/tmp/')
    run('sudo mv  /tmp/dispmanx_vncserver.conf  /etc/dispmanx_vncserver.conf')
    put('{fabfile_data_dir}/files/etc/systemd/system/dispmanx_vncserver.service',
        '/tmp/')
    run('sudo mv  /tmp/dispmanx_vncserver.service  '
        '/etc/systemd/system/dispmanx_vncserver.service')
    run('sudo systemctl start dispmanx_vncserver.service')
    run('sudo systemctl enable dispmanx_vncserver.service')
    run('sudo systemctl daemon-reload')
示例#16
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')
示例#17
0
def regex_repl():
    '''Install RegexREPL, a helper tool for building regular expressions.

    More infos:
     * https://github.com/theno/RegexREPL
     * REPL: https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop

    Files created by this task:

        > tree ~
        ├── bin
        │   ├── find_regex_repl.pl -> ~/repos/RegexREPL/find_regex_repl.pl
        │   └── match_regex_repl.pl -> ~/repos/RegexREPL/match_regex_repl.pl
        └── repos
            └── RegexREPL
                ├── find_regex_repl.pl
                ├── match_regex_repl.pl
                └── README.md
    '''
    install_package('libterm-readline-gnu-perl')
    checkup_git_repo_legacy(url='https://github.com/theno/RegexREPL.git')
    for cmd in ['find_regex_repl.pl', 'match_regex_repl.pl']:
        run(flo('ln -snf  ~/repos/RegexREPL/{cmd} ~/bin/{cmd}'))
示例#18
0
def download(src_base, version, srcdir):
    checkup_git_repo_legacy('git://git.openssl.org/openssl.git',
                            base_dir=src_base)
    run(flo('cd {srcdir}  &&  git checkout {version}'))
    run(flo('cd {srcdir}  &&  git pull'))
示例#19
0
文件: tmux.py 项目: theno/fabsetup
def tmux_plugin_manager():
    checkup_git_repo_legacy(url='https://github.com/tmux-plugins/tpm',
                     name='tpm', base_dir='~/.tmux/plugins')
示例#20
0
def tmux_plugin_manager():
    checkup_git_repo_legacy(url='https://github.com/tmux-plugins/tpm',
                            name='tpm',
                            base_dir='~/.tmux/plugins')