Improve portability of hosted bootstrap curl-pipe
This commit is contained in:
parent
375a34b97a
commit
dc699e0b4e
1 changed files with 22 additions and 11 deletions
33
bootstrap
33
bootstrap
|
@ -4,6 +4,8 @@
|
||||||
# This script can be "curl-piped" into bash to bootstrap a dotfiles repo when
|
# This script can be "curl-piped" into bash to bootstrap a dotfiles repo when
|
||||||
# yadm is not locally installed. Read below for instructions.
|
# yadm is not locally installed. Read below for instructions.
|
||||||
#
|
#
|
||||||
|
# This script is hosted at bootstrap.yadm.io to make it easy to remember/type.
|
||||||
|
#
|
||||||
# DISCLAIMER: In general, I would advise against piping someone's code directly
|
# DISCLAIMER: In general, I would advise against piping someone's code directly
|
||||||
# from the Internet into an interpreter (like Bash). You should
|
# from the Internet into an interpreter (like Bash). You should
|
||||||
# probably review any code like this prior to executing it. I leave
|
# probably review any code like this prior to executing it. I leave
|
||||||
|
@ -13,29 +15,38 @@
|
||||||
# (allowing the yadm project to be a submodule of my dotfiles
|
# (allowing the yadm project to be a submodule of my dotfiles
|
||||||
# repo).
|
# repo).
|
||||||
#
|
#
|
||||||
# Invoke with:
|
# Invoke bootstrap with:
|
||||||
#
|
#
|
||||||
# curl -fsSL 'https://tinyurl.com/yadm-bootstrap' | bash
|
# curl -L bootstrap.yadm.io | bash
|
||||||
#
|
#
|
||||||
# OR
|
# OR
|
||||||
|
#
|
||||||
|
# curl -L bootstrap.yadm.io | bash [-s -- REPO_URL [YADM_RELEASE]]
|
||||||
|
#
|
||||||
|
# Alternatively, source in this file to export a yadm() function which uses
|
||||||
|
# yadm remotely until it is locally installed.
|
||||||
|
#
|
||||||
|
# source <(curl -L bootstrap.yadm.io)
|
||||||
#
|
#
|
||||||
# curl -fsSL 'https://github.com/TheLocehiliosan/yadm/raw/master/bootstrap' | bash [-s -- REPO_URL [YADM_RELEASE]]
|
|
||||||
|
|
||||||
YADM_REPO="https://github.com/TheLocehiliosan/yadm"
|
YADM_REPO="https://github.com/TheLocehiliosan/yadm"
|
||||||
YADM_RELEASE="master"
|
YADM_RELEASE=${release:-master}
|
||||||
REPO_URL=""
|
REPO_URL=""
|
||||||
|
|
||||||
function yadm() {
|
function _private_yadm() {
|
||||||
if command -v which >/dev/null 2>&1 && which yadm >/dev/null 2>&1; then
|
unset -f yadm
|
||||||
|
if command -v yadm >/dev/null 2>&1; then
|
||||||
echo "Found yadm installed locally, removing remote yadm() function"
|
echo "Found yadm installed locally, removing remote yadm() function"
|
||||||
unset -f yadm
|
unset -f _private_yadm
|
||||||
command yadm "$@"
|
command yadm "$@"
|
||||||
else
|
else
|
||||||
|
function yadm() { _private_yadm "$@"; }; export -f yadm
|
||||||
echo WARNING: Using yadm remotely. You should install yadm locally.
|
echo WARNING: Using yadm remotely. You should install yadm locally.
|
||||||
curl -fsSL "$YADM_REPO/raw/$YADM_RELEASE/yadm" | bash -s -- "$@"
|
curl -fsSL "$YADM_REPO/raw/$YADM_RELEASE/yadm" | bash -s -- "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
export -f yadm
|
export -f _private_yadm
|
||||||
|
function yadm() { _private_yadm "$@"; }; export -f yadm
|
||||||
|
|
||||||
# if being sourced, return here, otherwise continue processing
|
# if being sourced, return here, otherwise continue processing
|
||||||
return 2>/dev/null
|
return 2>/dev/null
|
||||||
|
@ -51,13 +62,13 @@ function ask_about_source() {
|
||||||
echo "***************************************************"
|
echo "***************************************************"
|
||||||
echo "yadm is NOT currently installed."
|
echo "yadm is NOT currently installed."
|
||||||
echo "You should install it locally, this link may help:"
|
echo "You should install it locally, this link may help:"
|
||||||
echo "https://thelocehiliosan.github.io/yadm/docs/install"
|
echo "https://yadm.io/docs/install"
|
||||||
echo "***************************************************"
|
echo "***************************************************"
|
||||||
echo
|
echo
|
||||||
echo "If installation is not possible right now, you can temporarily \"source\""
|
echo "If installation is not possible right now, you can temporarily \"source\""
|
||||||
echo "in a yadm() function which fetches yadm remotely each time it is called."
|
echo "in a yadm() function which fetches yadm remotely each time it is called."
|
||||||
echo
|
echo
|
||||||
echo " source <(curl -fsSL '$YADM_REPO/raw/$YADM_RELEASE/bootstrap')"
|
echo " source <(curl -L bootstrap.yadm.io)"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue