summaryrefslogtreecommitdiffstats
path: root/build_tools/bin/kmsync.sh
blob: 6506b563c91421286ef56eb8e9dcd98c3088e5e3 (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
#!/bin/bash
#This script will create and synchronize a local package mirror with the repository (as defined below) on knoppmyth.net, it will also update the database.
#This script uses a shared account on knoppmyth.net.  DO NOT change the account name
# and dont' ask for the password, instead setup ssh keys.
#


if  [ -e /etc/makepkg.conf ]
then
    . /etc/makepkg.conf
else
    echo "couldn't find /etc/makepkg.conf"
fi
cwd=`dirname $0`
REMOTE_DIR=/mount/repository/repo
DOCROOT=/data/pkg_repo/$CARCH

#export UNISON="/root/.unison"
export UNISON="/data/pkg_repo/.unison"

function sync_dirs {
    REMOTE=$1
    LOCAL=$2

    echo "                     Updating $3                        "
    echo "________________________________________________________"

    #first bring down new changes from knoppmyth.net
    unison km-down  -terse -logfile /tmp/unison-down.log -auto -batch  -numericids ssh://reposync@knoppmyth.net/$REMOTE $LOCAL
    if [ ! $? = 0 ]
    then
        echo "#######################################################"
        echo "##             ERRORS OCCURED                        ##"
        echo "#######################################################"
        exit 1

    fi
    #update the local database
    update_db_repo.sh $LOCAL $3

    #push the database back
    unison km-up -logfile /tmp/unison-up.log -auto -batch -numericids   ssh://reposync@knoppmyth.net/$REMOTE $LOCAL
    echo "-------------------------------------------------------"
    echo "-----------         Finished with $3        -----------"
    echo "-------------------------------------------------------"




}
#---------------------------------------------------------------
if [ ! -d $UNISON ]
then
    mkdir $UNISON
fi

if [ ! -f $UNISON/km-down.prf ]
then
    cp -f $cwd/km-down.prf $UNISON/
fi

if [ ! -f $UNISON/km-up.prf ]
then
    cp -f $cwd/km-up.prf $UNISON/
fi



clear
case $1 in
    testing)
        #sync_dirs $REMOTE $LOCAL
        sync_dirs $REMOTE_DIR/$CARCH/core-testing $DOCROOT/core-testing  core-testing
        sync_dirs $REMOTE_DIR/$CARCH/extra-testing $DOCROOT/extra-testing extra-testing
        ;;

    release)
        sync_dirs $REMOTE_DIR/$CARCH/core $DOCROOT/core  core
        sync_dirs $REMOTE_DIR/$CARCH/extra $DOCROOT/extra extra
        ;;

    chroot-devel)
        echo "will update chroot-devel"
        sync_dirs $REMOTE_DIR/$CARCH/chroot-devel $DOCROOT/chroot-devel  chroot-devel
        ;;
    *)
        echo "invalid options"
        echo "kmsync.sh (testing|release|chroot-devel) "
        echo
        echo "EX:  kmsync.sh testing  <= will sync the testing repo with km.net update the local database and resync with km.net"
        #echo "kmsync.sh testing oneway <= will syncthe testing repo with km.net update the local database"

        ;;
esac
echo "Finished."
# End