1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-09-19 09:04:06 -07:00

add fallback when sh/obtain is missing

This commit is contained in:
Connor Olding 2024-07-04 20:17:30 -07:00
parent 1d896f6539
commit d8652a8ebd

16
update
View file

@ -28,11 +28,21 @@ die() {
backup="backup-$(date -u +%s)" || die 'failed to determine date' backup="backup-$(date -u +%s)" || die 'failed to determine date'
# load libraries. if ! [ -e sh/obtain ]; then
# TODO: write a simple fallback when the library is missing! url=https://eaguru.guru/git/notwa/rc/raw/branch/master/sh/obtain
if curl 2>&-; [ $? = 2 ]; then acquire() { curl -fsS -m45 -o- "$*" ;}
elif wget 2>&-; [ $? = 1 ]; then acquire() { wget -qt1 -T45 -O- "$*" ;}
else die '"sh/obtain" missing, curl and wget missing as well'
fi
mkdir -p sh || die 'failed to create "sh" directory'
acquire "$url" > sh/obtain && chmod +x sh/obtain ||
die 'failed to acquire "sh/obtain"'
fi
dummy() { :; } dummy() { :; }
preload=dummy preload=dummy
. sh/obtain (. sh/obtain) || die 'failed to import "sh/obtain"'
. sh/obtain || exit
__obtain_prep __obtain_prep