turn of all the safetys

This commit is contained in:
Mark Riedesel 2023-11-13 10:02:47 -06:00
parent 7389489a55
commit 8a60ae1e21

View file

@ -3,11 +3,11 @@
# curl https://raw.github.com/Klowner/dotfiles/main/bin/dotfiles | bash # curl https://raw.github.com/Klowner/dotfiles/main/bin/dotfiles | bash
basedir="${DOTFILES_ROOT:-$HOME/.dotfiles}" basedir="${DOTFILES_ROOT:-$HOME/.dotfiles}"
bindir="${DOTFILES_BIN:-$HOME/bin}" bindir="${DOTFILES_BIN:-$HOME/bin}"
branch="${DOTFILES_BRANCH:-main}"
repo="Klowner/dotfiles" repo="Klowner/dotfiles"
gitbase="git://github.com/${repo}.git" gitbase="git://github.com/${repo}.git"
gitbranch="${DOTFILES_BRANCH:-main}"
gitremote="git@github.com:${repo}" gitremote="git@github.com:${repo}"
tarball="http://github.com/${repo}/tarball/${branch}" tarball="http://github.com/${repo}/tarball/${gitbranch}"
function has() { function has() {
return $(which $1 &> /dev/null) return $(which $1 &> /dev/null)
@ -76,6 +76,28 @@ function link() {
ln -vsf $src $dst 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() { function bootstrap() {
note "Bootstrapping..." note "Bootstrapping..."
if missing curl && missing wget; then if missing curl && missing wget; then
@ -93,10 +115,10 @@ function bootstrap() {
die "Dotfiles already installed!" die "Dotfiles already installed!"
fi fi
fi fi
exit
warn "$basedir exists, moving to ${basedir}.bak" warn "$basedir exists, moving to ${basedir}.bak"
mv "${basedir}" "${basedir}.bak" mv "${basedir}" "${basedir}.bak"
fi fi
install_via_tarball
} }
function install() { function install() {
@ -104,12 +126,13 @@ function install() {
for path in _*; do for path in _*; do
dst=$(destination $path) dst=$(destination $path)
dstdir=$(dirname $dst) dstdir=$(dirname $dst)
echo "$path"
case $path in case $path in
.|..|.git) .|..|.git)
continue continue
;; ;;
*) *)
echo $basedir/$path $HOME/$dst "$dst $dstdir" link $basedir/$path $HOME/$dst
;; ;;
esac esac
done done
@ -118,7 +141,7 @@ function install() {
mkdir -v -p ${bindir} mkdir -v -p ${bindir}
if [ -d ${bindir} ]; then if [ -d ${bindir} ]; then
for path in ${basedir}/bin/*; do for path in ${basedir}/bin/*; do
echo "link" $path ${bindir}/${path##*/} link $path ${bindir}/${path##*/}
done done
fi fi
note "Done" note "Done"
@ -130,7 +153,7 @@ function git_migrate() {
fi fi
if [ ! -d "${basedir}/.git" ]; then if [ ! -d "${basedir}/.git" ]; then
note "Migrating dotfiles to git repository..." 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" git mv "${basedir}/migrate/.git" "${basedir}/.git"
rm -rf "${basedir}/migrate" rm -rf "${basedir}/migrate"
fi fi
@ -151,7 +174,7 @@ function add() {
function info() { function info() {
echo "location: ${basedir}" echo "location: ${basedir}"
echo "commands: ${bindir}" echo "commands: ${bindir}"
echo "git: ${gitremote}" echo "git: ${gitremote}:${gitbranch}"
} }
# Hopefully detect if this script is being piped to bash # Hopefully detect if this script is being piped to bash