install-script/install-debian.sh

89 lines
2.8 KiB
Bash
Raw Normal View History

2015-10-13 23:42:34 +02:00
#!/usr/bin/env bash
# hotfix for strange strato configuration
# Copyright (C) 2017 Andreas Fendt - All Rights Reserved
# Permission to copy and modify is granted under the MIT license
# Last revised 18.11.2017
2017-10-27 18:56:57 +02:00
# check if root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
2017-10-27 18:56:57 +02:00
# check if debian
if [ ! "$(grep -Ei 'debian|buntu' /etc/*release)" ]; then
echo "This script must be run on a debian system" 1>&2
exit 1
fi
2017-10-27 18:56:57 +02:00
# update system
apt-get update -y
apt-get dist-upgrade -y
apt-get autoclean -y
2017-10-27 18:56:57 +02:00
# get users directory
2017-11-04 14:24:43 +01:00
root_user_path=$(grep ':0:' /etc/passwd | awk -F':' '{print $6}')
default_user_path=$(egrep '\:100[0-9]\:' /etc/passwd | tail -n 1 | awk -F':' '{print $6}')
default_user=$(egrep '\:100[0-9]\:' /etc/passwd | tail -n 1 | awk -F':' '{print $1}')
2017-10-27 18:56:57 +02:00
# default shell
apt-get install -y sudo mc tree pv vim bash-completion
2017-10-27 18:56:57 +02:00
# zsh shell
apt-get install -y zsh && (
sed -i -- 's/\/bin\/bash/\/bin\/zsh/' /etc/passwd
wget -O /etc/zsh/newuser.zshrc.recommended \
http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
2017-11-04 14:24:43 +01:00
cp -f /etc/zsh/newuser.zshrc.recommended ${default_user_path}/.zshrc
cp -f /etc/zsh/newuser.zshrc.recommended ${root_user_path}/.zshrc
2017-10-27 18:56:57 +02:00
)
2017-10-27 18:56:57 +02:00
# add tmux auto start
apt-get install -y tmux && (
2017-11-04 14:24:43 +01:00
echo 'if [ "$TMUX" = "" ]; then tmux; fi' | cat - ${default_user_path}/.zshrc > \
/tmp/.zshrc && mv /tmp/.zshrc ${default_user_path}/.zshrc
2017-10-27 18:56:57 +02:00
)
2017-10-27 18:56:57 +02:00
# diagnostics
apt-get install -y htop iotop iftop nmon powertop stress lm-sensors \
gddrescue smartmontools kpartx nmap
2017-10-27 18:56:57 +02:00
# programming
apt-get install -y git build-essential
# networking
apt-get install -y axel wget ethtool fping
2017-10-27 18:56:57 +02:00
# misc. tools
apt-get install -y apt-file aptitude hexedit manpages-de
2017-10-27 18:56:57 +02:00
# configure vim
2017-11-04 14:24:43 +01:00
touch ${root_user_path}/.vimrc ${default_user_path}/.vimrc
2017-10-27 18:56:57 +02:00
for config in "filetype plugin indent on" "set tabstop=4" "set shiftwidth=4" \
"set expandtab" "syntax enable" "set softtabstop=4" \
"set number" "set showcmd" "set cursorline"; do
2017-11-04 14:24:43 +01:00
grep "$config" ${root_user_path}/.vimrc || echo "$config" >> ${root_user_path}/.vimrc
grep "$config" ${default_user_path}/.vimrc || echo "$config" >> ${default_user_path}/.vimrc
2014-09-07 21:46:07 +02:00
done
2017-10-27 18:56:57 +02:00
2017-11-04 14:24:43 +01:00
# configure user files
chown ${default_user}:${default_user} ${default_user_path}/.vimrc ${default_user_path}/.zshrc
2017-10-27 18:56:57 +02:00
# configure tmux
cat > /etc/tmux.conf <<EOL
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
EOL
# configure system
apt-get install -y console-data console-setup locales \
keyboard-configuration tzdata
dpkg-reconfigure console-data console-setup locales \
keyboard-configuration tzdata
# run programs
apt-file update
sensors-detect --auto