def powerline_for_bash(bindings_dir): bash_snippet = '~/.bashrc_powerline_bash' install_file_legacy(path=bash_snippet, bindings_dir=bindings_dir) 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, comment='#')
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')
def server_prepare_root_bin_dir(): '''Install custom commands for user root at '/root/bin/'.''' commands = ['run_backup'] for command in commands: install_file_legacy(flo('/root/bin/{command}'), sudo=True) sudo(flo('chmod 755 /root/bin/{command}')) if command == 'run_backup': sudo('ln -snf /root/bin/run_backup /etc/cron.daily/run_backup')
def set_up_powerline_daemon(scripts_dir): bash_snippet = '~/.bashrc_powerline_daemon' install_file_legacy(path=bash_snippet, scripts_dir=scripts_dir) prefix = flo('if [ -f {bash_snippet} ]; ') enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi') update_or_append_line(filename='~/.bashrc', prefix=prefix, new_line=enabler)
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'))
def powerline_for_bash(bindings_dir): bash_snippet = '~/.bashrc_powerline_bash' install_file_legacy(path=bash_snippet, bindings_dir=bindings_dir) 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, comment='#')
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')
def tmux(): '''Customize tmux for solarized colors and other things. Tweaks for: * enable 256 colors * correct highlighting within man pages, cf. http://stackoverflow.com/a/10563271 ''' install_file_legacy('~/.tmux.conf') set_up_terminfo() tmux_plugin_manager()
def tmux(): '''Customize tmux for solarized colors and other things. Tweaks for: * enable 256 colors * correct highlighting within man pages, cf. http://stackoverflow.com/a/10563271 ''' install_file_legacy('~/.tmux.conf') set_up_terminfo() tmux_plugin_manager()
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"'))
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)
def enable_nvm(): '''add to ~/.bashrc: Export of $NVM env variable and load nvm command.''' bash_snippet = '~/.bashrc_nvm' install_file_legacy(path=bash_snippet) prefix = flo('if [ -f {bash_snippet} ]; ') enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi') if env.host == 'localhost': uncomment_or_update_or_append_line(filename='~/.bashrc', prefix=prefix, new_line=enabler) else: print(cyan('\nappend to ~/.bashrc:\n\n ') + enabler)
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"'))
def create_files( # '/home/theno/.fabsetup-addon-repos/fabsetup-theno-termdown' addon_dir, username, # 'theno' addonname, # 'termdown' taskname, # 'termdown' author, author_email, headline='', description='', touched_files=''): filenames = [ '.gitignore', 'fabfile-dev.py', 'fabfile.py', 'LICENSE', 'MANIFEST.in', 'README.md', 'requirements.txt', 'setup.py', 'fabsetup_USER_TASK/fabutils.py', 'fabsetup_USER_TASK/__init__.py', 'fabsetup_USER_TASK/_version.py', ] for filename in filenames: install_file_legacy( path=flo('~/.fabsetup-addon-repos/fabsetup-USER-ADDON/{filename}'), username=username, addonname=addonname, taskname=taskname, headline=headline, description=description, touched_files=touched_files, author=author, author_email=author_email, USER=username, ADDON=addonname, TASK=taskname, ) # avoid substitution of USERNAME in path install_file_legacy( path='~/.fabsetup-addon-repos/fabsetup-{USER}-{ADDON}/' 'fabsetup_{USER}_{TASK}/files/home/USERNAME/bin/' 'termdown.template'.format(USER=username, ADDON=addonname, TASK=taskname), from_path='~/.fabsetup-addon-repos/fabsetup-USER-ADDON/' 'fabsetup_USER_TASK/files/home/USERNAME/bin/' 'termdown.template') print('') fabric.operations.local(flo('tree {addon_dir}'))
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)
def enable_nvm(): '''add to ~/.bashrc: Export of $NVM env variable and load nvm command.''' bash_snippet = '~/.bashrc_nvm' install_file_legacy(path=bash_snippet) prefix = flo('if [ -f {bash_snippet} ]; ') enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi') if env.host == 'localhost': uncomment_or_update_or_append_line(filename='~/.bashrc', prefix=prefix, new_line=enabler) else: print(cyan('\nappend to ~/.bashrc:\n\n ') + enabler)
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)
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')
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)
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)
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)
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')
def pyenv(): '''Install or update the pyenv python environment. Checkout or update the pyenv repo at ~/.pyenv and enable the pyenv. Pyenv wird also als Github-Repo "installiert" unter ~/.pyenv More info: * https://github.com/yyuu/pyenv * https://github.com/yyuu/pyenv/wiki/Common-build-problems#requirements Tutorial: * http://amaral-lab.org/resources/guides/pyenv-tutorial ''' install_packages([ 'make', 'build-essential', 'libssl-dev', 'zlib1g-dev', 'libbz2-dev', 'libreadline-dev', 'libsqlite3-dev', 'wget', 'curl', 'llvm', 'libncurses5-dev', 'libncursesw5-dev', ]) if exists('~/.pyenv'): run('cd ~/.pyenv && git pull') run('~/.pyenv/bin/pyenv update') else: run('curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/' 'master/bin/pyenv-installer | bash') # add pyenv to $PATH and set up pyenv init bash_snippet = '~/.bashrc_pyenv' install_file_legacy(path=bash_snippet) prefix = flo('if [ -f {bash_snippet} ]; ') enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi') if env.host == 'localhost': # FIXME: next function currently only works for localhost uncomment_or_update_or_append_line(filename='~/.bashrc', prefix=prefix, new_line=enabler) else: print(cyan('\nappend to ~/.bashrc:\n\n ') + enabler)
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')
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')
def set_up_powerline_daemon(scripts_dir): bash_snippet = '~/.bashrc_powerline_daemon' install_file_legacy(path=bash_snippet, scripts_dir=scripts_dir) prefix = flo('if [ -f {bash_snippet} ]; ') enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi') update_or_append_line(filename='~/.bashrc', prefix=prefix, new_line=enabler)
def set_up_gunicorn(site_dir, sitename): install_file_legacy('~/sites/SITENAME/scripts/tracwsgi.py', SITENAME=sitename, site_dir=site_dir)
def install_gunicorn_upstart_script(sitename, username, site_dir): socket = flo('unix://{site_dir}/run/trac.sock') num_workers = 2 install_file_legacy('/etc/init/gunicorn-SITENAME.conf', sudo=True, SITENAME=sitename, site_dir=site_dir, username=username, socket=socket, num_workers=num_workers)
def vimrc_customizations(): install_file_legacy('~/.vimrc.before') install_file_legacy('~/.vimrc.after') install_file_legacy('~/.gvimrc.before') install_file_legacy('~/.gvimrc.after')
def install_spout_fulltextrssGoogleBot(sitename): install_file_legacy('~/sites/SITENAME/selfoss/spouts/rss/fulltextrssGoogleBot.php', SITENAME=sitename)
def vimrc_customizations(): install_file_legacy('~/.vimrc.before') install_file_legacy('~/.vimrc.after') install_file_legacy('~/.gvimrc.before') install_file_legacy('~/.gvimrc.after')