Escaped Variables

Added change owner
This commit is contained in:
Andreas Fendt 2017-11-04 14:24:43 +01:00
parent d2aa306d87
commit fdb426038e

View File

@ -18,8 +18,9 @@ apt-get dist-upgrade -y
apt-get autoclean -y apt-get autoclean -y
# get users directory # get users directory
root_user=$(grep ':0:' /etc/passwd | awk -F':' '{print $6}') root_user_path=$(grep ':0:' /etc/passwd | awk -F':' '{print $6}')
default_user=$(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 shell # default shell
apt-get install -y sudo mc tree pv vim bash-completion apt-get install -y sudo mc tree pv vim bash-completion
@ -29,14 +30,14 @@ apt-get install -y zsh && (
sed -i -- 's/\/bin\/bash/\/bin\/zsh/' /etc/passwd sed -i -- 's/\/bin\/bash/\/bin\/zsh/' /etc/passwd
wget -O /etc/zsh/newuser.zshrc.recommended \ wget -O /etc/zsh/newuser.zshrc.recommended \
http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc 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 ${default_user_path}/.zshrc
cp -f /etc/zsh/newuser.zshrc.recommended $root_user/.zshrc cp -f /etc/zsh/newuser.zshrc.recommended ${root_user_path}/.zshrc
) )
# add tmux auto start # add tmux auto start
apt-get install -y tmux && ( apt-get install -y tmux && (
echo 'if [ "$TMUX" = "" ]; then tmux; fi' | cat - $default_user/.zshrc > \ echo 'if [ "$TMUX" = "" ]; then tmux; fi' | cat - ${default_user_path}/.zshrc > \
/tmp/.zshrc && mv /tmp/.zshrc $default_user/.zshrc /tmp/.zshrc && mv /tmp/.zshrc ${default_user_path}/.zshrc
) )
# diagnostics # diagnostics
@ -53,14 +54,17 @@ apt-get install -y axel wget ethtool fping
apt-get install -y apt-file aptitude hexedit manpages-de apt-get install -y apt-file aptitude hexedit manpages-de
# configure vim # configure vim
touch $root_user/.vimrc $default_user/.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" \
"set expandtab" "syntax enable" "set softtabstop=4" \ "set expandtab" "syntax enable" "set softtabstop=4" \
"set number" "set showcmd" "set cursorline"; do "set number" "set showcmd" "set cursorline"; do
grep "$config" $root_user/.vimrc || echo "$config" >> $root_user/.vimrc grep "$config" ${root_user_path}/.vimrc || echo "$config" >> ${root_user_path}/.vimrc
grep "$config" $default_user/.vimrc || echo "$config" >> $default_user/.vimrc grep "$config" ${default_user_path}/.vimrc || echo "$config" >> ${default_user_path}/.vimrc
done done
# 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 cat > /etc/tmux.conf <<EOL
bind '"' split-window -c "#{pane_current_path}" bind '"' split-window -c "#{pane_current_path}"