blob: 561b993d590a0987f8fd81f388720232dd5fd8d4 (
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
|
#!/bin/bash
dir="/var/tmp/portage/config/conf/$(hostname)"
username="ctibor"
root=/
repo="ssh://git@git.brancik.cz/rpi-config.git"
if [ $# != 1 ]; then
echo "Usage: sync-config <action>. Action can be either pull or push"
exit 1
fi
function check_repo {
if [ ! -d /var/tmp/portage/config/.git ]; then
echo "Cloning repository with config files."
mkdir -p /var/tmp/portage
chown ${username}:${username} /var/tmp/portage
/bin/su ${username} --command="/usr/bin/git clone --depth=1 ${repo} /var/tmp/portage/config"
fi
}
case $1 in
push)
check_repo
/bin/su ${username} --command="/usr/bin/git pull"
echo "Pushing config files to overlay folder ..."
/usr/bin/rsync -v --files-from /etc/portage/filelist_sync --recursive ${root} ${dir} --
cd ${dir}
/bin/su ${username} --command="/usr/bin/git add ."
/bin/su ${username} --command="/usr/bin/git commit -a -m \"Update portage config for mizar $(date +%Y%m%d-%H%M%S)\""
/bin/su ${username} --command="/usr/bin/git push";;
pull)
check_repo
cd ${dir}
/bin/su ${username} --command="/usr/bin/git pull"
echo "Pulling config files from overlay folder ..."
/usr/bin/rsync -v --files-from /etc/portage/filelist_sync --recursive ${dir} ${root} --;;
*)
echo "Usage: sync-config <action>. Action can be either pull or push"
exit 1
esac
|