From: W. Trevor King Date: Wed, 26 Nov 2008 19:17:40 +0000 (-0500) Subject: Added disconnect.sh and associated elements. X-Git-Tag: v0.3~97 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b26c358f4db2e687f6ad486c693316af80dd1e9e;p=dotfiles-framework.git Added disconnect.sh and associated elements. Now you can stop tracking the central server and restore a standard setup if you want. --- diff --git a/Makefile b/Makefile index d6b5a47..8148548 100644 --- a/Makefile +++ b/Makefile @@ -38,3 +38,7 @@ localdiff: # i.e. What specialization do I want compared to the central .dotfiles localpatch: ./diff.sh > local.patch + +# No Remove this computer from the auto-updates list +disconnect: + ./disconnect.sh diff --git a/_bashrc b/_bashrc index ff9b647..2f775a8 100644 --- a/_bashrc +++ b/_bashrc @@ -157,6 +157,7 @@ if [ -z "$SSH_CLIENT" ]; then fi fi +### ---- begin .dotfiles section ---- (keep this magic comment) # Check for Git (versioning system) so we know how to get our .dotfiles GIT_PATH=`which git` @@ -196,3 +197,5 @@ if [ -d ~/.dotfiles/ ]; then popd fi fi + +### ---- end .dotfiles section ---- (keep this magic comment) diff --git a/disconnect.sh b/disconnect.sh new file mode 100755 index 0000000..d92089c --- /dev/null +++ b/disconnect.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# You're about to give your sysadmin account to some newbie, and +# they'd just be confused by all this efficiency. This script freezes +# your dotfiles in their current state and makes everthing look +# normal. Note that this will delete your ~/.dotfiles directory, and +# strip the .dotfiles portion from your ~/.bashrc file. + +# For each file in this directory. +for file in _*; do + # Create .dotfile version. + dotfile=.${file/_/} + + # Replace symlinks with their target + if [ -h ~/$dotfile ]; then + echo -n "" + #rm -f ~/$dotfile + #mv $file ~/$dotfile + fi +done + +# See if the bashrc file is involved with .dotfiles at all +if [ ! -e _bashrc ]; then + # No _bashrc file, so leave ~/.bashrc alone + exit +fi + +# We may have a dotfiles section in ~/.bashrc. Strip it out. +BC="### ---- begin .dotfiles section ---- (keep this magic comment)" +EC="### ---- end .dotfiles section ---- (keep this magic comment)" +AWKSCRIPT="BEGIN{copy=1}{" +AWKSCRIPT="$AWKSCRIPT if(\$0 == \"$BC\"){copy=0};" +AWKSCRIPT="$AWKSCRIPT if(\$0 == \"$EC\"){copy=1};" +AWKSCRIPT="$AWKSCRIPT if(copy==1 && \$0 != \"$EC\"){print \$0}" +AWKSCRIPT="$AWKSCRIPT}" + +awk "$AWKSCRIPT" ~/.bashrc > bashrc_stripped +# see if the stripped file is any different +DIFF=`diff ~/.bashrc bashrc_stripped` || exit 1 +if [ -n "$DIFF" ] + +rm -f ~/.bashrc +cp bashrc_stripped ~/.bashrc diff --git a/fixup.sh b/fixup.sh index 5a4ad7e..30d6cf6 100755 --- a/fixup.sh +++ b/fixup.sh @@ -162,7 +162,7 @@ NOT_CHANGED="" UPDATED="" ADDED="" -# For each file in this directory. +# For each dotfile in this directory. for file in _*; do # Create .dotfile version. dotfile=.${file/_/}