From 8a60ae1e2141a33fb2cfbdd36890112accd907cb Mon Sep 17 00:00:00 2001 From: Mark Riedesel Date: Mon, 13 Nov 2023 10:02:47 -0600 Subject: [PATCH] turn of all the safetys --- bin/dotfiles | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/bin/dotfiles b/bin/dotfiles index 6581a0e..ed8b113 100755 --- a/bin/dotfiles +++ b/bin/dotfiles @@ -3,11 +3,11 @@ # curl https://raw.github.com/Klowner/dotfiles/main/bin/dotfiles | bash basedir="${DOTFILES_ROOT:-$HOME/.dotfiles}" bindir="${DOTFILES_BIN:-$HOME/bin}" -branch="${DOTFILES_BRANCH:-main}" repo="Klowner/dotfiles" gitbase="git://github.com/${repo}.git" +gitbranch="${DOTFILES_BRANCH:-main}" gitremote="git@github.com:${repo}" -tarball="http://github.com/${repo}/tarball/${branch}" +tarball="http://github.com/${repo}/tarball/${gitbranch}" function has() { return $(which $1 &> /dev/null) @@ -76,6 +76,28 @@ function link() { ln -vsf $src $dst } +function install_via_tarball() { + note "Downloading tarball..." + mkdir -vp $basedir + cd $basedir + tempfile=TEMP.tar.gz + if has curl; then + curl -L $tarball >$tempfile + elif has wget; then + wget -O $tempfile $tarball + else: + die "Can't download tarball." + fi + tar --strip-components 1 -xzvf $tempfile + rm -v $tempfile +} + +function install_via_git() { + note "Cloning dotfiles git repository..." + git clone ${gitremote} ${basedir} +} + + function bootstrap() { note "Bootstrapping..." if missing curl && missing wget; then @@ -93,10 +115,10 @@ function bootstrap() { die "Dotfiles already installed!" fi fi - exit warn "$basedir exists, moving to ${basedir}.bak" mv "${basedir}" "${basedir}.bak" fi + install_via_tarball } function install() { @@ -104,12 +126,13 @@ function install() { for path in _*; do dst=$(destination $path) dstdir=$(dirname $dst) + echo "$path" case $path in .|..|.git) continue ;; *) - echo $basedir/$path $HOME/$dst "$dst $dstdir" + link $basedir/$path $HOME/$dst ;; esac done @@ -118,7 +141,7 @@ function install() { mkdir -v -p ${bindir} if [ -d ${bindir} ]; then for path in ${basedir}/bin/*; do - echo "link" $path ${bindir}/${path##*/} + link $path ${bindir}/${path##*/} done fi note "Done" @@ -130,7 +153,7 @@ function git_migrate() { fi if [ ! -d "${basedir}/.git" ]; then note "Migrating dotfiles to git repository..." - git clone $gitremote --no-checkout --branch ${branch} "${basedir}/migrate" + git clone $gitremote --no-checkout --branch ${gitbranch} "${basedir}/migrate" git mv "${basedir}/migrate/.git" "${basedir}/.git" rm -rf "${basedir}/migrate" fi @@ -151,7 +174,7 @@ function add() { function info() { echo "location: ${basedir}" echo "commands: ${bindir}" - echo "git: ${gitremote}" + echo "git: ${gitremote}:${gitbranch}" } # Hopefully detect if this script is being piped to bash