Made the diff stat from inside the testfs, so new users/groups would stat correctly. Changed disco-ball fetch to fetch into the testfs, not into / (yikes!). New disco-ball command spin does what the main disco loop used to do for each module. Added the "users" disco ball to the standard library.
This commit is contained in:
@@ -11,7 +11,7 @@ mkdir -p ${DISCOROOT}/reports/_internal
|
||||
function init() {
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Must enter a path to initialize" >&2
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
mkdir -p $1/templates
|
||||
mkdir -p $1/scripts
|
||||
@@ -28,34 +28,39 @@ function fetch_params() {
|
||||
/usr/bin/time -f "$TIME" -o ${DISCOROOT}/reports/_internal/fetch_params /bin/bash /tmp/$$.sh
|
||||
RETVAL=$?
|
||||
rm -f /tmp/$$.sh
|
||||
exit $RETVAL
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
function fetch() {
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Must pass a module name to fetch"
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
if [ "$NOOP" == "" ]; then
|
||||
DEST=/var/disco/testfs/real/scratchfs
|
||||
else
|
||||
DEST=/var/disco/testfs/noop/scratchfs
|
||||
fi
|
||||
rm -rf ${STORAGE}/${1}
|
||||
mkdir -p ${DISCOROOT}/reports/$1
|
||||
rm -f ${DISCOROOT}/reports/${1}/fetch
|
||||
# Sometimes there's some shell escaping voodoo and rsync doesn't like the command args some people will pass it straight on
|
||||
# the command line; so we wrap it in a little bash script, and everyone's happy.
|
||||
echo ${RSYNC} ${SERVERURI}::${1}/files/* / > /tmp/$$.sh
|
||||
echo ${RSYNC} ${SERVERURI}::${1}/files/* ${DEST} > /tmp/$$.sh
|
||||
echo ${RSYNC} --delete ${SERVERURI}::${1}/requires ${SERVERURI}::${1}/scripts ${SERVERURI}::${1}/parameters ${SERVERURI}::${1}/templates ${STORAGE}/${1} >> /tmp/$$.sh
|
||||
echo 'exit $?' >> /tmp/$$.sh
|
||||
/usr/bin/time -f "$TIME" -o ${DISCOROOT}/reports/${1}/fetch /bin/bash /tmp/$$.sh 2>/tmp/$$.errors | sed s/"^"/"info: ${1}: "/g
|
||||
/usr/bin/time -f "$TIME" -o ${DISCOROOT}/reports/${1}/fetch /tmp/$$.sh 2>/tmp/$$.errors | sed s/"^"/"info: ${1}: "/g
|
||||
cat /tmp/$$.errors | grep -v "some files/attrs were not transferred" | sed s/"^"/"error: ${1}: "/g
|
||||
RETVAL=$?
|
||||
rm -f /tmp/$$.sh
|
||||
exit $RETVAL
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
function requires()
|
||||
{
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Must pass a module name for requirements"
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
cat ${STORAGE}/${1}/requires | sed s/"^"/"${1} "/g
|
||||
}
|
||||
@@ -73,13 +78,13 @@ function exec() {
|
||||
cat /tmp/$$.exec.time | sed s/"^"/" "/g >> ${DISCOROOT}/reports/${1}/exec
|
||||
done
|
||||
rm -f /tmp/$$.exec.time
|
||||
exit $RETVAL
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
function template() {
|
||||
if [ "$1" == "" ]; then
|
||||
echo "Must pass a module name to template"
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
mkdir -p ${DISCOROOT}/reports/$1
|
||||
rm -f ${DISCOROOT}/reports/${1}/template
|
||||
@@ -87,6 +92,9 @@ function template() {
|
||||
if [ "$NOOP" != "" ]; then
|
||||
DESTROOT=/var/disco/testfs/noop/scratchfs
|
||||
fi
|
||||
if [ ! -d ${STORAGE}/${1}/templates ]; then
|
||||
return 0;
|
||||
fi
|
||||
cd ${STORAGE}/${1}/templates
|
||||
RETVAL=0
|
||||
for file in $(find . -type f | sed s/"^\.\/"//g)
|
||||
@@ -103,7 +111,32 @@ function template() {
|
||||
fi
|
||||
done
|
||||
rm -f /tmp/$$.template.time
|
||||
exit $RETVAL
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
function spin() {
|
||||
module=$1
|
||||
echo "info: Processing ${module}"
|
||||
NOOP="true" template $module
|
||||
if [ "$NOOP" == "" ]; then
|
||||
# We rsync all the configs and files into the 'real' scratchfs so that we can
|
||||
# just do one big diff at the very end, capturing every single disk change,
|
||||
# including ones made by the scripts.
|
||||
rsync -aWH /var/disco/testfs/noop/scratchfs/. /var/disco/testfs/real/scratchfs/
|
||||
fi
|
||||
NOOP="$NOOP" exec $module
|
||||
RETVAL=$?
|
||||
/usr/bin/time -f "$TIME" -o /var/disco/reports/${module}/diff disco-fs-diff
|
||||
if [ "$NOOP" == "" ]; then
|
||||
# Now for the real rsync back home
|
||||
rsync -aWH /var/disco/testfs/real/scratchfs/. /
|
||||
fi
|
||||
rm -rf /var/disco/testfs/noop/scratchfs/*
|
||||
rm -rf /var/disco/testfs/real/scratchfs/*
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
echo "error: Failed to apply $module."
|
||||
fi
|
||||
return $?
|
||||
}
|
||||
|
||||
$1 $2
|
||||
|
||||
Reference in New Issue
Block a user