From 744e7eca5964e766fe78fd2437bf42f3f5b4569c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 5 Feb 2018 10:44:22 -0200 Subject: Do not depend on 'apps' repo name --- infection | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/infection b/infection index 12e7f9f..c326e82 100755 --- a/infection +++ b/infection @@ -6,6 +6,7 @@ # Parameters BASENAME="`basename $0`" DIRNAME="$(cd `dirname $0`/.. &> /dev/null && pwd)" +SHORTNAME="$(echo $DIRNAME | sed -e "s|$HOME/||")" EXCLUDES="--exclude=local --exclude=stowpkg/tree" DATE="`date +%Y%m%d%I%M%S`" BACKUPS="$HOME/.backups/$DATE" @@ -22,6 +23,12 @@ function infection_usage { # Initialize function infection_init { ( + # Check if repo is inside $HOME + if [ "$DIRNAME" != "$HOME/$SHORTNAME" ]; then + echo "Please make sure $DIRNAME is moved to $HOME" + exit 1 + fi + cd $DIRNAME &> /dev/null echo "Initializing submodules..." @@ -31,16 +38,16 @@ function infection_init { # 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/apps/dotfiles" ]; then + # once the integrity of the repo is checked + if [ -e "$DIRNAME/dotfiles" ]; then if [ -e "$HOME/.dotfiles" ]; then - if [ ! -h "$HOME/.dotfiles" ] || [ "`readlink $HOME/.dotfiles`" != "apps/dotfiles" ]; then + if [ ! -h "$HOME/.dotfiles" ] || [ "`readlink $HOME/.dotfiles`" != "$SHORTNAME/dotfiles" ]; then mkdir -p $BACKUPS mv $HOME/.dotfiles $BACKUPS/ - ( cd $HOME &> /dev/null && ln -s apps/dotfiles .dotfiles ) + ( cd $HOME &> /dev/null && ln -s $SHORTNAME/dotfiles .dotfiles ) fi else - ( cd $HOME &> /dev/null && ln -s apps/dotfiles .dotfiles ) + ( cd $HOME &> /dev/null && ln -s $SHORTNAME/dotfiles .dotfiles ) fi fi @@ -113,9 +120,9 @@ function infection_deploy { REMOTE="$2" MODULES="`$DIRNAME/metadot/metadot installed | xargs`" - # Sync apps - if [ -e "$HOME/apps" ]; then - rsync -avz --delete $EXCLUDES $HOME/apps/ $REMOTE:apps/ + # Sync repo + if [ -e "$HOME/$SHORTNAME" ]; then + rsync -avz --delete $EXCLUDES $HOME/$SHORTNAME/ $REMOTE:$SHORTNAMR/ fi # Sync dotfiles @@ -126,9 +133,9 @@ function infection_deploy { # Sync loaded modules ssh -T $REMOTE <