summaryrefslogtreecommitdiff
path: root/tools/sync-rpi-config.sh
blob: f09b1701b08fcec952c45ef89f574adabfc82d20 (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
#!/bin/bash

repo=/tmp/rpi-config
device=${1}

if [ ! -d /tmp/rpi-config/.git ]; then
        cd /tmp
        su ctibor --command "/usr/bin/git clone --depth 1 ssh://git@git.brancik.cz/rpi-config.git"
        su ctibor --command "/usr/bin/git config --global user.name \"Ctibor Brančík\""
        su ctibor --command "/usr/bin/git config --global user.email \"ctibor@brancik.cz\""
fi

if [ $# != 2 ]; then
        echo "Usage sync-rpi-config <device> <action>. Action can be either push or pull."
        exit 1;
fi

case $1 in
        alcor-01|alcor-02|alcor-03)
        root="/usr/armv6j-hardfloat-linux-gnueabi/";;
        mizar)
        root="/usr/armv7a-hardfloat-linux-gnueabi/";;
        alioth)
        root="/usr/aarch64-unknown-linux-gnu/";;
        *)
        echo "Usage sync-rpi-config <device> <action>."
        exit 1;;
esac

case $2 in
        push)
        echo "Pushing config files to overlay folder ..."
        /usr/bin/rsync -v --files-from ${root}/etc/portage/filelist_sync --recursive ${root} ${repo}/conf/${device} --
        cd ${repo}
        su ctibor --command "/usr/bin/git pull"
        su ctibor --command "/usr/bin/git commit -a -m \"Update portage config for ${device} $(date +%Y%m%d-%H%M%S)\""
        su ctibor --command "/usr/bin/git push";;
        pull)
        echo "Pulling config files from overlay folder ..."
        cd ${repo}
        su ctibor --command "/usr/bin/git pull"
        /usr/bin/rsync -v --files-from ${root}/etc/portage/filelist_sync --recursive ${repo}/conf/${device} ${root} --;;
        *)
        echo "Usage sync-rpi-config <device> <action>."
        exit 1;;
esac

function cleanup {
        rm -r /tmp/rpi-config
}

trap cleanup EXIT;