diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-02-05 10:44:22 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-02-05 10:44:22 -0200 |
commit | 744e7eca5964e766fe78fd2437bf42f3f5b4569c (patch) | |
tree | fc1f9e6c97417858e3c1bc7ca6c12a227f1c03c6 | |
parent | 0f49a67df1cb7d4fdb9d59d0d10fdc089807d9e2 (diff) | |
download | inception-744e7eca5964e766fe78fd2437bf42f3f5b4569c.tar.gz inception-744e7eca5964e766fe78fd2437bf42f3f5b4569c.tar.bz2 |
Do not depend on 'apps' repo name
-rwxr-xr-x | infection | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -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 |