dotfiles/common/configure_fresh_system
2016-11-01 14:35:53 +01:00

186 lines
4.2 KiB
Bash
Executable file

#!/bin/bash
SUDO=""
if [[ -z $NOSUDO ]]; then
SUDO="sudo"
fi
echo "using '$SUDO' as sudo"
set -e
echo
echo "configuring settings common among OSes"
$SUDO true
#zsh
if [[ -z $DONT_CHANGE_SHELL ]]; then
echo "changing shell to zsh"
chsh -s `which zsh` $USER
fi
CURL="curl -sSf"
jobs_count=`nproc`
if [[ -z $DIR ]]; then
echo "please set DIR"
exit 1
fi
DIR=`realpath $DIR`
echo "using $DIR as the top level directory"
cd $DIR
git submodule update --init --recursive
#configs
ln -vfs "$DIR/.vim" ~/.
ln -vfs "$DIR/.vimrc.linux" ~/.vimrc
ln -vfs "$DIR/.tmux.conf" ~/.
rm -f "~/.zshrc"
ln -vfs "$DIR/.zshrc" ~/.
ln -vfs "$DIR/.setenv" ~/.
ln -vfs "$DIR/.oh-my-zsh" ~/.
ln -vfs "$DIR/.oh-my-zsh-plugins/zsh-syntax-highlighting" ~/.oh-my-zsh/custom/plugins/
ln -vfs "$DIR/.Slic3r" ~/.
ln -vfs "$DIR/.ghci" ~/.
ln -vfs "$DIR/.conkyrc" ~/.
mkdir -p ~/.kde/share/config/
ln -vfs "$DIR/.kdiff3rc" ~/.kde/share/config/kdiff3rc
ln -vfs "$DIR/.gitconfig.linux.private" ~/.gitconfig
mkdir -p ~/.config/autostart/
# autostart apps
ln -vfs "$DIR/.config/autostart/redshift-gtk.desktop" ~/.config/autostart/
mkdir -p ~/.config/vdirsyncer/
ln -vfs "$DIR/.config/vdirsyncer/config" ~/.config/vdirsyncer/
ln -vfs "$DIR/.config/redshift.conf" ~/.config/redshift.conf
source ~/.setenv
# symlink 'nodejs' as node on some systems
# will replace symlink if it exists, but won't replace regular file
if [[ ! -f /usr/bin/node ]]; then
$SUDO ln -vfs /usr/bin/nodejs /usr/bin/node
fi
# tools
ln -vfs "$DIR/tools" ~/
# stuff that does not like symbolic links
mkdir -vp ~/.config/terminator
rm -f ~/.config/terminator/config
ln "$DIR/.config/terminator/config" ~/.config/terminator/config
#install fonts
mkdir -p ~/.fonts
cp -rv "$DIR/fonts" ~/.fonts
set +e
fc-cache -rv
$SUDO fc-cache -rv
set -e
if [[ -z $NORUST ]]; then
#rust
echo "installing rust"
RUSTUP_TEMP="/tmp/blastoff.sh"
$CURL https://sh.rustup.rs > "$RUSTUP_TEMP"
chmod a+x "$RUSTUP_TEMP"
"$RUSTUP_TEMP" -y
rm -f "$RUSTUP_TEMP"
rustup update
rustup default stable
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
cd "$DIR/../"
echo "getting rust sources..."
if [[ ! -d rust ]]; then
git clone https://github.com/rust-lang/rust.git --recursive
else
cd rust
git pull
git submodule update --init --recursive
fi
set +e
cargo install rustfmt
cargo install racer
cargo install rustsym
cargo install ripgrep
set -e
fi
set +e
echo "Querying for gpg2 path"
gpg2_path=`which gpg2`
echo "Got $gpg2_path for gpg2 path"
echo set -e
if [[ -x gpg2_path ]]; then
echo "Using gpg2"
GPG=gpg2
else
echo "WARNING using gpg instead of gpg2"
GPG=gpg
fi
if [[ -z $NORUBY ]]; then
$GPG --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable --ruby
fi
if [[ -z $NOVIM ]]; then
if [[ ! -d ~/.fzf ]]; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
else
cd ~/.fzf
git pull
git submodule update --init --recursive
fi
echo "Installing fzf"
~/.fzf/install --64 --all
echo "Installing Vim plugins"
echo "\n" | vim +PluginInstall +qa
if [[ -z $NOYCM ]]; then
"Echo configuring YouCompleteMe"
cd ~/.vim/bundle/YouCompleteMe
if [[ -z $NOPYTHON3 ]]; then
python3 ./install.py --clang-completer --racer-completer --tern-completer
else
python ./install.py --clang-completer --racer-completer --tern-completer
fi
fi
fi
if [[ -z $NO_GO ]]; then
export GOPATH="$HOME/go"
mkdir -p "$GOPATH"
# excercism
go get -u github.com/exercism/cli/exercism
fi
echo "Installing Reveal-md"
# talks: reveal-md
$SUDO npm install -g reveal-md
echo "Installing fancy differ"
$SUDO npm install -g diff-so-fancy
if [[ -z $NOPYTHON3 ]]; then
PIP=pip3
else
PIP=pip
fi
echo "Installing Nikola"
$SUDO $PIP install pygments-style-solarized ws4py watchdog webassets Nikola
if [[ -z $USER ]]; then
USER=`whoami`
fi
# normalize npm permissions
mkdir -p $HOME/.npm
$SUDO chown $USER $HOME/.npm -R
echo
echo "now go ahead and restart"
echo