From 452a94b9933411efc168371c90c955c7ef4f9194 Mon Sep 17 00:00:00 2001 From: Alban VIDAL Date: Mon, 14 May 2018 01:18:46 +0200 Subject: [PATCH] Initial commit Signed-off-by: Alban VIDAL --- README.md | 26 +++++++++ auto_config.sh | 78 +++++++++++++++++++++++++ root/.bashrc | 43 ++++++++++++++ root/.profile | 20 +++++++ root/.profile.d/00_stats_connexion.conf | 1 + root/.vimrc | 36 ++++++++++++ 6 files changed, 204 insertions(+) create mode 100644 README.md create mode 100755 auto_config.sh create mode 100644 root/.bashrc create mode 100644 root/.profile create mode 100644 root/.profile.d/00_stats_connexion.conf create mode 100644 root/.vimrc diff --git a/README.md b/README.md new file mode 100644 index 0000000..37c4ea3 --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/auto_config.sh b/auto_config.sh new file mode 100755 index 0000000..e60c212 --- /dev/null +++ b/auto_config.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +# +# BSD 3-Clause License +# +# Copyright (c) 2018, Alban Vidal +# 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 + diff --git a/root/.bashrc b/root/.bashrc new file mode 100644 index 0000000..60c71c6 --- /dev/null +++ b/root/.bashrc @@ -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 ' + diff --git a/root/.profile b/root/.profile new file mode 100644 index 0000000..6ac3361 --- /dev/null +++ b/root/.profile @@ -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 + diff --git a/root/.profile.d/00_stats_connexion.conf b/root/.profile.d/00_stats_connexion.conf new file mode 100644 index 0000000..483708e --- /dev/null +++ b/root/.profile.d/00_stats_connexion.conf @@ -0,0 +1 @@ +echo TODO diff --git a/root/.vimrc b/root/.vimrc new file mode 100644 index 0000000..34f075b --- /dev/null +++ b/root/.vimrc @@ -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 : +set tabstop=4 " (ts) width (in spaces) that a 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 +