From 0b7cfa2c81da8cc1a435620eabdd772a25de0f1f Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Fri, 18 Feb 2022 12:29:23 -0600 Subject: check for required binaries and support wget or curl --- deploy.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/deploy.sh b/deploy.sh index c89e7aa..17fd382 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,9 +1,25 @@ #!/bin/bash -set -euo pipefail +set -eo pipefail mkdir -p dotfiles-backup +if command -v unzip > /dev/null; then + UNZIPCMD="unzip" +fi +if command -v vim > /dev/null; then + VIMCMD="vim" +fi +if command -v wget > /dev/null; then + DLCMD="wget -O" +elif command -v curl > /dev/null; then + DLCMD="curl -o" +fi +if [ -z "$UNZIPCMD" ] || [ -z "$VIMCMD" ] || [ -z "$DLCMD" ]; then + echo "requires 'unzip', 'vim', and either 'wget' or 'curl'" + exit 1 +fi + # XDG layout xcache="${XDG_CACHE_HOME:-${HOME}/.cache}" xdata="${XDG_DATA_HOME:-${HOME}/.local/share}" @@ -54,9 +70,9 @@ cd .. # install vim-plug if [ ! -e "$HOME/.vim/autoload/plug.vim" ]; then mkdir -p "$HOME/.vim/autoload" - curl -o "$HOME/.vim/autoload/plug.vim" \ + $DLCMD "$HOME/.vim/autoload/plug.vim" \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - vim +PlugInstall +qall + $VIMCMD +PlugInstall +qall fi # create local files @@ -84,8 +100,8 @@ function get_font { local font_dir="$HOME/.local/share/fonts/$font_name" mkdir -p "$font_dir" if [ ! -d "$font_dir" ] || [ -z "$(ls -A "$font_dir" 2> /dev/null)" ]; then - curl -o "$font_dir/font.zip" "$font_url" - unzip "$font_dir/font.zip" "$@" -d "$font_dir" + $DLCMD "$font_dir/font.zip" "$font_url" + $UNZIPCMD "$font_dir/font.zip" "$@" -d "$font_dir" rm "$font_dir/font.zip" new_font=1 fi -- cgit v1.2.3