Initial commit

Signed-off-by: Alban VIDAL <alban.vidal@zordhak.fr>
This commit is contained in:
Alban VIDAL 2018-05-14 01:18:46 +02:00
parent 117ba9c03c
commit 452a94b993
6 changed files with 204 additions and 0 deletions

26
README.md Normal file
View File

@ -0,0 +1,26 @@
Basic config for Debian
=======================
This script configure basic config for Debian
The following component are configured:
+ Install git and tig
+ Set git username and email
+ Install bash-completion
+ Install and configure auto updates (unattended-upgrades and apt-listchanges
+ Install and tune logrotate
+ Disable IPv6
+ Tune .vimrc
+ Tune .bashrc
+ Tune .profile
You just need to clone this repository in /srv/git/basic_config_debian and execute the auto_config.sh script
```bash
apt install git
mkdir -p /srv/git
git clone https://github.com/AlbanVidal/basic_config_debian.git /srv/git/basic_config_debian
cd /srv/git/basic_config_debian
./auto_config.sh
```

78
auto_config.sh Executable file
View File

@ -0,0 +1,78 @@
#!/bin/bash
#
# BSD 3-Clause License
#
# Copyright (c) 2018, Alban Vidal <alban.vidal@zordhak.fr>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
################################################################################
# Install the packages
apt-get -y install -y git tig bash-completion unattended-upgrades apt-listchanges logrotate
# Configure auto updates
sed -i \
-e 's#^//Unattended-Upgrade::Mail .*#Unattended-Upgrade::Mail "unattended@zordhak.fr";#' \
-e 's#^//Unattended-Upgrade::MailOnlyOnError .*#Unattended-Upgrade::MailOnlyOnError "true";#' \
/etc/apt/apt.conf.d/50unattended-upgrades
# Git global username and email
read -p "Git username: " GIT_USERNAME
read -p "Git email: " GIT_EMAIL
git config --global user.name "$GIT_USERNAME"
git config --global user.email "$GIT_EMAIL"
## Symbolic links
# Bashrc
ln -sf /srv/git/basic_config_debian/root/.bashrc /root/
# Profile
ln -sf /srv/git/basic_config_debian/root/.profile /root/
mkdir -p /root/.profile.d
ln -sf /srv/git/basic_config_debian/root/.profile.d/00_connexion_info.conf /root/.profile.d/
# vimrc
ln -sf /srv/git/basic_config_debian/root/.vimrc /root/
## Tune logrotate
# Fix logrotate bug
cat << EOF > /etc/cron.daily/logrotate
#!/bin/sh
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate -f /etc/logrotate.conf
EOF
# Disable delaycompress
sed -i 's/.*delaycompress/#&/' /etc/logrotate.d/*
# Disable IPv6
cat << EOF > /etc/sysctl.d/98-disable-ipv6.conf
# Disable ipv6 on all connexion
net.ipv6.conf.all.disable_ipv6 = 1
EOF
sysctl -p

43
root/.bashrc Normal file
View File

@ -0,0 +1,43 @@
# If .bashrc.d directory exist, load .conf files
if [ -f ~/.bashrc.d/*.conf ]; then
for bashrc_d_file in ~/.bashrc.d/*.conf ; do
. $bashrc_d_file
done
fi
# alias
export LS_OPTIONS='--color=auto'
alias ls='ls -h'
alias ll='ls -lh'
alias l='ls -lAh'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Journalctl :
alias jf="journalctl -f"
# Git :
alias ggb="cd /srv/git/basic_config_debian"
alias gs="git status"
alias gd="git diff"
alias ga="git add"
alias gb="git branch"
alias gc="git commit"
alias gca="git commit -v -a"
alias gcam="git commit --amend -v"
alias gp="git push origin master"
alias gl="git log"
alias gll="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
# PS1
export PS1="\[\033]0;\u@\h - \w\007\]\[\e[32m\]root@\h\[\e[0m\] [\[\e[0m\]\t\[\e[0m\]][\[\e[34m\]\w\[\e[0m\]]$ "
# History format
HISTTIMEFORMAT='%Y-%m-%d %H:%M:%S '

20
root/.profile Normal file
View File

@ -0,0 +1,20 @@
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n
################################################################################
# My conf
# if .profile.d directory exist, load .conf files
if [ -f ~/.profile.d/*.conf ] ;then
for profile_d_file in /root/.profile.d/*.conf
do
. $profile_d_file
done
fi

View File

@ -0,0 +1 @@
echo TODO

36
root/.vimrc Normal file
View File

@ -0,0 +1,36 @@
" Activation de la colorisation syntaxique :
syntax on
"
" Gestion de la casse pour les recherches «/ »
"« set ignorecase » for case-insensitive searching
"« set smartcase » which will automatically switch to a case-sensitive search if you use any capital letters
"set smartcase
set ignorecase
"
" thèmes de couleurs :
"colorscheme koehler
colorscheme pablo
"
" (et) activer le remplacement des tabulations par des espaces :
set expandtab " (et) expand tabs to spaces (use :retab to redo entire file)
"
" (ts) nombre d'espace qui seront générés lors de l'appuie de la touche <tab> :
set tabstop=4 " (ts) width (in spaces) that a <tab> is displayed as
"
" (sw) nombre d'espaces utilisés pour l'auto indentation :
set shiftwidth=4 " (sw) width (in spaces) used in each step of autoindent (aswell as << and >>)
"
" Permet de prendre en compte les lignes du type suivant pour surcharger le conf vim
" # vim: syntax=sh ts=4 sw=4 sts=4
" http://vim.wikia.com/wiki/Modeline_magic
set modeline
"
" mettre surbrillance les résultats de la recherche
set hlsearch
"
" Permet de retourner a la dernière ligne lue dans un fichier
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif