def configure(config): configure_print('git') path_to_mpv_dir = Path(config['path_to_root'], 'home', config['user_name']) with create_file(Path(path_to_mpv_dir, '.gitconfig')) as f: print("""[user] name = Andrey Morozov email = [email protected] [core] editor = vim whitespace = -indent-with-non-tab,-space-before-tab,-trailing-space,-cr-at-eol autocrlf = true [alias] s = status d = diff c = commit l = log --graph --pretty=format:'%C(red)%h%C(yellow)%d%Creset %s %C(white) [%C(green)%an:%Creset %ar]' ll = log --graph --branches --decorate --stat --all --abbrev-commit lll = log --graph --branches --decorate --stat --all --abbrev-commit -p co = checkout b = branch -vv ba = branch -a -vv up = fetch --all --prune --recurse-submodules=yes -j4 --progress report = shortlog --all --branches --no-merges -n --since=7.days.ago uncommit = reset HEAD~ wd = show --stat -p # whatdiff [color] ui = true interactive = auto [color "branch"] current = yellow bold local = green bold remote = cyan bold [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold whitespace = white reverse [color "status"] added = green bold changed = yellow bold untracked = red bold [github] user = AoD314 [http] postBuffer = 536870912 [filter "tabspace"] smudge = unexpand --tabs=4 --first-only clean = expand --tabs=4 --initial """, file=f)
def configure(config): configure_print('locale') with create_file(Path(config['path_to_root'], 'etc/locale.gen')) as f: print(""" ru_RU.UTF-8 UTF-8 en_US.UTF-8 UTF-8 """, file=f) with create_file(Path(config['path_to_root'], 'etc/environment')) as f: print(""" LANG="en_US.UTF-8" """, file=f) with create_file(Path(config['path_to_root'], 'etc/conf.d/consolefont')) as f: print(""" consolefont="LatArCyrHeb-16" """, file=f) with create_file(Path(config['path_to_root'], 'etc/conf.d/keymaps')) as f: print(""" keymap="us" windowkeys="yes" extended_keymaps="" dumpkeys_charset="" fix_euro="no" """, file=f) with create_file(Path(config['path_to_root'], 'etc/conf.d/hwclock')) as f: print(""" clock="UTC" clock_args="" """, file=f) with create_file(Path(config['path_to_root'], 'etc/ntp.conf')) as f: print(""" # Common pool for random people #server pool.ntp.org server ntp1.stratum2.ru server ntp2.stratum2.ru server ntp3.stratum2.ru server ntp1.stratum1.ru server ntp2.stratum1.ru server ntp3.stratum1.ru # Pools for Gentoo users server 0.gentoo.pool.ntp.org server 1.gentoo.pool.ntp.org server 2.gentoo.pool.ntp.org server 3.gentoo.pool.ntp.org driftfile /var/lib/ntp/ntp.drift restrict default nomodify nopeer noquery limited kod restrict 127.0.0.1 restrict [::1] """, file=f)
def configure(config): configure_print('network') with create_file(Path(config['path_to_root'], 'etc/conf.d/net')) as f: print('config_eth0="dhcp"', file=f) print('hostname="neo"', file=f) with create_file(Path(config['path_to_root'], 'etc/resolv.conf')) as f: print('nameserver 8.8.8.8', file=f)
def configure(config): configure_print('sysctl.conf') with create_file(Path(config['path_to_root'], 'etc/sysctl.conf')) as f: print(""" net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.all.rp_filter = 1 vm.swappiness=0 """, file=f)
def configure(config): configure_print("profile") with create_file(Path(config["path_to_root"], "etc/profile")) as f: print( """ export HISTSIZE=8192 export HISTFILESIZE=$HISTSIZE export HISTIGNORE="&:ls:[bf]g:exit:l:ll:cd ..:m:n:pwd:[ \t]*" export HISTCONTROL=ignorespace:erasedups export EIX_LIMIT_COMPACT=0 export EIX_LIMIT=0 """, file=f, )
def configure(config): configure_print('mpv') path_to_mpv_dir = Path(config['path_to_root'], 'home', config['user_name'], '.config', 'mpv') with create_file(Path(path_to_mpv_dir, 'config')) as f: print("""############################################################## # https://github.com/mpv-player/mpv/blob/master/DOCS/man/en/ # ############################################################## ad-lavc-threads=2 vd-lavc-threads=8 cache=262144 # 256 mb cache-default=262144 # 256 mb reset-on-next-file="" volume=50 sub-ass=no osd-duration=3000 osd-font="Liberation Mono" osd-font-size=12 osd-level=3 # volume + seek + timer + percentage + total time osd-color=1.0/1.0/1.0 osd-back-color=0.0/0.0/0.0/0.25 osd-border-size=0 sub-text-blur=0 hwdec=auto slang="ru" alang="ru" vo=opengl-hq screenshot-jpeg-quality=100 screenshot-png-compression=9 """, file=f) with create_file(Path(path_to_mpv_dir, 'input.conf')) as f: print(""" F1 show_text "${filename}(${video-format}) [${width}x${height}@${fps} ${file-size}]" F3 show_text "${estimated-frame-number} / ${estimated-frame-count}" F3 show_text "video bitrate: ${video-bitrate}" F4 show_text "cache total/used/free: ${cache-size} / ${cache-used} / ${cache-free} - ${cache}%" """, file=f)
def configure(config): configure_print('sublime') with create_file(Path(config['path_to_root'], 'home', config['user_name'],'.config/sublime-text-2/Packages/User/Preferences.sublime-settings')) as f: print("""{ "color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme", "font_face": "Hack", "font_size": 10, "translate_tabs_to_spaces": true, "tab_size": 4, "auto_complete_delay": 10, "rulers": [80, 120, 160], "highlight_modified_tabs": true, "draw_white_space": "all" } """, file=f)
def configure(configuration): configure_print('make.conf') path_to_root = configuration['path_to_root'] print('see ' + str(Path(path_to_root, 'usr/share/portage/config/make.conf.example')) + ' for examples') with create_file(Path(path_to_root, 'etc/portage/make.conf')) as f: sse = get_sse_support() py = get_python_support() cmd = sse + '\n\n' + '\n\n' + py + """ ACCEPT_LICENSE="*" CFLAGS="-O2 -pipe -march=native" CXXFLAGS="${CFLAGS}" VIDEO_CARDS="nvidia" INPUT_DEVICES="keyboard mouse" # virtualbox CHOST="x86_64-pc-linux-gnu" USE="nls theora gmp posix usb png threads \ policykit consolekit utf8 \ ipv6 lm_sensors -introspection" USE="${USE} qt4 qt5 -gtk -gtk3 -wayland egl gles opengl " USE="${USE} ffmpeg -libav -vlc " USE="${USE} ogg xvid x264 webm vdpau flac " USE="${USE} udev -systemd -eudev " USE="${USE} -java -ruby " USE="${USE} -sqlite -mysql " USE="${USE} -pam -semantic-desktop " USE="${USE} -pulseaudio alsa " ALSA_CARDS="ca0106 hda-intel" CHOST="x86_64-pc-linux-gnu" PORTDIR="/usr/portage" DISTDIR="${PORTDIR}/distfiles" PKGDIR="${PORTDIR}/packages" MAKEOPTS="-j{0}" EMERGE_DEFAULT_OPTS="--jobs=2 --keep-going=y " PORTAGE_TMPDIR=/tmp PORTDIR_OVERLAY="/usr/local/portage" source /var/lib/layman/make.conf """.format(multiprocessing.cpu_count() + 1) print(cmd, file=f)
def configure(config): configure_print('bash') user_name = config['user_name'] path_to_home = Path(config['path_to_root'], 'home', user_name) with create_file(Path(path_to_home, '.bashrc')) as f: print(""" PS1='\[\e[1;32m\]\u \[\e[0;31m\] [\[\e[1;34m\]\w \[\e[1;32m\]$(__git_ps1 "(%s)")\[\e[0;31m\]] \[\e[1;37m\]{\t}\n\$ ' shopt -s histappend PROMPT_COMMAND='history -a' shopt -s cdspell shopt -s dirspell #export ANDROID_NDK=/opt/android-ndk/ #export ANDROID_STANDALONE_TOOLCHAIN=/opt/android-ndk/toolchains/ #LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib64 PATH=$PATH:/opt/sublime-text2/ alias gr="grep -niIHR" alias htop="htop -d 2" alias l="ls -lh" alias lS="ls -lSh" alias ll="ls -lah" alias bigs="ls -Shal | head -n 25" alias news="ls -lsaht | head -n 25" alias hotm="ps -A -o rssize:10,time:9,%cpu:5,cmd | sort -nr | head | awk '{ printf \"%7.1f M --- %s\n\", \$1/1024, \$4}{};'" alias hotc="ps -A -o rssize:10,time:9,%cpu:5,cmd --sort -%cpu | head -n 13 | awk '{ printf \"%6.1f%% --- %s\n\", \$3, \$4}{};' | tail -n 12" alias m="make -j5" alias n="ninja" alias sl="sublime_text" alias hddfree="du -h --max-depth=1 | sort -h" source ~/.git-completion.bash bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward' """.format(user_name, str(256 * 1024 * 1024), str(multiprocessing.cpu_count() + 1)), file=f)
def configure(config): configure_print('X') path_to_home = Path(config['path_to_root'], 'home', config['user_name']) with create_file(Path(path_to_home, '.xinitrc')) as f: print("exec startkde", file=f) with create_file(Path(config['path_to_root'], 'etc/conf.d/xdm')) as f: print("""# We always try and start X on a static VT. The various DMs normally default # to using VT7. If you wish to use the xdm init script, then you should ensure # that the VT checked is the same VT your DM wants to use. We do this check to # ensure that you haven't accidentally configured something to run on the VT # in your /etc/inittab file so that you don't get a dead keyboard. CHECKVT=7 # What display manager do you use ? [ xdm | gdm | kdm | gpe | entrance ] # NOTE: If this is set in /etc/rc.conf, that setting will override this one. DISPLAYMANAGER="kdm" """, file=f)
def configure(config): configure_print('sublime') with create_file(Path(config['path_to_root'], 'home', config['user_name'] ,'.config/qxkb.cfgs')) as f: print(""" [Style] path=/usr/share/qxkb/theme/default [KeyLayout] model=pc104 layout="us,ru" variant=" ," status=2 showflag=true showsingle=false switching=0 useConvert=false shotcutConvert= option=grp:caps_toggle """, file=f)
def configure(config): configure_print('sysctl.conf') with create_file(Path(config['path_to_root'], 'etc/sysctl.conf')) as f: print(""" net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.all.rp_filter = 1 vm.dirty_bytes = 67108864 vm.dirty_background_bytes = 50331648 # Устанавливаем в 256 Кб размер буферов по умолчанию для приема и отправки данных через сокеты net.core.rmem_default = 262144 net.core.wmem_default = 262144 # Устанавливаем в 16Мб максимальный размер буфера сокетов. net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 # максимальное кол-во соединений net.ipv4.tcp_max_orphans = 65536 net.ipv4.tcp_mem=65536 131072 262144 net.ipv4.tcp_rmem=4096 87380 16777216 net.ipv4.tcp_wmem=4096 65536 16777216 net.ipv4.tcp_sack = 1 net.ipv4.tcp_no_metrics_save = 1 net.ipv4.tcp_fin_timeout = 10 # Максимальный размер очереди net.core.netdev_max_backlog = 2048 vm.swappiness=0 """, file=f)
def configure(config): configure_print('bash') user_name = config['user_name'] path_to_home = Path(config['path_to_root'], 'home', user_name) with create_file(Path(path_to_home, '.bashrc')) as f: print(""" PS1='\[\e[1;32m\]\u \[\e[0;31m\] [\[\e[1;34m\]\w \[\e[1;32m\]$(__git_ps1 "(%s)")\[\e[0;31m\]] \[\e[1;37m\]{\t}\n\$ ' function extract { if [ -z "$1" ]; then # display usage if no parameters given echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>" else if [ -f "$1" ] ; then NAME=${1%.*} #mkdir $NAME && cd $NAME case "$1" in *.tar.bz2) tar xvjf ./"$1" ;; *.tar.gz) tar xvzf ./"$1" ;; *.tar.xz) tar xvJf ./"$1" ;; *.lzma) unlzma ./"$1" ;; *.bz2) bunzip2 ./"$1" ;; *.rar) unrar x -ad ./"$1" ;; *.gz) gunzip ./"$1" ;; *.tar) tar xvf ./"$1" ;; *.tbz2) tar xvjf ./"$1" ;; *.tgz) tar xvzf ./"$1" ;; *.zip) unzip ./"$1" ;; *.Z) uncompress ./"$1" ;; *.7z) 7z x ./"$1" ;; *.xz) unxz ./"$1" ;; *.exe) cabextract ./"$1" ;; *) echo "extract: '$1' - unknown archive method" ;; esac else echo "'$1' - file does not exist" fi fi } shopt -s histappend PROMPT_COMMAND='history -a' shopt -s cdspell shopt -s dirspell #export ANDROID_NDK=/opt/android-ndk/ #export ANDROID_STANDALONE_TOOLCHAIN=/opt/android-ndk/toolchains/ #LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib64 PATH=$PATH:/opt/sublime-text2/ alias gr="grep -niIHR" alias htop="htop -d 2" alias l="ls -lh" alias lS="ls -lSh" alias ll="ls -lah" alias bigs="ls -Shal | head -n 25" alias news="ls -lsaht | head -n 25" alias hotm="ps -A -o rssize:10,time:9,%cpu:5,cmd | sort -nr | head | awk '{ printf \"%7.1f M --- %s\n\", \$1/1024, \$4}{};'" alias hotc="ps -A -o rssize:10,time:9,%cpu:5,cmd --sort -%cpu | head -n 13 | awk '{ printf \"%6.1f%% --- %s\n\", \$3, \$4}{};' | tail -n 12" alias m="make -j9" alias n="ninja" alias sl="sublime_text" alias hddfree="du -h --max-depth=1 | sort -h" source ~/.git-completion.bash bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward' """.format(user_name, str(256 * 1024 * 1024), str(multiprocessing.cpu_count() + 1)), file=f)
def configure(config): configure_print('vim') path_to_root = config['path_to_root'] user_name = config['user_name'] with create_file(Path(path_to_root, 'home', user_name, '.vimrc')) as f: print("""set nu set encoding=utf-8 set background=dark colorscheme pablo set completeopt=longest,menuone nnoremap * *N set tabstop=4 set softtabstop=4 set shiftwidth=4 set smarttab set expandtab set pastetoggle=<F2> set clipboard=unnamed map <c-j> <c-w>j map <c-k> <c-w>k map <c-l> <c-w>l map <c-h> <c-w>h vnoremap < <gv vnoremap > >gv set hlsearch set incsearch set ignorecase set smartcase set nobackup set nowritebackup set noswapfile set smartcase set incsearch set autowrite set hidden set laststatus=2 set statusline=%<%F%h%m%r%h%w%y\ %{&ff}\ %{strftime(\"%c\")}%=\ line:%l\/%L\ col:%c%V\ pos:%o\ ascii:%b\ %P set hlsearch if has("gui_running") if has("gui_gtk2") set guifont=Droid\ Sans\ Mono\ 11 elseif has("gui_win32") set guifont=Consolas:h11:cANSI endif set lines=9999 set columns=999 set guioptions-=m set guioptions-=T endif set history=25000 set showcmd set nocompatible syntax on set showmatch set ignorecase set showmode set ts=4 set sw=4 imap <c-space> <c-x><c-o> set backspace=2 filetype plugin on filetype indent on iab utf! # -*- coding: UTF-8 -*- iab python! #!/usr/bin/env python nmap <C-N> :noh <CR> set incsearch set hlsearch set nocompatible filetype on filetype plugin on filetype indent on set ofu=syntaxcomplete#Complete nnoremap <silent> <F8> :TlistToggle<CR> set showtabline=1 nmap <S-Left> :tabprevious<CR> imap <S-Left> :tabprevious<CR> map <S-Left> :tabprevious<CR> nmap <S-Right> :tabnext<CR> imap <S-Right> :tabnext<CR> map <S-Right> :tabnext<CR> nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR> nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . tabpagenr()<CR> nmap <F3> :tab sp . <CR> imap <F3> :tab sp . <CR> map <F3> :tab sp . <CR> set fo-=ro set foldenable set foldlevel=25 set foldmethod=indent set foldnestmax=2 nnoremap <space> za vnoremap <space> zf set t_Co=256 set udf set nobackup set nowritebackup set noswapfile """, file=f)