Skip to content

Instantly share code, notes, and snippets.

@stouset
Created April 25, 2011 19:38
Show Gist options
  • Save stouset/941056 to your computer and use it in GitHub Desktop.
Save stouset/941056 to your computer and use it in GitHub Desktop.
Profile update script
#!/bin/bash
# include profile location variables
. ~/.profile
. ~/.profile.git/profile-env
# update ourself
(cd $DOT_PROFILE && git pull)
# symlink all home.d files into place
for FILE in $(find $PROFILE_HOME_D -type f -o -type l); do
FILE=${FILE#$PROFILE_HOME_D/}
DIR=$(dirname $FILE)
echo "# ln -sf $PROFILE_HOME_D/$FILE ~/$FILE"
mkdir -p ~/$DIR
ln -sf $PROFILE_HOME_D/$FILE ~/$FILE
done
# remove stale symlinks
for DIR in $(find $PROFILE_HOME_D -type d); do
DIR=${DIR#$PROFILE_HOME_D}
DIR=${DIR#/}
for SYMLINK in $(find ~/$DIR -maxdepth 1 -type l); do
if [ ! -e $SYMLINK ]; then
echo "# rm -i $SYMLINK (stale symlink)"
rm -i $SYMLINK
fi
done
done
# perform OS-specific tasks
for FILE in $(find $PROFILE_SYSTEM_D/$SYSTEM_BASE.d -type f -o -type l); do
if [ -x $FILE ]; then
echo "# eval $FILE"
eval $FILE
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment