summaryrefslogtreecommitdiff
path: root/bin/bstraph.sh
blob: 8123bb7d15ec4cc70d33cba439d488946af18b48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh

. $HOME/src/dotfiles/.shenv

# Bootstrap home directory after dotfiles repository successfully
# cloned (see ~/bin/insinuate-dotfiles).  This script should
# definitely be POSIX sh

set -e

# ---- Perform the bootstrap

if ! [ -e "$HOME/.mrconfig" ]; then
    cat >"$HOME/.mrconfig" <<EOF
# -*- mode: conf -*-

include = cat ~/src/dotfiles/lib-src/mr/config
EOF
fi
(
    cd $HOME/src/dotfiles
    mr fixups
    mr stow

    if [ -z $(git remote) ]; then
        # don't set up any tracking branches or fetch it
        git remote add origin athena:dotfiles
    fi
)

echo "I: dotfiles bootstrap successful"

# ---- Check if there is a host-specific branch

hostname="$(hostname -s)"
if ! [ "$hostname" = "master" ] \
        && ( cd "$HOME/src/dotfiles" && git branch -a | grep "origin/$hostname" ); then
    echo "I: there is a host-specific dotfiles branch for this host"
    echo "I: consider checking it out"
fi