#!/bin/sh # Bootstrap home directory after dotfiles repository successfully cloned (see # INSINUATE-DOTFILES Consfigurator property and 'insinuate-dotfiles' script). # This script should be POSIX sh and idempotent. This is the 'mr fixups' # action for src/dotfiles, here rather than in src/dotfiles/lib-src/mr/config # so that we can run it even if we don't have a Perl interpreter. set -e cd "$HOME/src/dotfiles" if [ -d /etc/skel ]; then cd /etc/skel for file in $(find . -type f); do [ -e "$HOME/$file" -a ! -h "$HOME/$file" \ -a -e "$HOME/src/dotfiles/$file" ] \ && cmp "$file" "$HOME/$file" >/dev/null && rm "$HOME/$file" done cd "$HOME/src/dotfiles" fi # On Debian systems root gets a special .bashrc and .profile. for f in bashrc profile; do [ -e /usr/share/base-files/dot.$f \ -a -e "$HOME/.$f" -a ! -h "$HOME/.$f" ] \ && cmp /usr/share/base-files/dot.$f "$HOME/.$f" >/dev/null \ && rm "$HOME/.$f" done # These will often end up created by, e.g., insinuate-dotfiles. # Remove them so that the initial stow will not involve any conflicts. for f in gpg.conf gpg-agent.conf dirmngr.conf .gpg-v21-migrated; do [ -h "$HOME/.gnupg/$f" ] || rm -f "$HOME/.gnupg/$f" done bin/hstow restow . if command -v git >/dev/null; then for branch in $(git for-each-ref \ --format='%(refname:short)' refs/heads/); do git rev-parse "$branch"@{upstream} >/dev/null 2>&1 \ && git branch --unset-upstream "$branch" done # Ensure 'git push-all' non-force pushes master to origin. git config --unset branch.master.pushRemote ||: # Ensure 'git push-all' force pushes localhost's branch to origin. git config branch."$(hostname | sed -e 's#\..*$##')".pushRemote origin # Don't set up any tracking branches, or fetch it. [ -z "$(git remote)" ] \ && git remote add origin https://git.spwhitton.name/dotfiles # Non-POSIX cleanup: eventually drop. rm -f .git/hooks/post-checkout{,_01gpgsign} find bin lib/aid lib/backup lib/perl5 lib/hooks lib/athena lib/bins \ lib/img lib/mr lib/src local/anacron/spool local/mutt \ -type d -empty -delete 2>/dev/null ||: fi cd "$HOME" [ -e .mrconfig ] || cat >.mrconfig <