diff options
Diffstat (limited to 'util-vserver/tools/vesync')
-rwxr-xr-x | util-vserver/tools/vesync | 171 |
1 files changed, 0 insertions, 171 deletions
diff --git a/util-vserver/tools/vesync b/util-vserver/tools/vesync deleted file mode 100755 index 33a202d..0000000 --- a/util-vserver/tools/vesync +++ /dev/null @@ -1,171 +0,0 @@ -#!/bin/bash -# -# vesync - Sync metadata and overlays in vservers -# Copyright (C) 2005 Benedikt Boehm <hollow@gentoo.org> -# Christian Heim <phreak@gentoo.org> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -: ${APP:=${0##*/}} -: ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars} - -if [ ! -e ${UTIL_VSERVER_VARS} ]; then - echo "Cannot find util-vserver installation" - echo "(the file '$UTIL_VSERVER_VARS' would be expected)" - exit 1 -fi - -source ${UTIL_VSERVER_VARS} - -if [ ! -e ${_LIB_GENTOO_FUNCTIONS} ]; then - echo "${_LIB_GENTOO_FUNCTIONS} missing. Are you running Gentoo?" - exit 1 -fi - -source ${_LIB_GENTOO_FUNCTIONS} - -trap "exit 1" INT - -syncportage() { -# $1 - name of the vserver - ebegin "Updating metadata for vserver '${1}'" - /usr/sbin/vserver ${1} exec /usr/bin/emerge --metadata >&9 - eend $? || die -} - -syncoverlay() { -# $1 - name of the vserver -# $2 - overlayhost (e.g. rsync://rsync.de.gentoo.org/gentoo-overlay) -# $3 - overlay directory (e.g. /usr/local/portage) - ebegin "Syncing overlay '${3}' for vserver '${1}'" - /usr/sbin/vserver ${1} exec /usr/bin/rsync -rtW --progress --delete \ - --delete-after ${2}/ ${3}/ >&9 - eend $? || die -} - -usage() { - echo "Usage: vesync <opts> [<name>]" - echo - echo "<name> Name of the vserver (required if --all not used)" - echo - echo "Options:" - echo " -h, --help This help message" - echo " -q, --quiet Don't show output of emerge" - echo " -a, --all Sync all running vservers" - echo " -e, --exclude <list> Exclude single vservers with --all" - echo " --overlay Directory of a portage overlay" - echo " --overlay-host Rsync host of the overlay" - echo " --overlay-only Only sync the overlay" - echo -} - -# Parsing opts -opts=$(POSIXLY_CORRECT=1 getopt -o hqae --longoptions help,quiet,all,exclude:,overlay,overlay-host,overlay-only -n $0 -- "$@") - -[ "$?" != "0" ] && die "Wrong number of options" - -eval set -- "$opts" - -quiet=0 -all=0 -exclude= -overlay= -overlay_host= -overlay_only=0 - -while true; do - case "${1}" in - --help|-h) - usage - exit 0 - ;; - --quiet|-q) - quiet=1 - shift - ;; - --all|-a) - all=1 - shift - ;; - --exclude|-e) - exclude=$2 - shift 2 - ;; - --overlay) - overlay=${2%/} - shift 2 - ;; - --overlay-host) - overlay_host=${2%/} - shift 2 - ;; - --overlay-only) - overlay_only=1 - shift - ;; - --) - shift - break - ;; - *) - die "Unknown argument '${1}'" - ;; - esac -done - -# checking quiet option -if [ ${quiet} -eq 0 ]; then - exec 9>&1 -else - exec 9>/dev/null 2>&1 -fi - -# checking vserver name -name= -if [ -z "$1" ] && [ ${all} -eq 0 ]; then - die "Missing argument <name>" -else - name=$1 -fi -shift - -# get list of all running vservers -if [ ${all} -eq 0 ]; then - vservers=${name} -else - running=$(vs_running_name) - vservers= - - for r in ${running}; do - match=0 - - for e in ${exclude}; do - [ "${r}" == "${e}" ] && match=1 - done - - [ ! -f "${__CONFDIR}/${r}/vdir/etc/gentoo-release" ] && match=1 - - [ ${match} -eq 0 ] && vservers="${vservers} ${r}" - done -fi - -# finally, sync it! -for vserver in ${vservers}; do - [ ${overlay_only} -eq 0 ] && syncportage ${vserver} - - if [ -n "${overlay_host}" ] && [ -n "${overlay}" ]; then - syncoverlay ${vserver} ${overlay_host} ${overlay} - fi -done |