Last active
August 29, 2015 14:17
-
-
Save hotfix31/abbe645b57a07c01cdbb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "### Post-install" | |
| cd / | |
| N=`date +%F` | |
| H=`hostname -s` | |
| I=`hostname -i` | |
| F=`hostname -f` | |
| echo "## APT" | |
| echo "# Configure..." | |
| cat > /etc/apt/sources.list <<EOF | |
| deb http://ftp.fr.debian.org/debian/ wheezy main non-free contrib | |
| #deb-src http://ftp.fr.debian.org/debian/ wheezy main non-free contrib | |
| EOF | |
| cat > /etc/apt/sources.list.d/deb_updates.list <<EOF | |
| # wheezy-updates, previously known as 'volatile' | |
| deb http://ftp.fr.debian.org/debian/ wheezy-updates main contrib non-free | |
| #deb-src http://ftp.fr.debian.org/debian/ wheezy-updates main contrib non-free | |
| EOF | |
| cat > /etc/apt/sources.list.d/deb_secu.list <<EOF | |
| deb http://security.debian.org/ wheezy/updates main contrib non-free | |
| #deb-src http://security.debian.org/ wheezy/updates main contrib non-free | |
| EOF | |
| cat > /etc/apt/apt.conf.d/10norecommends <<EOF | |
| APT::Install-Recommends "0"; | |
| EOF | |
| cat > /etc/apt/apt.conf.d/10nosuggests <<EOF | |
| APT::Install-Suggests "0"; | |
| EOF | |
| echo "# Update package list..." | |
| aptitude update | |
| echo "# Upgrade installed packages..." | |
| aptitude -y safe-upgrade | |
| echo "# Install a few useful packages..." | |
| aptitude -y install vim-nox sudo screen inetutils-telnet ntpdate bsd-mailx logrotate multitail tcpdump nmap lsof ssmtp bind9-host atop htop iptraf psmisc less mlocate mtr python rsync unzip dnsutils whois cron-apt geoip-database snmp snmpd openssh-server file lockfile-progs openssh-blacklist openssh-blacklist-extra logwatch | |
| echo "## Sample bash config" | |
| echo "# for 'root'" | |
| cat > /root/.bashrc <<EOF | |
| # ~/.bashrc: executed by bash(1) for non-login shells. | |
| export LS_OPTIONS='--color=auto' | |
| eval "\`dircolors\`" | |
| alias ls='ls \$LS_OPTIONS' | |
| alias ll='ls \$LS_OPTIONS -l' | |
| alias l='ls \$LS_OPTIONS -lA' | |
| alias grep="grep --color" | |
| # Some more alias to avoid making mistakes: | |
| alias rm='rm -i' | |
| alias cp='cp -i' | |
| alias mv='mv -i' | |
| # Prompt | |
| case "\$TERM" in | |
| xterm*|rxvt*) | |
| PS1="[\u@\h: \w]\\\$ " | |
| export PROMPT_COMMAND='echo -ne "\033]0;\${USER}@\${HOSTNAME}: \${PWD}\007"' | |
| ;; | |
| screen) | |
| PS="[\u@\h: \w]\\\\$ " | |
| export PROMPT_COMMAND='echo -ne "\ek$(echo ${USER}@${HOSTNAME}: ${PWD/$HOME/\~})\e\\"' | |
| ;; | |
| *) | |
| PS1="[\u@\h: \w]\\\$ " | |
| ;; | |
| esac | |
| # pour ne pas que dpkg soit gene par le noexec de /tmp | |
| export TMPDIR="/var/tmp" | |
| export PS1 | |
| EOF | |
| echo "## Vim" | |
| cat > /etc/vim/vimrc.local <<EOF | |
| syntax on | |
| set hls | |
| set showmatch | |
| set laststatus=2 | |
| set modeline | |
| set modelines=1 | |
| set title | |
| EOF | |
| echo "# Cron-APT" | |
| cat > /etc/cron-apt/config <<EOF | |
| APTCOMMAND=/usr/bin/aptitude | |
| MAILON="upgrade" | |
| SYSLOGON="error" | |
| DIFFONCHANGES=prepend | |
| EOF | |
| cat > /etc/cron-apt/action.d/3-download <<EOF | |
| autoclean -y | |
| safe-upgrade -d -y -o APT::Get::Show-Upgraded=true -o quiet=2 | |
| EOF | |
| cat > /etc/cron-apt/action.d/0-update <<EOF | |
| update -o quiet=2 | |
| EOF | |
| echo "# Cron" | |
| cat > /etc/cron.d/perso <<EOF | |
| 0 0 * * * root /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2> /dev/null || /bin/true | |
| 59 23 * * * root /usr/sbin/logwatch --mailto [email protected] --output mail > /dev/null 2> /dev/null || /bin/true | |
| EOF | |
| chmod 0755 /etc/cron.d/tfb | |
| echo -e '#!/bin/sh\nexit 0' > /etc/cron.daily/logrotate | |
| chmod 0444 /etc/cron.daily/logrotate | |
| echo -e '#!/bin/sh\nexit 0'> /etc/cron.daily/00logwatch | |
| chmod 0444 /etc/cron.daily/00logwatch | |
| echo "# Default editor/pager" | |
| update-alternatives --set editor /usr/bin/vim.nox | |
| update-alternatives --set pager /bin/less | |
| echo "# Disable some needless services" | |
| for s in atop mpt-statusd rsync | |
| do | |
| echo -n "## disable $s... " | |
| update-rc.d $s disable &> /dev/null | |
| if [ $? -eq 0 ] | |
| then | |
| echo OK | |
| else | |
| echo KO | |
| fi | |
| done | |
| echo "*** DONE ***" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment