]> gitweb.fluxo.info Git - inception.git/commitdiff
Do not depend on 'apps' repo name
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 5 Feb 2018 12:44:22 +0000 (10:44 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 5 Feb 2018 12:44:22 +0000 (10:44 -0200)
infection

index 12e7f9f9d7b265bcb429fe3962d4dd8053f5db7a..c326e82201b21eba51e6e625650ee5977bad3b32 100755 (executable)
--- 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 <<EOF
       ##### BEGIN REMOTE SCRIPT #####
-      \$HOME/apps/infection load
+      \$HOME/$SHORTNAME/infection load
       for module in $MODULES; do
-        \$HOME/apps/metadot/metadot load \$module
+        \$HOME/$SHORTNAME/metadot/metadot load \$module
       done
       ##### END REMOTE SCRIPT #######
 EOF