turn of all the safetys
This commit is contained in:
parent
7389489a55
commit
8a60ae1e21
1 changed files with 30 additions and 7 deletions
37
bin/dotfiles
37
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue