From 2c05e0747a1cbc38da50757ed534b63248437484 Mon Sep 17 00:00:00 2001 From: "J. Elfring" Date: Sat, 27 Jan 2024 14:45:49 +0100 Subject: [PATCH] first commit --- .gitignore | 1 + Dockerfile | 31 ++++++ README.md | 3 + assets/profile.d/aliases.sh | 38 +++++++ assets/profile.d/color-prompt.sh | 11 ++ assets/profile.d/functions.sh | 65 +++++++++++ assets/vimrc | 183 +++++++++++++++++++++++++++++++ docker-compose.yaml | 18 +++ 8 files changed, 350 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 assets/profile.d/aliases.sh create mode 100644 assets/profile.d/color-prompt.sh create mode 100644 assets/profile.d/functions.sh create mode 100755 assets/vimrc create mode 100644 docker-compose.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e1e6034 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM alpine:edge +LABEL maintainer "J. Elfring " + +RUN apk add --update --no-cache \ + bash \ + bind-tools \ + busybox-extras \ + ca-certificates \ + curl \ + git \ + helm \ + jq \ + kubectl \ + mysql-client \ + netcat-openbsd \ + openssh-client \ + openssl \ + postgresql-client \ + rsync \ + socat \ + sqlite \ + vim \ + w3m \ + wget + +ADD assets/profile.d/* /etc/profile.d/ +COPY assets/vimrc /etc/vim/vimrc + +WORKDIR /root + +CMD /bin/bash -li diff --git a/README.md b/README.md new file mode 100644 index 0000000..4b24dac --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Alpine linux docker-toolbox + +A docker image with some tools and clients. diff --git a/assets/profile.d/aliases.sh b/assets/profile.d/aliases.sh new file mode 100644 index 0000000..a89620e --- /dev/null +++ b/assets/profile.d/aliases.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Easier navigation: .., ..., ...., ....., ~ and - +alias ..="cd .." +alias ...="cd ../.." +alias ....="cd ../../.." +alias .....="cd ../../../.." +alias ~="cd ~" # `cd` is probably faster to type though +alias -- -="cd -" + +# Shortcuts +alias g="git" +alias h="history" +alias k="kubectl" + +# Always use color output for `ls` +# And sort directories before files +alias ls="ls --color --group-directories-first" + +# ls abbreviation +alias l="ls -l" +alias ll="ls -l" +alias la="ls -la" + +# Always enable colored `grep` output +alias grep='grep --color=auto ' + +# Enable aliases to be sudo’ed +alias sudo='sudo ' + +# Canonical hex dump some systems have this symlinked +command -v hd > /dev/null || alias hd="hexdump -C" + +# vi == vim +alias vi='vim' + +# Passwort erstellen +alias mkpasswd='openssl rand -base64 40 | cut -c1-40' diff --git a/assets/profile.d/color-prompt.sh b/assets/profile.d/color-prompt.sh new file mode 100644 index 0000000..26b416d --- /dev/null +++ b/assets/profile.d/color-prompt.sh @@ -0,0 +1,11 @@ +# Setup a red prompt for root and a green one for users. +# rename this file to color_prompt.sh to actually enable it +NORMAL="\[\e[0m\]" +RED="\[\e[1;31m\]" +GREEN="\[\e[1;32m\]" +if [ "$USER" = root ]; then + PS1="$RED\h [$NORMAL\w$RED]# $NORMAL" +else + PS1="$GREEN\h [$NORMAL\w$GREEN]\$ $NORMAL" +fi + diff --git a/assets/profile.d/functions.sh b/assets/profile.d/functions.sh new file mode 100644 index 0000000..5dea850 --- /dev/null +++ b/assets/profile.d/functions.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Trap RC != 0 and display +EC() { + echo -e '\e[1;31m'code $?'\e[m\n' +} +trap EC ERR + +# Create a new directory and enter it +mkd() { + mkdir -p "$@" && cd "$@" +} + +# Make a temporary directory and enter it +tmpd() { + if [ $# -eq 0 ]; then + dir=`mktemp -d` && cd $dir + else + dir=`mktemp -d -t $1.XXXXXXXXXX` && cd $dir + fi +} + +# Run `dig` and display the most useful info +digga() { + dig +nocmd "$1" any +multiline +noall +answer +} + +## Dump SSL Cert from host +## sslcheck example.com:25 -starttls smtp +## sslcheck example.com:443 +sslcheck(){ + echo -n | openssl s_client -connect $* | tee /dev/tty | openssl x509 -text -noout +} + +## SSH agent +## Add sth like test -z $noKeychain && agent to ~/.extra +function agent(){ + /usr/bin/keychain --nolock --nogui $HOME/.ssh/id_rsa + source $HOME/.keychain/$HOSTNAME-sh +} + + + +## Kubernetes Goodies +k(){ + kubectl $* +} + +k-sel(){ + kubeconfig=$(find ~/.kube/kubesel -type f | rev | cut -d "/" -f 1 | rev | sort | fzf --height=25%) + export KUBECONFIG=~/.kube/kubesel/$kubeconfig + echo + kubectl config get-contexts +} + +k-ns(){ + kubectl config set-context + --current \ + --namespace=$(kubectl get namespace | grep Active \ + | cut -d " " -f1 \ + | fzf --height=25% + ) + echo + kubectl config get-contexts +} diff --git a/assets/vimrc b/assets/vimrc new file mode 100755 index 0000000..b80c728 --- /dev/null +++ b/assets/vimrc @@ -0,0 +1,183 @@ +" +" Install plugins +" +set nocompatible " be iMproved, required + +filetype plugin indent on +syntax on +syntax sync minlines=256 + +" +" Settings +" +set autoindent +set autoread " Automatically reread changed files without asking me anything +set autowrite " Automatically save before :next, :make etc. +set backspace=indent,eol,start " Makes backspace key more powerful. +set complete=.,w,b,u,t +set completeopt=longest,menuone +set display+=lastline +set encoding=utf-8 " Set default encoding to UTF-8 +set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats +set hidden +set history=500 +set hlsearch +set ignorecase +set incsearch +set laststatus=2 +set lazyredraw +set nobackup " Don't create annoying backup files +set nocursorcolumn +set nocursorline +set noerrorbells " No beeps +set showmode " We show the mode with airlien or lightline +set noswapfile " Don't use swapfile +set nowritebackup +set nrformats-=octal +set number " Show line numbers +set re=1 +set ruler " Show the cursor position all the time +set scrolloff=7 +set showcmd " Show me what I'm typing +set showmatch " Show matching brackets by flickering +set sidescrolloff=7 +set smartcase +set splitbelow " Split horizontal windows below to the current windows +set splitright " Split vertical windows right to the current windows +set synmaxcol=300 +set tabpagemax=50 +set ttyfast + +" Make Vim to handle long lines nicely. +set wrap +set textwidth=79 +set formatoptions=qrn1 + +" Time out on key codes but not mappings. +set notimeout +set ttimeout +set ttimeoutlen=10 + +if has('gui_running') + "set transparency=3 + set regexpengine=1 " fix js regex syntax +endif + +let mapleader = "," + +" dont save .netrwhist history +let g:netrw_dirhistmax=0 + +" Allow saving of files as sudo when I forgot to start vim using sudo. +cmap w!! w !sudo tee > /dev/null % + +" open help vertically +command! -nargs=* -complete=help Help vertical belowright help + +" Different Cursorshapes for the modes +let &t_SI = "\[6 q" +let &t_SR = "\[4 q" +let &t_EI = "\[2 q" + +" ==================== Remap Keys ==================== +" Remaps % to tab so navigate to matching brackets +nnoremap % +vnoremap % + +" Visual mode pressing * or # searches for the current selection +vnoremap * :call VisualSelection('f') +vnoremap # :call VisualSelection('b') + +" Center, kill hl +nnoremap n nzzzv +nnoremap N Nzzzv +nnoremap :nohlsearch +nnoremap zz + +" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, +" so that you can undo CTRL-U after inserting a line break. +inoremap u + +" Toggle line numbers and rulers +nmap ll :set number! +nmap lr :set relativenumber! +nmap cc :set cursorcolumn! +nmap cl :set cursorline! + +" Better split switching +map j +map k +map h +map l +map j +map k +map h +map l + +" Move up and down on split lines +map gk +map gj +map k gk +map j gj + +" Spell checking +nnoremap :setlocal spell! spell? +map ss :setlocal spell! +map sn ]s +map sp [s +map sa zg +map s? z= + +" trim all whitespaces away +nnoremap W :%s/\s\+$//:let @/='' + +" Do not show stupid q: window +map q: :q + +" Paste Mode +set pastetoggle= + +" ==================== File Type settings ==================== +set tabstop=4 +set softtabstop=4 +set shiftwidth=4 +set noexpandtab +set shiftround +set smarttab + +au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.md setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.json setlocal et ts=2 sw=2 sts=2 +au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.md setlocal et ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.py setlocal et ts=4 sw=4 sts=4 +au BufNewFile,BufRead *.yml,*.yaml setlocal et ts=2 sw=2 sts=2 +au BufNewFile,BufRead *.htm,*.html setlocal noet ts=4 sw=4 sts=4 + +au FileType dockerfile setlocal et ts=2 sw=2 sts=2 +au FileType nginx setlocal noet ts=4 sw=4 sts=4 +au FileType fstab,systemd set noet +au FileType gitconfig,sh,toml set noet + +" ==================== Wildmenu ==================== +set wildmenu +set wildmode=list:full + +set wildignore+=.hg,.git,.svn " Version control +set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files +set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images +set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files +set wildignore+=*.spl " compiled spelling word lists +set wildignore+=*.sw? " Vim swap files +set wildignore+=*.DS_Store " OSX bullshit +set wildignore+=*.luac " Lua byte code +set wildignore+=migrations " Django migrations +set wildignore+=go/pkg " Go static files +set wildignore+=go/bin " Go bin files +set wildignore+=go/bin-vagrant " Go bin-vagrant files +set wildignore+=*.pyc " Python byte code +set wildignore+=*.orig " Merge resolution files + +" vim:ts=2:sw=2:et diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..aad20ea --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,18 @@ +version: "2" + +services: + + aap: + build: . + image: ${DOCKER_IMAGENAME} + restart: unless-stopped + logging: + driver: json-file + options: + max-file: "2" + max-size: "500k" + environment: + - SERVERADMINMAIL=webmaster@example.com + volumes: + - ./aap-webroot:/var/www/localhost +