install-debian.sh: change to oh-my-zsh, the script is now more robust against calling again

unattended-upgrades.sh: added executable bit
This commit is contained in:
Andreas Fendt 2018-04-28 20:25:29 +02:00
parent bbb8c553a2
commit 8c3a6b49e7
2 changed files with 35 additions and 40 deletions

75
install-debian.sh Normal file → Executable file
View File

@ -1,9 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# hotfix for strange strato configuration # Install Script for Debian and Ubuntu installations
# Copyright (C) 2017 Andreas Fendt - All Rights Reserved # This script can be called multiple times
# Copyright (C) 2018 Andreas Fendt - All Rights Reserved
# Permission to copy and modify is granted under the MIT license # Permission to copy and modify is granted under the MIT license
# Last revised 18.11.2017 # Last revised 28.04.2018
# check if root # check if root
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
@ -13,7 +14,7 @@ fi
# check if debian # check if debian
if [ ! "$(grep -Ei 'debian|buntu' /etc/*release)" ]; then if [ ! "$(grep -Ei 'debian|buntu' /etc/*release)" ]; then
echo "This script must be run on a debian system" 1>&2 echo "This script must be run on a debian or ubuntu system" 1>&2
exit 1 exit 1
fi fi
@ -22,42 +23,38 @@ apt-get update -y
apt-get dist-upgrade -y apt-get dist-upgrade -y
apt-get autoclean -y apt-get autoclean -y
# get users directory # get users directory and usernames
root_user=$(grep ':0:' /etc/passwd | awk -F':' '{print $1}')
root_user_path=$(grep ':0:' /etc/passwd | awk -F':' '{print $6}') 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_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}') default_user=$(egrep '\:100[0-9]\:' /etc/passwd | tail -n 1 | awk -F':' '{print $1}')
# default shell # install default packages
apt-get install -y sudo mc tree pv vim bash-completion apt-get install -y sudo mc tree pv vim bash-completion wget git htop iotop iftop nmon apt-file aptitude hexedit tmux \
fonts-powerline
# zsh shell # zsh shell
apt-get install -y zsh && ( apt-get install -y zsh && ( [ ! -d $root_user_path/.oh-my-zsh ] || [ ! -d $default_user_path/.oh-my-zsh ] ) && (
sed -i -- 's/\/bin\/bash/\/bin\/zsh/' /etc/passwd # change shell
wget -O /etc/zsh/newuser.zshrc.recommended \ chsh -s /bin/zsh $root_user
http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc chsh -s /bin/zsh $default_user
cp -f /etc/zsh/newuser.zshrc.recommended ${default_user_path}/.zshrc
cp -f /etc/zsh/newuser.zshrc.recommended ${root_user_path}/.zshrc # install oh-my-zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
# configure oh-my-zsh
grep 'ZSH_THEME="agnoster"' $root_user_path/.zshrc || sed -i -- 's/ZSH_THEME=".*"/ZSH_THEME="agnoster"/g' $root_user_path/.zshrc
grep "command-not-found" $root_user_path/.zshrc || sed -i -- '/^plugins=(/a \\ command-not-found\n common-aliases\n sudo\n systemd\n tmux\n ubuntu' $root_user_path/.zshrc
# install oh-my-zsh to default user
cp $root_user_path/.zshrc $default_user_path/.zshrc
cp -a $root_user_path/.oh-my-zsh $default_user_path/.oh-my-zsh
chown ${default_user}:${default_user} ${default_user_path}/.oh-my-zsh ${default_user_path}/.zshrc
# configure tmux
grep "ZSH_TMUX_AUTOSTART" $default_user_path/.zshrc || sed -i -- '1s/^/ZSH_TMUX_AUTOSTART="true"\nZSH_TMUX_AUTOQUIT="false"\n\n/' $default_user_path/.zshrc
) )
# add tmux auto start
apt-get install -y tmux && (
echo 'if [ "$TMUX" = "" ]; then tmux; fi' | cat - ${default_user_path}/.zshrc > \
/tmp/.zshrc && mv /tmp/.zshrc ${default_user_path}/.zshrc
)
# diagnostics
apt-get install -y htop iotop iftop nmon powertop stress lm-sensors \
gddrescue smartmontools kpartx nmap
# programming
apt-get install -y git build-essential
# networking
apt-get install -y axel wget ethtool fping
# misc. tools
apt-get install -y apt-file aptitude hexedit manpages-de
# configure vim # configure vim
touch ${root_user_path}/.vimrc ${default_user_path}/.vimrc touch ${root_user_path}/.vimrc ${default_user_path}/.vimrc
for config in "filetype plugin indent on" "set tabstop=4" "set shiftwidth=4" \ for config in "filetype plugin indent on" "set tabstop=4" "set shiftwidth=4" \
@ -66,16 +63,14 @@ for config in "filetype plugin indent on" "set tabstop=4" "set shiftwidth=4" \
grep "$config" ${root_user_path}/.vimrc || echo "$config" >> ${root_user_path}/.vimrc grep "$config" ${root_user_path}/.vimrc || echo "$config" >> ${root_user_path}/.vimrc
grep "$config" ${default_user_path}/.vimrc || echo "$config" >> ${default_user_path}/.vimrc grep "$config" ${default_user_path}/.vimrc || echo "$config" >> ${default_user_path}/.vimrc
done done
chown ${default_user}:${default_user} ${default_user_path}/.vimrc
# configure user files
chown ${default_user}:${default_user} ${default_user_path}/.vimrc ${default_user_path}/.zshrc
# configure tmux # configure tmux
cat > /etc/tmux.conf <<EOL for config in "bind '\"' split-window -c \"#{pane_current_path}\"" \
bind '"' split-window -c "#{pane_current_path}" "bind % split-window -h -c \"#{pane_current_path}\"" \
bind % split-window -h -c "#{pane_current_path}" "bind c new-window -c \"#{pane_current_path}\""; do
bind c new-window -c "#{pane_current_path}" grep "$config" /etc/tmux.conf || echo "$config" >> /etc/tmux.conf
EOL done
# configure system # configure system
apt-get install -y console-data console-setup locales \ apt-get install -y console-data console-setup locales \

0
unattended-upgrades.sh Normal file → Executable file
View File