#!/bin/bash
echo "RUN $(basename "$0") ==="


if [ -z "$(grep '^alias ls=' /root/.bashrc)" ]
then
    echo 'alias ls="ls -lstrh --color=auto"' >> /root/.bashrc
fi
cat <<EOF > /root/.vimrc
set bg=dark
colorscheme slate

set number
set relativenumber
set showcmd
" Define tabs size
set shiftwidth=4
set tabstop=4
" Replace tab by spaces
set expandtab
set smartindent
set smarttab
" Smartcase
set smartcase
set ignorecase
" Define line size
"set textwidth=78
set textwidth=0
set linebreak
set colorcolumn=80
highlight ColorColumn ctermbg=darkgrey

" Syntax coloration
syntax on
filetype plugin indent on
EOF

cat <<EOF > /etc/fail2ban/jail.local
[DEFAULT]

# Ignore Tetras Libre IPs
ignoreip = 127.0.0.1/8 ::1 $(dig +short servermon.tetras-libre.fr | tail -n 1) $(dig +short tetrix.tetras-libre.fr | tail -n 1) $(docker network inspect traefik | awk '/Subnet/{print $2}' | sed -e 's/"//g' -e 's/,$//')
EOF
fail2ban-client reload