Next Version

This commit is contained in:
Andreas Fendt 2017-10-27 18:56:57 +02:00
parent 88dfc7d0d4
commit aed3d27681

View File

@ -1,164 +1,78 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# functions
function repository {
apt-get install -y software-properties-common && (
add-apt-repository -y ppa:ultradvorka/ppa
add-apt-repository -y ppa:webupd8team/java
)
}
function update-upgrade {
apt-get update -y
apt-get upgrade -y
}
function common {
# get users directory
root_user=$(grep ':0:' /etc/passwd | awk -F':' '{print $6}')
default_user=$(grep ':1000:' /etc/passwd | awk -F':' '{print $6}')
# default shell
apt-get install -y sudo mc tree pv vim mosh bash-completion
# bash shell
apt-get install -y hh && (
grep HH_CONFIG /etc/bash.bashrc || \
hh --show-configuration >> /etc/bash.bashrc
)
# 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
cp -f /etc/zsh/newuser.zshrc.recommended $default_user/.zshrc
cp -f /etc/zsh/newuser.zshrc.recommended $root_user/.zshrc
)
# tmux
apt-get install -y tmux && (
echo 'if [ "$TMUX" = "" ]; then tmux; fi' | cat - $default_user/.zshrc > \
/tmp/.zshrc && mv /tmp/.zshrc $default_user/.zshrc
)
# diagnostics
apt-get install -y htop iotop iftop nmon powertop stress lm-sensors \
gddrescue smartmontools kpartx nmap
# programming
apt-get install -y git subversion libapache2-svn build-essential
# networking
apt-get install -y nfs-common cifs-utils openvpn axel \
wget ethtool fping
# misc. tools
apt-get install -y apt-file aptitude hexedit manpages-de
# configure vim
touch $root_user/.vimrc $default_user/.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" $root_user/.vimrc || echo "$config" >> $root_user/.vimrc
grep "$config" $default_user/.vimrc || echo "$config" >> $default_user/.vimrc
done
}
function common-end {
# 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
}
function client-gui {
# programs
apt-get install -y firefox firefox-locale-de thunderbird \
thunderbird-locale-de keepassx filezilla vlc gparted \
wireshark kate
# IDE
apt-get install -y eclipse
# OpenJDK
apt-get install -y openjdk-6-jdk openjdk-6-source openjdk-6-demo \
openjdk-6-doc openjdk-6-jre-headless openjdk-6-jre-lib
apt-get install -y openjdk-7-jdk openjdk-7-source openjdk-7-demo \
openjdk-7-doc openjdk-7-jre-headless openjdk-7-jre-lib
apt-get install -y icedtea-7-plugin
# Oracle Java
apt-get install -y oracle-java7-installer oracle-java8-installer
# misc. tools
apt-get install -y git-gui bless
}
function client-gui-end {
# Java Plugin
update-alternatives --config mozilla-javaplugin.so
}
function server-gui {
# programs
apt-get install -y firefox firefox-locale-de thunderbird \
thunderbird-locale-de filezilla gparted wireshark kate
# ssh
apt-get install -y openssh-server
}
function server-cli {
# ssh
apt-get install -y openssh-server
}
# check if root # check if root
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2 echo "This script must be run as root" 1>&2
exit 1 exit 1
fi fi
# choose plattform # check if debian
PS3='Please enter your system ' if [ ! "$(grep -Ei 'debian|buntu' /etc/*release)" ]; then
options=("client-gui" "server-cli" "server-gui" "quit") echo "This script must be run on a debian system" 1>&2
select opt in "${options[@]}" exit 1
do fi
case $opt in
"client-gui") # update system
update-upgrade apt-get update -y
repository apt-get upgrade -y
common
client-gui # get users directory
common-end root_user=$(grep ':0:' /etc/passwd | awk -F':' '{print $6}')
client-gui-end default_user=$(egrep '\:100[0-9]\:' /etc/passwd | tail -n 1 | awk -F':' '{print $6}')
break
;; # default shell
"server-cli") apt-get install -y sudo mc tree pv vim bash-completion
update-upgrade
repository # zsh shell
common apt-get install -y zsh && (
server-cli sed -i -- 's/\/bin\/bash/\/bin\/zsh/' /etc/passwd
common-end wget -O /etc/zsh/newuser.zshrc.recommended \
break http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
;; cp -f /etc/zsh/newuser.zshrc.recommended $default_user/.zshrc
"server-gui") cp -f /etc/zsh/newuser.zshrc.recommended $root_user/.zshrc
update-upgrade )
repository
common # add tmux auto start
server-gui apt-get install -y tmux && (
common-end echo 'if [ "$TMUX" = "" ]; then tmux; fi' | cat - $default_user/.zshrc > \
break /tmp/.zshrc && mv /tmp/.zshrc $default_user/.zshrc
;; )
*)
echo invalid option # diagnostics
;; apt-get install -y htop iotop iftop nmon powertop stress lm-sensors \
esac gddrescue smartmontools kpartx nmap
# programming
apt-get install -y git build-essential
# networking
apt-get install -y nfs-common cifs-utils axel wget ethtool fping
# misc. tools
apt-get install -y apt-file aptitude hexedit manpages-de
# configure vim
touch $root_user/.vimrc $default_user/.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" $root_user/.vimrc || echo "$config" >> $root_user/.vimrc
grep "$config" $default_user/.vimrc || echo "$config" >> $default_user/.vimrc
done done
# 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