#!/bin/bash
# (C) 2013-2019 David 'Mokon' Bond, All Rights Reserved

pushd . &> /dev/null

cd ~

file=`mktemp`
time curl -L -o $file -s \
  https://github.com/mokon/menv/archive/master.tar.gz

tar -xzf $file
/bin/rm -f $file
/bin/mv menv-master menv

find menv/ -not -path "menv/vault/*/*" -and -name .gitkeep -exec rm -rf {} \;

time source ~/menv/core/target_handlers/install

cd menv
git clone --bare https://github.com/mokon/menv .git &> /dev/null
git config --unset core.bare > /dev/null
git reset > /dev/null
git ls-files --deleted -z | git update-index --assume-unchanged -z --stdin > /dev/null
git push --set-upstream origin master &> /dev/null
cd ..

source ~/menv/core/target_handlers/login

popd &> /dev/null