From aa0fae61a2f6e2fc501dfd3fe5e041f41bdca60d Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 25 Dec 2017 23:07:38 -0200 Subject: Manage dotfiles inside this repo --- inception | 57 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 17 deletions(-) (limited to 'inception') diff --git a/inception b/inception index 6bd7127..3bb9d78 100755 --- a/inception +++ b/inception @@ -7,6 +7,8 @@ BASENAME="`basename $0`" DIRNAME="$(cd `dirname $0` &> /dev/null && pwd)" EXCLUDES="--exclude=local --exclude=stowpkg/tree" +DATE="`date +%Y%m%d%I%M%S`" +BACKUPS="$HOME/.backups/$DATE" # Make sure we're running git directly and not any existing wrapper GIT="/usr/bin/git" @@ -26,14 +28,25 @@ function inception_init { $GIT submodule sync --recursive $GIT submodule update --init --recursive - if [ ! -e "$HOME/.dotfiles" ]; then - echo "Cloning default dotfiles..." - ./metadot/metadot clone default - else - echo "Updating dotfiles..." - ./metadot/metadot fetch + # Convert to new dotfiles layout + # + # This way we can easily check the integrity of our dotfiles + # once the integrity of the apps repo is checked + if [ -e "$HOME/.dotfiles" ]; then + if [ ! -h "$HOME/.dotfiles" ] || [ "`readlink $HOME/.dotfiles`" != "apps/dotfiles" ]; then + mv $HOME/.dotfiles $BACKUPS/ + ( cd $HOME && ln -s $HOME/apps/dotfiles .dotfiles ) + fi fi + #if [ ! -e "$HOME/.dotfiles" ]; then + # echo "Cloning default dotfiles..." + # ./metadot/metadot clone default + #else + # echo "Updating dotfiles..." + # ./metadot/metadot fetch + #fi + #echo "Checking latest tag..." #cd $HOME/.dotfiles #$DIRNAME/utils-git/git-check-tag @@ -41,13 +54,15 @@ function inception_init { #echo "Checking out the latest tag..." #$DIRNAME/utils-git/git-checkout-tag - echo "Checking dotfiles..." - $DIRNAME/metadot/metadot version + #echo "Checking dotfiles..." + #$DIRNAME/metadot/metadot version ) - echo "" - echo "Please manually verify dotfiles version and tag from the above output." - echo "If everything is fine, proceed running this command again with the 'load' parameter." + #echo "" + #echo "Please manually verify dotfiles version and tag from the above output." + #echo "If everything is fine, proceed running this command again with the 'load' parameter." + + cd - } # Load @@ -65,7 +80,7 @@ function inception_load { if [ "$DEPENDENCIES" == "--deps" ]; then ./metadot/metadot deps --all fi - elif [ -z "$BUNDLE" ]; then + elif [ ! -z "$BUNDLE" ]; then echo "Loading $BUNDLE dotfiles..." ./metadot/metadot load-bundle $BUNDLE @@ -80,7 +95,7 @@ function inception_load { # Install function inception_install { - $0 init + #$0 init $0 load $* } @@ -106,6 +121,7 @@ function inception_deploy { # Sync loaded modules ssh -T $REMOTE <