Add web-based installer

This should allow my dotfiles to be installed by simply running curl and piping into bash
This commit is contained in:
David Todd (c0de) 2018-05-16 21:05:52 -05:00
parent b7ac358290
commit e464fdce93

View File

@ -1,66 +1,101 @@
#!/bin/bash #!/usr/bin/env bash
# This file will attempt to automatically configure and install my dotfiles # This ensures that the entire script is downloaded before execution
# This assumes that the following are already installed and in the PATH; perhaps we will attempt to auto-install them in the future {
# tmux
# vim # Change this url to point to your repo if you made customizations
# zsh repourl="git://github.com/alopexc0de/dotfiles.git"
# curl
# git # Exit the script if any errors are encountered
# php 5.3 or greater set -e
basedir=$HOME/dotfiles
bindir=$HOME/bin
postinst=$HOME/.dotfiles.postinst
# Attempts to safely install the configs as symlinks (backing up existing ones)
function symlink() {
src=$1
dest=$2
if [ -e $dest ]; then
if [ -L $dest ]; then
# Already symlinked -- I'll assume correctly.
return
else
# Rename files with a ".old" extension.
echo "$dest already exists, renaming to $dest.old"
backup=$dest.old
if [ -e $backup ]; then
echo "Error: $backup already exists. Please delete or rename it."
exit 1
fi
mv -v $dest $backup
fi
fi
ln -sf $src $dest
}
echo "Please ensure that the following packages are installed and available in your PATH before proceeding:" echo "Please ensure that the following packages are installed and available in your PATH before proceeding:"
echo "tmux, vim, zsh, curl, git" echo "tmux, vim, zsh, curl, git"
read -p "Press enter to continue. " WAIT_FOR_INPUT read -p "Press enter to continue. " WAIT_FOR_INPUT
# First things first, install oh-my-zsh if ! which git >>/dev/null ; then
echo "Error: git is not installed"
exit 1
fi
# If the update script exists, try to do a normal update
if [ -x "$basedir/check_for_upgrade.sh" ]; then
source "$basedir/shell/env"
env _DOTFILES=$basedir DISABLE_UPDATE_PROMPT='FALSE' zsh -f $basedir/check_for_upgrade.sh
else
echo "Cloning dotfiles to $basedir"
rm -rf $basedir
git clone --quiet --depth=1 $repourl $basedir
fi
# Start installing config
echo "Installing Oh-My-ZSH" echo "Installing Oh-My-ZSH"
echo "When the install is done, type `exit` to continue installing dotfiles" echo "When the install is done, type `exit` to continue installing dotfiles"
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
echo "Overriding ~/.zshrc. A backup can be found at ~/.zshrc.backup" echo "Creating Symlinks"
mv ~/.zshrc ~/.zshrc.backup symlink $basedir/shell/zshrc $HOME/.zshrc
ln -s ~/dotfiles/shell/zshrc ~/.zshrc symlink $basedir/shell/bashrc $HOME/.bashrc
symlink $basedir/tmux.conf $HOME/.tmux.conf
echo "Overriding ~/.bashrc. A backup can be found at ~/.bashrc.backup" symlink $basedir/vimrc $HOME/.vimrc
mv ~/.bashrc ~/.bashrc.backup symlink $basedir/gitconfig $HOME/.gitconfig
ln -s ~/dotfiles/shell/bashrc ~/.bashrc
echo "Installing tmux config"
ln -s ~/dotfiles/tmux.conf ~/.tmux.conf
echo "Installing VIM Pathogen" echo "Installing VIM Pathogen"
mkdir -p ~/.vim/autoload ~/.vim/bundle mkdir -p $HOME/.vim/autoload $HOME/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim curl -LSso $HOME/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
echo "Installing VIM Sensible" echo "Installing VIM Sensible"
cd ~/.vim/bundle cd $HOME/.vim/bundle
git clone git://github.com/tpope/vim-sensible.git git clone git://github.com/tpope/vim-sensible.git
echo "Installing VIM config" echo "Adding user bin"
ln -s ~/dotfiles/vimrc ~/.vimrc mkdir -p $bindir $basedir/.bin
for path in bin/* ; do
echo "Installing (user) global git config" symlink $basedir/$path $bindir/$(basename $path)
ln -s ~/dotfiles/gitconfig ~/.gitconfig done
echo "Changing default shell to ZSH" echo "Changing default shell to ZSH"
chsh -s /usr/bin/zsh chsh -s /usr/bin/zsh
# Make the install directories if [ -e "$postinst" ]; then
echo "Making install directories" echo "Running post install"
mkdir -p ~/bin ~/dotfiles/.bin source "$postinst"
else
# Install wp-cli echo "No post install script found. Optionally create one at $postinst"
# echo "Installing wp-cli" fi
# cd ~/dotfiles/.bin
# curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
# chmod a+x wp-cli.phar
# ln -s ~/dotfiles/.bin/wp-cli.phar ~/bin/wp
# Since $HOME/bin is in the PATH, this should work
# wp --info
echo "Install done." echo "Install done."
echo "Check tmux, vim, and your shell to verify everything is correct" echo "Check tmux, vim, and your shell to verify everything is correct"
echo "you may need to launch a new instance of your shell" echo "you may need to launch a new instance of your shell"
} # Ensures that the whole script is downloaded before execution