2015-10-13 23:42:34 +02:00
|
|
|
#!/usr/bin/env bash
|
2014-09-02 15:57:01 +02:00
|
|
|
|
2018-04-28 20:25:29 +02:00
|
|
|
# Install Script for Debian and Ubuntu installations
|
|
|
|
# This script can be called multiple times
|
2019-02-19 23:38:47 +01:00
|
|
|
# Copyright (C) 2019 Andreas Fendt - All Rights Reserved
|
2017-11-18 14:55:09 +01:00
|
|
|
# Permission to copy and modify is granted under the MIT license
|
2019-10-05 12:24:19 +02:00
|
|
|
# Last revised 05.10.2019
|
2017-11-18 14:55:09 +01:00
|
|
|
|
2019-02-19 23:38:47 +01:00
|
|
|
# create the temporary script
|
2018-06-17 14:39:15 +02:00
|
|
|
script=/tmp/install-script
|
|
|
|
cat > $script << 'EOL'
|
2019-02-20 00:02:55 +01:00
|
|
|
# change behavior of bash
|
2019-02-19 23:38:47 +01:00
|
|
|
set -e
|
|
|
|
|
2018-06-17 14:39:15 +02:00
|
|
|
# configure vim
|
|
|
|
configure-vim() {
|
|
|
|
touch ~/.vimrc
|
|
|
|
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
|
|
|
|
grep "$config" ~/.vimrc || echo "$config" >> ~/.vimrc
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# install fzf
|
|
|
|
install-fzf() {
|
2019-02-20 00:02:55 +01:00
|
|
|
if [ ! -d ~/.fzf ]; then
|
|
|
|
cd ~ && git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install
|
|
|
|
else
|
|
|
|
echo "fzf is already installed for $(id)"
|
|
|
|
fi
|
2018-06-17 14:39:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# install oh-my-zsh
|
|
|
|
install-ohmyzsh() {
|
2019-02-20 00:02:55 +01:00
|
|
|
if [ ! -d ~/.oh-my-zsh ]; then
|
2019-02-19 23:38:47 +01:00
|
|
|
# install oh-my-zsh
|
2019-10-05 12:05:41 +02:00
|
|
|
git clone https://github.com/HyP3r-/oh-my-zsh.git ~/.oh-my-zsh
|
2019-03-06 02:08:19 +01:00
|
|
|
touch ~/.zshrc && cp ~/.zshrc ~/.zshrc.orig
|
2019-02-19 23:38:47 +01:00
|
|
|
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
2018-06-17 14:39:15 +02:00
|
|
|
|
|
|
|
# configure oh-my-zsh
|
|
|
|
grep 'ZSH_THEME="agnoster"' ~/.zshrc || sed -i -- 's/ZSH_THEME=".*"/ZSH_THEME="agnoster"/g' ~/.zshrc
|
2019-02-19 23:38:47 +01:00
|
|
|
grep "command-not-found" ~/.zshrc || sed -i -- '/^plugins=(/s/git/command-not-found common-aliases git sudo systemd tmux ubuntu/' ~/.zshrc
|
2018-06-17 14:39:15 +02:00
|
|
|
|
|
|
|
# configure tmux on normal user
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
grep "ZSH_TMUX_AUTOSTART" ~/.zshrc || sed -i -- '1s/^/ZSH_TMUX_AUTOSTART="true"\nZSH_TMUX_AUTOQUIT="false"\n\n/' ~/.zshrc
|
|
|
|
fi
|
2019-02-20 00:02:55 +01:00
|
|
|
else
|
|
|
|
echo "oh-my-zsh is already installed for $(id)"
|
|
|
|
fi
|
2018-06-17 14:39:15 +02:00
|
|
|
}
|
|
|
|
|
2019-02-19 23:44:13 +01:00
|
|
|
# call target function depending of the arguments
|
2018-06-17 14:39:15 +02:00
|
|
|
$@
|
2019-02-19 23:44:13 +01:00
|
|
|
exit 0
|
2018-06-17 14:39:15 +02:00
|
|
|
EOL
|
|
|
|
chmod +x $script
|
|
|
|
|
2019-02-20 00:02:55 +01:00
|
|
|
# change behavior of bash
|
2019-02-19 23:38:47 +01:00
|
|
|
set -e
|
|
|
|
|
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
|
2014-09-02 15:57:01 +02:00
|
|
|
|
2017-10-27 18:56:57 +02:00
|
|
|
# check if debian
|
|
|
|
if [ ! "$(grep -Ei 'debian|buntu' /etc/*release)" ]; then
|
2018-04-28 20:25:29 +02:00
|
|
|
echo "This script must be run on a debian or ubuntu system" 1>&2
|
2017-10-27 18:56:57 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2014-09-02 15:57:01 +02:00
|
|
|
|
2017-10-27 18:56:57 +02:00
|
|
|
# update system
|
|
|
|
apt-get update -y
|
2017-10-28 15:02:32 +02:00
|
|
|
apt-get dist-upgrade -y
|
|
|
|
apt-get autoclean -y
|
2014-09-02 15:57:01 +02:00
|
|
|
|
2018-04-28 20:25:29 +02:00
|
|
|
# install default packages
|
2019-10-05 12:14:21 +02:00
|
|
|
apt-get install -y apt-file aptitude bash-completion dialog fonts-powerline git hexedit htop iftop iotop mc nmon pv python3-pip sudo tmux tree vim wget zsh
|
|
|
|
pip3 install git+https://github.com/jeffkaufman/icdiff.git@release-1.9.5
|
2014-09-05 21:47:00 +02:00
|
|
|
|
2018-06-17 14:39:15 +02:00
|
|
|
# get users
|
|
|
|
menu=(); while IFS=: read -r name pw uid gid gecos home shell; do if (( uid >= 1000 && uid < 10000 )); then menu+=( "$name" "$uid" on ); fi; done < /etc/passwd
|
|
|
|
users=$(dialog --checklist "Install this on User" 0 0 4 root "0" on "${menu[@]}" 3>&1 1>&2 2>&3)
|
2018-04-30 17:12:29 +02:00
|
|
|
|
2018-06-17 14:39:15 +02:00
|
|
|
# for each user install packages
|
|
|
|
for user in $users; do
|
|
|
|
# install zsh shell
|
2019-11-03 22:50:24 +01:00
|
|
|
chsh -s /bin/zsh $user || true
|
2014-09-02 15:57:01 +02:00
|
|
|
|
2018-06-17 14:39:15 +02:00
|
|
|
# run install and configuration scripts
|
|
|
|
for target in install-ohmyzsh install-fzf configure-vim; do
|
2019-11-03 22:50:24 +01:00
|
|
|
su -l -c "$script $target" -s /bin/bash $user || true
|
2018-06-17 14:39:15 +02:00
|
|
|
done
|
2014-09-07 21:46:07 +02:00
|
|
|
done
|
2017-11-04 14:24:43 +01:00
|
|
|
|
2017-10-27 18:56:57 +02:00
|
|
|
# configure tmux
|
2018-04-28 20:25:29 +02:00
|
|
|
for config in "bind '\"' split-window -c \"#{pane_current_path}\"" \
|
|
|
|
"bind % split-window -h -c \"#{pane_current_path}\"" \
|
|
|
|
"bind c new-window -c \"#{pane_current_path}\""; do
|
2018-06-17 14:39:15 +02:00
|
|
|
grep "$config" /etc/tmux.conf || echo "$config" >> /etc/tmux.conf
|
2018-04-28 20:25:29 +02:00
|
|
|
done
|
2017-10-27 18:56:57 +02:00
|
|
|
|
|
|
|
# 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
|
2018-06-17 14:39:15 +02:00
|
|
|
|
|
|
|
# delete temporary script file
|
|
|
|
rm -f $script
|