summaryrefslogtreecommitdiffstats
path: root/.mrconfig
blob: 0944498153677b3821b96558d0233988300547e2 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
[DEFAULT]
update = git pull --rebase
lib =
        get_backup_remote() {
            case "$HOSTNAME" in
                mx2)
                    echo extdata
                    ;;
                miminarnb)
                    echo sam500
                    ;;
                *)
                    echo "Unsupported hostname $HOSTNAME!" >&2
                    exit 1
                    ;;
            esac
        }
        get_backup_path() {
            local pth
            local repo=`basename "$MR_REPO"`
            local remote=`get_backup_remote`
            if [[ -z "${remote}" ]]; then
                exit 1
            fi
            local base="/mnt/$remote"
            case "$repo" in
                Videos)
                    pth=movies
                    ;;
                Calibre\ Library)
                    pth=ebooks
                    ;;
                *)
                    pth="${repo,,}"
                    ;;
            esac
            echo "$base/$pth"
        }
        get_checkout_repo() {
            case "$HOSTNAME" in
                mx2)
                    case "$MR_REPO" in
                        Calibre\ Library)
                            echo "/ssh/miminarnb-local/$MR_REPO"
                            ;;
                        *)
                            get_backup_path
                            ;;
                    esac
                    ;;
                miminarnb)
                    echo "ssh://mx2/$MR_REPO"
                    ;;
                *)
                    echo "Unsupported hostname $HOSTNAME!" >&2
                    exit 1
                    ;;
            esac
        }
        annexupdate() {
            git annex sync "$@"
        }
        annexsync() {
            git annex sync "$@"
        }
        annexbackup() {
            local backup_repo="${1:-}"
            local remote
            if [[ -z "${backup_repo:-}" ]]; then
                backup_repo=`get_backup_path`
            fi
            remote=`basename "$backup_repo"`
            local dir=`git remote show "$backup_repo" | sed -n 's/\s*Push\s\+URL\s*:\s*\(.*\)/\1/p'`
            local branch=`git rev-parse --abbrev-ref HEAD`
            if ! git branch -lvv | grep -q '^\*\s*[^[:space:]]\+\s\+.*\[.*\]'; then
                # set remote upstream tracking
                git branch -u "$backup_repo/$branch"
            fi
            if [[ "${dir:0:1}" = '/' ]]; then
                pushd "$dir"
                    git annex sync `hostname`
                    git annex get
                popd
            else
                git push "$backup_repo"
                git copy --to "$backup_repo"
            fi
        }
        annexcheckout() {
            local src="${1:-}"
            local remote=`get_backup_remote`
            if [[ -z "$remote" ]]; then
                exit 1
            fi
            if [[ -z "$src" ]]; then
                src=`get_checkout_repo`
            fi
            git clone "$src" "$MR_REPO"
            pushd "$2"
                git annex init `hostname`
            popd
            git remote rename origin $remote
            git branch -u $remote master
        }

[.rcs]
checkout = git clone 'fedorapeople.org:public_git/rcs.git' '.rcs' && cd .rcs && git submodule update --init --recursive && git submodule foreach git checkout master
fixups = ./make-links

[.vim]
checkout = git clone 'fedorapeople.org:public_git/vim.git' '.vim'
fixups = ./update-plugins -i

[wsp/my/xminad]
checkout = git clone 'fedorapeople.org:public_git/xminad.git' 'xminad'
fixups = make build && make install && make restart

[Videos]
checkout = annexcheckout
aco = annexcheckout
update = annexupdate
backup = annexbackup

[Music]
checkout = annexcheckout
aco = annexcheckout
update = annexupdate --content
backup = annexbackup
fixups = mpc update --wait

[Documents]
checkout = annexcheckout
aco = annexcheckout
update = annexupdate --content
backup = annexbackup

[Calibre Library]
checkout = annexcheckout
    cd Calibre\ Library
    printf '#!/bin/bash\ngit annex edit metadata.db\n' > .git/hooks/post-commit
    chmod a+x .git/hooks/post-commit
    git annex unlock metadata.db
    git config annex.largefiles "include=* exclude=*.opf exclude=*.json"
aco = annexcheckout
update = annexupdate --content
    git annex unlock metadata.db
backup = annexbackup

[/usr/local/bin]
checkout = sudo git clone ssh://root@mx2/usr/local/bin
update = sudo git pull --rebase; sudo git push
backup = sudo git push extdata