#!/bin/bash #This script will create and synchronize a local package mirror with the repository (as defined below) on linhes.org, # it will also update the database. #This script uses a shared account on linhes.org. # 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=/srv/www/repo REMOTE_DIR=/srv/www/repo DOCROOT=/data/pkg_repo/$CARCH #export UNISON="/root/.unison" export UNISON="/data/pkg_repo/.unison" cp -f /build_tools/bin/km-up.prf $UNISON/km-up.prf cp -f /build_tools/bin/km-down.prf $UNISON/km-down.prf function sync_dirs { REMOTE=$1 LOCAL=$2 echo " Updating $3 " echo "________________________________________________________" #first bring down new changes from linhes.org echo "--------" echo echo "Syncing the packages with linhes.org" echo echo "--------" unison km-down -logfile /tmp/unison-down.log -auto -batch -numericids ssh://reposync@linhes.org/$REMOTE $LOCAL if [ ! $? = 0 ] then echo "#######################################################" echo "## ERRORS OCCURED ##" echo "#######################################################" exit 1 fi #update the local database if [ "$4" == "update_db" ] then echo "Updating the whole db..." update_db_repo.sh $LOCAL $3 fi #push the database back echo "--------" echo echo "Pushing the pkg database to linhes.org" echo echo "--------" unison km-up -logfile /tmp/unison-up.log -auto -batch -numericids -force $LOCAL $LOCAL ssh://reposync@linhes.org/$REMOTE #scp $LOCAL/*.db.tar.gz reposync@linhes.org:$REMOTE/ echo "-------------------------------------------------------" echo "----------- Finished with $3 -----------" echo "-------------------------------------------------------" } function source_sync () { src_repo=$1 case $1 in testing ) echo "updating source packages" REMOTE_DIR=/srv/www/repo/src_packages/core-testing LOCAL=/data/pkg_repo/src_packages/core-testing unison km-down -logfile /tmp/unison-down.log -auto -batch -numericids ssh://reposync@linhes.org/$REMOTE_DIR $LOCAL REMOTE_DIR=/srv/www/repo/src_packages/extra-testing LOCAL=/data/pkg_repo/src_packages/extra-testing unison km-down -logfile /tmp/unison-down.log -auto -batch -numericids ssh://reposync@linhes.org/$REMOTE_DIR $LOCAL ;; release ) echo "updating source packages" REMOTE_DIR=/srv/www/repo/src_packages/core LOCAL=/data/pkg_repo/src_packages/core unison km-down -logfile /tmp/unison-down.log -auto -batch -numericids ssh://reposync@linhes.org/$REMOTE_DIR $LOCAL REMOTE_DIR=/srv/www/repo/src_packages/extra LOCAL=/data/pkg_repo/src_packages/extra unison km-down -logfile /tmp/unison-down.log -auto -batch -numericids ssh://reposync@linhes.org/$REMOTE_DIR $LOCAL ;; chroot-devel ) echo "updating source packages" REMOTE_DIR=/srv/www/repo/src_packages/chroot-devel LOCAL=/data/pkg_repo/src_packages/chroot-devel unison km-down -logfile /tmp/unison-down.log -auto -batch -numericids ssh://reposync@linhes.org/$REMOTE_DIR $LOCAL ;; *) echo "need to know the source repository [testing|release|chroot-devel]" exit 1 ;; esac } function pacman_sync () { echo "running 'pacman -Sy' to sync repos" pacman -Sy } #--------------------------------------------------------------- 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 $2 sync_dirs $REMOTE_DIR/$CARCH/extra-testing $DOCROOT/extra-testing extra-testing $2 source_sync testing pacman_sync ;; release) sync_dirs $REMOTE_DIR/$CARCH/core $DOCROOT/core core $2 sync_dirs $REMOTE_DIR/$CARCH/extra $DOCROOT/extra extra $2 source_sync release pacman_sync ;; chroot-devel) echo "will update chroot-devel" sync_dirs $REMOTE_DIR/$CARCH/chroot-devel $DOCROOT/chroot-devel chroot-devel $2 source_sync chroot-devel pacman_sync ;; source) if [ x = x$2 ] then echo "need to know the source repository [testing|release|chroot-devel]" exit 1 fi source_sync $2 pacman_sync ;; *) echo "invalid options" echo "kmsync.sh (testing|release|chroot-devel|source[testing|release|chroot-devel]) " echo echo "EX: kmsync.sh testing update_db <= 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