Add option to install without prompting
This commit is contained in:
parent
3a538461f0
commit
8dc0a4b964
42
install.sh
42
install.sh
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#Copyright (C) 2013 Tony Grosinger. All rights reserved.
|
#Copyright (C) 2022 Tony Grosinger. All rights reserved.
|
||||||
#
|
#
|
||||||
#Description:
|
#Description:
|
||||||
# This script can be run in two modes depending on the file structure of the
|
# This script can be run in two modes depending on the file structure of the
|
||||||
@ -34,14 +34,14 @@ fi
|
|||||||
# Define functions
|
# Define functions
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Remove a file if it exists then create a symlink to the one contained in ${REPO_DIR}
|
# Remove a file if it exists then create a symlink to the one contained in ${DOTFILES_DIR}
|
||||||
function linkFile() {
|
function linkFile() {
|
||||||
ln -fns ${REPO_DIR}/$1 $1;
|
ln -fns ${DOTFILES_DIR}/$1 $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove a file if it exists then create a symlink from the file in $HOME/bin to the one contained in ${REPO_DIR}
|
# Remove a file if it exists then create a symlink from the file in $HOME/bin to the one contained in ${DOTFILES_DIR}
|
||||||
function linkBin() {
|
function linkBin() {
|
||||||
ln -fns ${REPO_DIR}/$1 $HOME/bin/$2;
|
ln -fns ${DOTFILES_DIR}/$1 $HOME/bin/$2;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a directory named by first parameter. Delete directory first if it already exists.
|
# Create a directory named by first parameter. Delete directory first if it already exists.
|
||||||
@ -69,7 +69,6 @@ function performSetup() {
|
|||||||
|
|
||||||
echo "Linking shell configs..."
|
echo "Linking shell configs..."
|
||||||
linkFile ".bashrc"
|
linkFile ".bashrc"
|
||||||
ln -fns ${REPO_DIR}/.bashrc .zshrc
|
|
||||||
|
|
||||||
echo "Linking vim..."
|
echo "Linking vim..."
|
||||||
linkFile ".vim"
|
linkFile ".vim"
|
||||||
@ -111,22 +110,26 @@ function performSetup() {
|
|||||||
# Initialize (Determine mode)
|
# Initialize (Determine mode)
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Determine which mode we are running in. (Is the file in the current directory?)
|
# Determine which mode we are running in. (Does the install script exist in the dotfiles directory?)
|
||||||
if [ -f install.sh ]; then
|
if [ -f ${DOTFILES_DIR}/install.sh ]; then
|
||||||
echo "Running in Mode 1: Already cloned repository"
|
echo "Running in Mode 1: Already cloned repository"
|
||||||
REPO_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
||||||
|
|
||||||
echo "This will create symlinks and destroy any conflicting configs already in place.";
|
if [ "${1}" != "-y" ]; then
|
||||||
read -p "Continue? [y/N] " choice
|
echo "This will create symlinks and destroy any conflicting configs already in place.";
|
||||||
|
read -p "Continue? [y/N] " choice
|
||||||
|
|
||||||
# Perform the logic
|
# Perform the logic
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
Y|y|yes )
|
Y|y|yes )
|
||||||
performSetup ${HOME}
|
performSetup ${HOME}
|
||||||
echo "Done! Restart your shell to see changes"
|
echo "Done! Restart your shell to see changes"
|
||||||
;;
|
;;
|
||||||
* ) echo "Aborted!";;
|
* ) echo "Aborted!";;
|
||||||
esac
|
esac
|
||||||
|
else
|
||||||
|
performSetup ${HOME}
|
||||||
|
echo "Done! Restart your shell to see changes"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Running in Mode 2: Direct from Curl"
|
echo "Running in Mode 2: Direct from Curl"
|
||||||
|
|
||||||
@ -163,7 +166,6 @@ else
|
|||||||
curl -L ${REPO_TAR} | tar zx --strip 1 --directory ${DOTFILES_DIR}
|
curl -L ${REPO_TAR} | tar zx --strip 1 --directory ${DOTFILES_DIR}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
REPO_DIR="${DOTFILES_DIR}"
|
|
||||||
performSetup ${HOME}
|
performSetup ${HOME}
|
||||||
echo "Done! Restart your shell to see changes"
|
echo "Done! Restart your shell to see changes"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user