diff options
author | kylo252 <[email protected]> | 2022-03-10 10:14:55 +0100 |
---|---|---|
committer | kylo252 <[email protected]> | 2022-03-10 10:14:55 +0100 |
commit | e6ececed172de963572f11cfecdaf5f60c55cf32 (patch) | |
tree | f3846508a94a5760e87bf4a970536bcd5ffea6b7 /utils/installer/install.sh | |
parent | 3abb0a7350392a4a02f970e8636dcb167c1ba53c (diff) | |
parent | f1779fddcc34a8ad4cd0af0bc1e3a83f42844dbe (diff) |
Merge branch 'rolling'1.1.2
Diffstat (limited to 'utils/installer/install.sh')
-rwxr-xr-x | utils/installer/install.sh | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 13679367..6aca4ca9 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -25,6 +25,7 @@ readonly BASEDIR declare ARGS_LOCAL=0 declare ARGS_OVERWRITE=0 declare ARGS_INSTALL_DEPENDENCIES=1 +declare INTERACTIVE_MODE=1 declare -a __lvim_dirs=( "$LUNARVIM_CONFIG_DIR" @@ -45,10 +46,11 @@ function usage() { echo "Usage: install.sh [<options>]" echo "" echo "Options:" - echo " -h, --help Print this help message" - echo " -l, --local Install local copy of LunarVim" - echo " --overwrite Overwrite previous LunarVim configuration (a backup is always performed first)" - echo " --[no]-install-dependencies Whether to prompt to install external dependencies (will prompt by default)" + echo " -h, --help Print this help message" + echo " -l, --local Install local copy of LunarVim" + echo " -y, --yes Disable confirmation prompts (answer yes to all questions)" + echo " --overwrite Overwrite previous LunarVim configuration (a backup is always performed first)" + echo " --[no]-install-dependencies Whether to automatically install external dependencies (will prompt by default)" } function parse_arguments() { @@ -60,6 +62,9 @@ function parse_arguments() { --overwrite) ARGS_OVERWRITE=1 ;; + -y | --yes) + INTERACTIVE_MODE=0 + ;; --install-dependencies) ARGS_INSTALL_DEPENDENCIES=1 ;; @@ -93,17 +98,23 @@ function main() { check_system_deps if [ "$ARGS_INSTALL_DEPENDENCIES" -eq 1 ]; then - msg "Would you like to install LunarVim's NodeJS dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps - - msg "Would you like to install LunarVim's Python dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_python_deps - - msg "Would you like to install LunarVim's Rust dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps + if [ "$INTERACTIVE_MODE" -eq 1 ]; then + msg "Would you like to install LunarVim's NodeJS dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps + + msg "Would you like to install LunarVim's Python dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_python_deps + + msg "Would you like to install LunarVim's Rust dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps + else + install_nodejs_deps + install_python_deps + install_rust_deps + fi fi backup_old_config @@ -310,30 +321,29 @@ function verify_lvim_dirs() { } function backup_old_config() { - for dir in "${__lvim_dirs[@]}"; do - if [ ! -d "$dir" ]; then - continue - fi - mkdir -p "$dir.bak" - touch "$dir/ignore" - msg "Backing up old $dir to $dir.bak" - if command -v rsync &>/dev/null; then - rsync --archive -hh --stats --partial --copy-links --cvs-exclude "$dir"/ "$dir.bak" - else - OS="$(uname -s)" - case "$OS" in - Linux | *BSD) - cp -r "$dir/"* "$dir.bak/." - ;; - Darwin) - cp -R "$dir/"* "$dir.bak/." - ;; - *) - echo "OS $OS is not currently supported." - ;; - esac - fi - done + local src="$LUNARVIM_CONFIG_DIR" + if [ ! -d "$dir" ]; then + return + fi + mkdir -p "$src.old" + touch "$src/ignore" + msg "Backing up old $src to $src.old" + if command -v rsync &>/dev/null; then + rsync --archive -hh --stats --partial --copy-links --cvs-exclude "$src"/ "$src.old" + else + OS="$(uname -s)" + case "$OS" in + Linux | *BSD) + cp -r "$src/"* "$src.old/." + ;; + Darwin) + cp -R "$src/"* "$src.old/." + ;; + *) + echo "OS $OS is not currently supported." + ;; + esac + fi msg "Backup operation complete" } |