#!/bin/sh # curl -s https://ldot.de -o dotfiles.sh # cat dotfiles.sh # sh dotfiles.sh echo $* set -e cd . /etc/os-release if [ "${USER}" = "root" ]; then installpkgs="no" for cmd in zsh vim git htop tmux sudo; do cmdpath="$(command -v "${cmd}" 2>/dev/null || true)" if [ -z "${cmdpath}" ]; then installpkgs="yes" fi done if [ "${installpkgs}" = "yes" ]; then if [ -e "/usr/bin/pacman" ]; then pacman -S --noconfirm zsh vim git htop tmux sudo elif [ -e "/usr/bin/apt-get" ]; then apt-get install zsh vim git htop tmux sudo else echo "Unknown package manager, can't install dependencies" fi fi fi if [ -e ".dotfiles" ]; then if [ -e ".dotfiles/.git" ]; then (cd .dotfiles && git pull) fi else git clone https://github.com/lukas2511/dotfiles.git .dotfiles for oldfile in .zshrc .vimrc .gitconfig; do if [ -e "${oldfile}" ]; then if [ ! -e ".dotfiles/_oldshit" ]; then echo "Old configurations will be stored under .dotfiles/_oldshit" mkdir -p .dotfiles/_oldshit echo "_oldshit" >> .dotfiles/.git/info/exclude fi mv -v "${oldfile}" .dotfiles/_oldshit/ fi done ln -s ~/.dotfiles/zshrc .zshrc echo 'source ~/.dotfiles/vimrc' > .vimrc mkdir -p .vimbackup ln -s ~/.dotfiles/git/config .gitconfig fi ZSH="$(command -v zsh 2>/dev/null || true)" CURSH="$(getent passwd root | cut -d':' -f7)" if [ -n "${ZSH}" ] && [ ! "${ZSH}" = "${CURSH}" ]; then echo "Changing login shell to zsh" chsh -s "${ZSH}" root fi if [ -e ".lukas2511" ] || [ -e "/home/lukas2511" ] || (getent passwd lukas2511 >/dev/null); then echo "User lukas2511 detected, installing ssh keys in 5 seconds, ctrl+c to abort" sleep 5 mkdir -p .ssh for key in 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH7W3NIGeEGRHu63+dP7s6M5/s0uHODI4QV2Y1yOzDEq'; do if [ ! -e .ssh/authorized_keys ] || ! grep -q "${key}" .ssh/authorized_keys; then echo "Adding: ${key}" echo "${key}" >> .ssh/authorized_keys fi done fi