From 09ccfe26fd230ce7ea1df0f52335b4a0601fdc90 Mon Sep 17 00:00:00 2001 From: sneak Date: Sat, 11 Apr 2020 11:55:50 -0700 Subject: [PATCH] testing --- .drone.yml | 10 +- Dockerfile | 1 + bin/start | 4 - root/etc/service/runtime-setup-user/run | 13 ++ root/home/template/.toprc | 16 ++ root/home/template/.vimrc | 198 ++++++++++++++++++++++++ root/root/.toprc | 16 ++ setup/packages.txt | 1 - setup/run.sh | 24 +++ setup/runuser.sh | 26 ++++ 10 files changed, 301 insertions(+), 8 deletions(-) create mode 100644 root/etc/service/runtime-setup-user/run create mode 100644 root/home/template/.toprc create mode 100644 root/home/template/.vimrc create mode 100644 root/root/.toprc create mode 100644 setup/runuser.sh diff --git a/.drone.yml b/.drone.yml index 33e8247..2edcc7a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,8 +8,12 @@ steps: - UBUNTU_MIRROR=http://de.archive.ubuntu.com/ubuntu settings: repo: sneak/work - dry_run: true - #auto_tag: true + #dry_run: true + username: + from_secret: docker_username + password: + from_secret: docker_password tags: + - ${DRONE_BRANCH//\//-}-${DRONE_COMMIT_SHA:0:8} - ${DRONE_COMMIT_SHA} - - ${DRONE_BRANCH} + - ${DRONE_BRANCH/\//-} diff --git a/Dockerfile b/Dockerfile index 7390394..e348c57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ RUN \ groupadd -g $GID_TO_ADD $USERNAME_TO_ADD && \ useradd -u $UID_TO_ADD -g $GID_TO_ADD -s /bin/bash $USERNAME_TO_ADD && \ usermod -p '*' $USERNAME_TO_ADD && \ + echo $USERNAME_TO_ADD > /etc/workuser && \ go get -v -u github.com/peterbourgon/runsvinit && \ cp /root/go/bin/runsvinit /usr/local/sbin/runsvinit && \ rm -rf /root/go && \ diff --git a/bin/start b/bin/start index d21af5d..78e8c1d 100755 --- a/bin/start +++ b/bin/start @@ -10,9 +10,5 @@ docker run \ -d \ --name work \ -v /:/hostroot \ - -v /home/sneak/.ssh/id_rsa:/home/sneak/.ssh/id_rsa \ - -v /home/sneak/.ssh/config:/home/sneak/.ssh/config \ - -v /home/sneak/.ssh/known_hosts:/home/sneak/.ssh/known_hosts \ - -v /home/sneak/Documents:/home/sneak/Documents \ -v /var/run/docker.sock:/var/run/docker.sock \ sneak/work diff --git a/root/etc/service/runtime-setup-user/run b/root/etc/service/runtime-setup-user/run new file mode 100644 index 0000000..31ddd05 --- /dev/null +++ b/root/etc/service/runtime-setup-user/run @@ -0,0 +1,13 @@ +#!/bin/bash + +UN="$(cat /etc/workuser)" +HD="/home/$UN" + +if [[ -e "$HD/.setupdone" ]]; then + sleep 86400; + exit +fi + +sudo -l -u $UN /bin/bash << EOF + echo "user setup done" > ~/.setupdone +EOF diff --git a/root/home/template/.toprc b/root/home/template/.toprc new file mode 100644 index 0000000..31522b4 --- /dev/null +++ b/root/home/template/.toprc @@ -0,0 +1,16 @@ +top's Config File (Linux processes with windows) +Id:i, Mode_altscr=0, Mode_irixps=1, Delay_time=1.0, Curwin=0 +Def fieldscur=ķ&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij + winflags=162740, sortindx=18, maxtasks=0, graph_cpus=2, graph_mems=0 + summclr=1, msgsclr=1, headclr=3, taskclr=1 +Job fieldscur=(Ļ@<)*+,-./012568>?ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij + winflags=195508, sortindx=0, maxtasks=0, graph_cpus=2, graph_mems=0 + summclr=6, msgsclr=6, headclr=7, taskclr=6 +Mem fieldscur=?@ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij + winflags=195380, sortindx=3, maxtasks=0, graph_cpus=2, graph_mems=0 + summclr=3, msgsclr=3, headclr=2, taskclr=3 +Fixed_widest=0, Summ_mscale=0, Task_mscale=0, Zero_suppress=0 + diff --git a/root/home/template/.vimrc b/root/home/template/.vimrc new file mode 100644 index 0000000..c4ad235 --- /dev/null +++ b/root/home/template/.vimrc @@ -0,0 +1,198 @@ +"execute pathogen#infect() + +silent !mkdir -p ~/.vim/backup > /dev/null 2>&1 +silent !mkdir -p ~/.vim/undo > /dev/null 2>&1 +silent !mkdir -p ~/.vim/swap > /dev/null 2>&1 +silent !mkdir -p ~/.vim/autoload > /dev/null 2>&1 +silent !mkdir -p ~/.vim/plugged > /dev/null 2>&1 + +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.paths/sneak-sync/dotfiles/vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +source ~/.vim/autoload/plug.vim + +call plug#begin('~/.vim/plugged') + +Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } +" Plug 'roxma/vim-hug-neovim-rpc' +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +"Plug 'edkolev/tmuxline.vim' +Plug 'zchee/deoplete-go', { 'for': 'go' } +Plug 'zchee/deoplete-jedi', { 'for': 'python' } + +Plug 'vim-syntastic/syntastic' + +set statusline+=%#warningmsg# +set statusline+=%{SyntasticStatuslineFlag()} +set statusline+=%* +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_auto_loc_list = 1 +let g:syntastic_check_on_open = 1 +let g:syntastic_check_on_wq = 0 +let g:syntastic_go_checkers = ['gofmt'] +let g:syntastic_enable_signs = 1 +highlight SyntasticErrorSign guifg=white guibg=red + +Plug 'scrooloose/nerdtree' +"Plug 'ludovicchabant/vim-gutentags' + +let g:gutentags_ctags_tagfile = '.tags' +let g:gutentags_file_list_command = 'git ls-files' +let g:gutentags_generate_on_new = 1 + +"Plug 'majutsushi/tagbar' +Plug 'fatih/vim-go', { 'do': 'GoUpdateBinaries', 'for': 'go' } +Plug 'cespare/vim-toml', { 'for': 'toml' } +let g:deoplete#enable_at_startup = 1 +call plug#end() + +let g:airline_powerline_fonts = 1 + +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif + +" unicode symbols +" let g:airline_left_sep = '▶' +" let g:airline_right_sep = '◀' + let g:airline_symbols.crypt = '🔒' + let g:airline_symbols.linenr = '☰' +" let g:airline_symbols.linenr = '␊' +" let g:airline_symbols.linenr = '␤' +" let g:airline_symbols.linenr = '¶' +" let g:airline_symbols.maxlinenr = '' +" let g:airline_symbols.maxlinenr = '㏑' +" let g:airline_symbols.branch = '⎇' +" let g:airline_symbols.paste = 'ρ' +" let g:airline_symbols.paste = 'Þ' +" let g:airline_symbols.paste = '∥' +" let g:airline_symbols.spell = 'Ꞩ' +" let g:airline_symbols.notexists = 'Ɇ' +" let g:airline_symbols.whitespace = 'Ξ' + +fun! InitBex() + let myvar = strftime("%y%m%d.%Hh%M") + let myvar = "set backupext=.". myvar + execute myvar +endfun +map :call InitBex() +silent call InitBex() + +set relativenumber +filetype plugin indent on +syntax on + +set modelines=10 +noremap "" +noremap! +noremap "" +noremap! +noremap "" +noremap! +noremap "" +noremap! +vnoremap > >gv +vnoremap < <gv + +"au BufWinLeave * silent! mkview +"au BufWinEnter * silent! loadview + +au BufRead,BufNewFile *.go set filetype=go +"au BufRead,BufNewFile *.coffee set filetype=coffee + +let mapleader="," + +set ignorecase +set smartcase +set gdefault +set incsearch +set showmatch +set hlsearch +nnoremap :noh + +set ignorecase +set smartcase +set gdefault +set incsearch +set showmatch +set hlsearch +set autoindent +"set signcolumn=yes +set backspace=indent,eol,start +set backup +set backupdir=~/.vim/backup// +set cmdheight=3 +"set clipboard=unnamed +set directory=~/.vim/swap// +set encoding=utf-8 +set expandtab +set fileencodings=utf-8,iso-8859-15 +set guifont=Monaco:h16 +set hidden +set ignorecase +set laststatus=2 +set modeline +set nobomb +set nocompatible +set shiftwidth=4 +set showcmd +set smartcase +set smarttab +set softtabstop=4 +set spellfile=~/.vim/spellfile.utf-8.add +set spelllang=en +set tabstop=4 +set termencoding=utf-8 +set ttyfast +set tw=76 +set undodir=~/.vim/undo// +set undofile +set wildignore+=*.pyc +set writebackup + +setglobal fileencoding=utf-8 + +autocmd FileType make setlocal noexpandtab +autocmd FileType markdown setlocal spell +au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown +autocmd BufNewFile,BufRead *.json set ft=javascript + +"inoremap jj + +map N Nzz +map n nzz +"map +colorscheme koehler +hi CursorLine term=none cterm=none ctermbg=none +set t_Co=256 +set foldmethod=indent +set foldminlines=5 +set nofoldenable "dont fold by default +set foldlevel=1 "this is just what i use + +"nnoremap @=(foldlevel('.')?'za':'l') +"vnoremap zf + +"nnoremap :bn +"nnoremap :bp +"nnoremap :ls + +highlight ExtraWhitespace ctermbg=red guibg=red +match ExtraWhitespace /\s\+$/ +autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ +autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@?ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij + winflags=162740, sortindx=18, maxtasks=0, graph_cpus=2, graph_mems=0 + summclr=1, msgsclr=1, headclr=3, taskclr=1 +Job fieldscur=(Ļ@<)*+,-./012568>?ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij + winflags=195508, sortindx=0, maxtasks=0, graph_cpus=2, graph_mems=0 + summclr=6, msgsclr=6, headclr=7, taskclr=6 +Mem fieldscur=?@ABCFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij + winflags=195380, sortindx=3, maxtasks=0, graph_cpus=2, graph_mems=0 + summclr=3, msgsclr=3, headclr=2, taskclr=3 +Fixed_widest=0, Summ_mscale=0, Task_mscale=0, Zero_suppress=0 + diff --git a/setup/packages.txt b/setup/packages.txt index a8445d2..9d5a112 100644 --- a/setup/packages.txt +++ b/setup/packages.txt @@ -1,4 +1,3 @@ - apt-transport-https apt-utils aspell diff --git a/setup/run.sh b/setup/run.sh index 888ce04..7bbe2da 100644 --- a/setup/run.sh +++ b/setup/run.sh @@ -5,3 +5,27 @@ TD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)" cd "$TD" apt install -y $(cat packages.txt) + +SSH_HOST_KEY_FILES=" + ssh_host_ecdsa_key + ssh_host_ecdsa_key.pub + ssh_host_ed25519_key + ssh_host_ed25519_key.pub + ssh_host_rsa_key + ssh_host_rsa_key.pub +" + +for FN in $SSH_HOST_KEY_FILES ; do + ln -s /hostroot/etc/ssh/$FN /etc/ssh/$FN +done + +# install other stuff here + +# update pip +# install black +# install python packages +# install yarn +# install prettier +# install vim-go + +sudo -u $USERNAME_TO_ADD bash ./runuser.sh diff --git a/setup/runuser.sh b/setup/runuser.sh new file mode 100644 index 0000000..0e9729d --- /dev/null +++ b/setup/runuser.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +TD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)" + +# original home +OH="/hostroot/home/$USER_TO_ADD" + +# container home +export HOME="/home/$USER_TO_ADD" + +rsync -avP /home/template/ $HOME/ + +# link ~/.home to original home +ln -s "/hostroot/home/$USER_TO_ADD" $HOME/.home + +# oh-my-zsh +curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh > /tmp/installomz.sh +export ZSH="$HOME/.zsh" +bash /tmp/installomz.sh --unattended --keep-zshrc + +# link in ssh key from original home +ln -s ~/.home/.ssh/id_rsa ~/.ssh/id_rsa +ln -s ~/.home/.ssh/id_rsa.pub ~/.ssh/id_rsa.pub + +# move this to runtime +#DEVDIR="$( cd ~/.home/dev >/dev/null 2>&1 && pwd -P)"