====== post install for servers ======
apt install -y curl && \
curl -s "http://wiki.csgalileo.org/tips:ubuntu:locale?do=export_code&codeblock=1" | /bin/bash
apt remove -y unattended-upgrades
locale-gen it_IT.UTF-8
locale-gen en_US.UTF-8
update-locale LANG=it_IT.UTF-8 LC_MESSAGES=POSIX
timedatectl set-timezone Europe/Rome
grep -q menu-complete /etc/inputrc
if [ $? = 1 ]; then
cat >> /etc/inputrc < /etc/apt/apt.conf.d/20auto-upgrades < /etc/tmux.conf
cat > /etc/vim/vimrc.local < 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
if has("autocmd")
filetype plugin indent on
endif
EOF
cat > /root/.aliases < /root/.ssh/authorized_keys < /root/.bashrc
update-alternatives --set editor /usr/bin/vim.tiny
[ -d /etc/cloud ] && echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
[ -d /etc/cloud ] && perl -pi -e "s|disable_root: .*|disable_root: false|" /etc/cloud/cloud.cfg
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
HISTCONTROL=ignoredups:ignorespace
shopt -s histappend
HISTSIZE=5000
HISTFILESIZE=10000
shopt -s checkwinsize
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
unset color_prompt force_color_prompt
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
[ -f ~/.aliases ] && . ~/.aliases
[ -f ~/.bashrc.local ] && . ~/.bashrc.local
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
# run TMUX
[[ $- != *i* ]] && return
if which tmux >/dev/null 2>&1; then
if [[ -z "$TMUX" ]] ;then
ID="`tmux ls | grep -vm1 attached | cut -d: -f1`" # get the id of a deattached session
if [[ -z "$ID" ]] ;then # if not available create a new one
tmux new-session
else
tmux attach-session -t "$ID" # if available attach to it
fi
fi
fi
### NOTHING BELOW ###
mkdir -p /root/.ssh
cat > /root/.ssh/authorized_keys <
sudo apt install -y curl && \
curl -s "http://wiki.csgalileo.org/tips:ubuntu:locale?do=export_code&codeblock=3" | sudo /bin/sh