#!/bin/sh # This scripts knows about every possible distribution (well, it should) # It is passed a vserver name and a key (a command). The key represent a task. # It executes the command and output on stdout. # For example # distrib-info vserver1 pkgversion # If vserver1 is a redhat system, it executes # rpm -qa --queryformat "%{name}=%{version}-%{release} USR_SBIN=/usr/sbin USR_LIB_VSERVER=/usr/lib/vserver if [ "$1" = "" ] ; then echo distrib-info vserver-name command [ args ... ] >&2 echo Commands are: >&2 echo dumpfiles: Shows all files owned by a package >&2 echo pkgversion: reports all packages and their version/release >&2 echo unifiles: reports all unify-able file of a package >&2 exit 1 fi if [ "$1" = "/" ] ; then DISTDIR=/ CHROOTCMD= elif [ -d "$1" ] ; then DISTDIR=$1 CHROOTCMD="/usr/sbin/chroot $DISTDIR" else VSERVERDIR="" eval `$USR_LIB_VSERVER/printconf.sh --quote $1` if [ "$VSERVERDIR" = "" ] ; then exit 1 fi DISTDIR=$VSERVERDIR CHROOTCMD="/usr/sbin/chroot $DISTDIR" fi KEY=$2 shift shift if [ -f $DISTDIR/etc/redhat-release -o -f $DISTDIR/etc/mandrake-release ] ; then case $KEY in pkgversion) $CHROOTCMD /bin/rpm -qa --queryformat "%{name}=%{version}-%{release}\n" ;; unifiles) # We remove /etc and /var/log to make sure no special file # there will be unified $CHROOTCMD /bin/rpm -ql --dump $* \ | $USR_LIB_VSERVER/parserpmdump /etc/ ;; dumpfiles) $CHROOTCMD /bin/rpm -ql $* ;; *) echo unknown request $KEY >&2 ;; esac else echo Distribution not supported yet >&2 fi