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:
1
Makefile
1
Makefile
@@ -14,6 +14,7 @@ install:
|
|||||||
$(INSTALL_CMD) ./client/bin/disco-fs-diff $(EXEC_PREFIX)/disco-fs-diff
|
$(INSTALL_CMD) ./client/bin/disco-fs-diff $(EXEC_PREFIX)/disco-fs-diff
|
||||||
$(INSTALL_CMD) ./client/bin/disco-sh-exec $(EXEC_PREFIX)/disco-sh-exec
|
$(INSTALL_CMD) ./client/bin/disco-sh-exec $(EXEC_PREFIX)/disco-sh-exec
|
||||||
$(INSTALL_CMD) ./client/bin/disco-sh-shell $(EXEC_PREFIX)/disco-sh-shell
|
$(INSTALL_CMD) ./client/bin/disco-sh-shell $(EXEC_PREFIX)/disco-sh-shell
|
||||||
|
$(INSTALL_CMD) ./client/bin/disco-shutup $(EXEC_PREFIX)/disco-shutup
|
||||||
$(INSTALL_CMD) ./client/bin/disco $(EXEC_PREFIX)/disco
|
$(INSTALL_CMD) ./client/bin/disco $(EXEC_PREFIX)/disco
|
||||||
$(INSTALL_CMD) ./universe/bin/disco-ball $(EXEC_PREFIX)/disco-ball
|
$(INSTALL_CMD) ./universe/bin/disco-ball $(EXEC_PREFIX)/disco-ball
|
||||||
$(INSTALL_CMD) ./universe/bin/disco-param $(EXEC_PREFIX)/disco-param
|
$(INSTALL_CMD) ./universe/bin/disco-param $(EXEC_PREFIX)/disco-param
|
||||||
|
|||||||
27
balls/users/scripts/00-makeusers.sh
Normal file
27
balls/users/scripts/00-makeusers.sh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
########################
|
||||||
|
# 00-makeusers.sh
|
||||||
|
#
|
||||||
|
# Make linux users for the 'users' disco ball
|
||||||
|
# Each user is represented as a key under ${HOSTNAME}/users, with the value
|
||||||
|
# of each key being a list of useradd/usermod compatible command line flags
|
||||||
|
# that are passed, one each, directly into usermod/useradd
|
||||||
|
########################
|
||||||
|
|
||||||
|
HOSTNAME=$(hostname)
|
||||||
|
|
||||||
|
for username in $(disco-param keys ${HOSTNAME}/users)
|
||||||
|
do
|
||||||
|
NAME=$username
|
||||||
|
PARAMS=$(disco-param get ${HOSTNAME}/users/${NAME})
|
||||||
|
getent passwd | grep "^${NAME}" 2>&1 | disco-shutup
|
||||||
|
RETVAL=$?
|
||||||
|
if [ $RETVAL -eq 0 ] && [ "$PARAMS" == "" ]; then
|
||||||
|
userdel ${NAME}
|
||||||
|
elif [ $RETVAL -ne 0 ]; then
|
||||||
|
usermod ${PARAMS} ${NAME}
|
||||||
|
elif [ "$PARAMS" != "" ]; then
|
||||||
|
useradd ${PARAMS} ${NAME}
|
||||||
|
fi
|
||||||
|
done
|
||||||
@@ -18,7 +18,12 @@ function colorize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function report() {
|
function report() {
|
||||||
for module in $(ls /var/disco/reports/)
|
if [ "$1" != "" ]; then
|
||||||
|
MODULELIST="$1"
|
||||||
|
else
|
||||||
|
MODULELIST=$(ls /var/disco/reports/)
|
||||||
|
fi
|
||||||
|
for module in $MODULELIST;
|
||||||
do
|
do
|
||||||
BASE="report: $module:"
|
BASE="report: $module:"
|
||||||
for file in $(ls /var/disco/reports/${module})
|
for file in $(ls /var/disco/reports/${module})
|
||||||
@@ -51,18 +56,7 @@ function dance() {
|
|||||||
|
|
||||||
for module in $(cat /tmp/$$.tsort | tsort | tac)
|
for module in $(cat /tmp/$$.tsort | tsort | tac)
|
||||||
do
|
do
|
||||||
echo "info: Processing ${module}"
|
disco-ball spin ${module}
|
||||||
NOOP="true" disco-ball template $module
|
|
||||||
NOOP=true /usr/bin/time -f "$TIME" -o /var/disco/reports/${module}/diff disco-fs-diff
|
|
||||||
if [ "$NOOP" == "" ]; then
|
|
||||||
rsync -aWH /var/disco/testfs/noop/scratchfs/. /.
|
|
||||||
fi
|
|
||||||
NOOP="$NOOP" disco-ball exec $module
|
|
||||||
RETVAL=$?
|
|
||||||
rm -rf /var/disco/testfs/noop/scratchfs/*
|
|
||||||
if [ $RETVAL -ne 0 ]; then
|
|
||||||
echo "error: Failed to apply $module."
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$REPORT" != "" ]; then
|
if [ "$REPORT" != "" ]; then
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ while read LINE
|
|||||||
do
|
do
|
||||||
FNAME=$(echo $LINE | cut -d : -f 4 | sed s/"^ *"/""/ | sed s/" *$"/""/)
|
FNAME=$(echo $LINE | cut -d : -f 4 | sed s/"^ *"/""/ | sed s/" *$"/""/)
|
||||||
MD5_NEW=$(md5sum ${DISCOROOT}/scratchfs${FNAME} 2>/dev/null| cut -d " " -f 1)
|
MD5_NEW=$(md5sum ${DISCOROOT}/scratchfs${FNAME} 2>/dev/null| cut -d " " -f 1)
|
||||||
STAT_NEW=$(stat --format "owner='%G:%U', selinux='%C', md5='${MD5_NEW}'" ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null)
|
STAT_NEW=$(chroot ${DISCOROOT}/chroot stat --format "owner='%G:%U', selinux='%C', md5='${MD5_NEW}'" /${FNAME} 2>/dev/null)
|
||||||
if [ ! -d ${FNAME} ] && [ ! -d ${DISCOROOT}/scratchfs${FNAME} ]; then
|
if [ ! -d ${FNAME} ] && [ ! -d ${DISCOROOT}/scratchfs${FNAME} ]; then
|
||||||
diff -N ${FNAME} ${DISCOROOT}/scratchfs${FNAME} 2>/dev/null > /tmp/$$.diff
|
diff -N ${FNAME} ${DISCOROOT}/scratchfs${FNAME} 2>/dev/null > /tmp/$$.diff
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
DISCOCFG=/etc/disco
|
DISCOCFG=/etc/disco
|
||||||
|
|
||||||
if [ "$NOOP" != "" ]; then
|
if [ "$NOOP" != "" ]; then
|
||||||
DISCOROOT=/var/disco/testfs/noop
|
DISCOROOT=/var/disco/testfs/noop
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fi
|
|||||||
|
|
||||||
mount | grep $DISCOROOT >/dev/null 2>&1
|
mount | grep $DISCOROOT >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
./disco-fs-mount || exit 1
|
echo "disco filesystem is not mounted; please mount it and try again."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Strip out any shebang and put the script in the root
|
# Strip out any shebang and put the script in the root
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ mkdir -p ${DISCOROOT}/reports/_internal
|
|||||||
function init() {
|
function init() {
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
echo "Must enter a path to initialize" >&2
|
echo "Must enter a path to initialize" >&2
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
mkdir -p $1/templates
|
mkdir -p $1/templates
|
||||||
mkdir -p $1/scripts
|
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
|
/usr/bin/time -f "$TIME" -o ${DISCOROOT}/reports/_internal/fetch_params /bin/bash /tmp/$$.sh
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
rm -f /tmp/$$.sh
|
rm -f /tmp/$$.sh
|
||||||
exit $RETVAL
|
return $RETVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch() {
|
function fetch() {
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
echo "Must pass a module name to fetch"
|
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
|
fi
|
||||||
rm -rf ${STORAGE}/${1}
|
rm -rf ${STORAGE}/${1}
|
||||||
mkdir -p ${DISCOROOT}/reports/$1
|
mkdir -p ${DISCOROOT}/reports/$1
|
||||||
rm -f ${DISCOROOT}/reports/${1}/fetch
|
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
|
# 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.
|
# 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 ${RSYNC} --delete ${SERVERURI}::${1}/requires ${SERVERURI}::${1}/scripts ${SERVERURI}::${1}/parameters ${SERVERURI}::${1}/templates ${STORAGE}/${1} >> /tmp/$$.sh
|
||||||
echo 'exit $?' >> /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
|
cat /tmp/$$.errors | grep -v "some files/attrs were not transferred" | sed s/"^"/"error: ${1}: "/g
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
rm -f /tmp/$$.sh
|
rm -f /tmp/$$.sh
|
||||||
exit $RETVAL
|
return $RETVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
function requires()
|
function requires()
|
||||||
{
|
{
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
echo "Must pass a module name for requirements"
|
echo "Must pass a module name for requirements"
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
cat ${STORAGE}/${1}/requires | sed s/"^"/"${1} "/g
|
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
|
cat /tmp/$$.exec.time | sed s/"^"/" "/g >> ${DISCOROOT}/reports/${1}/exec
|
||||||
done
|
done
|
||||||
rm -f /tmp/$$.exec.time
|
rm -f /tmp/$$.exec.time
|
||||||
exit $RETVAL
|
return $RETVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
function template() {
|
function template() {
|
||||||
if [ "$1" == "" ]; then
|
if [ "$1" == "" ]; then
|
||||||
echo "Must pass a module name to template"
|
echo "Must pass a module name to template"
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
mkdir -p ${DISCOROOT}/reports/$1
|
mkdir -p ${DISCOROOT}/reports/$1
|
||||||
rm -f ${DISCOROOT}/reports/${1}/template
|
rm -f ${DISCOROOT}/reports/${1}/template
|
||||||
@@ -87,6 +92,9 @@ function template() {
|
|||||||
if [ "$NOOP" != "" ]; then
|
if [ "$NOOP" != "" ]; then
|
||||||
DESTROOT=/var/disco/testfs/noop/scratchfs
|
DESTROOT=/var/disco/testfs/noop/scratchfs
|
||||||
fi
|
fi
|
||||||
|
if [ ! -d ${STORAGE}/${1}/templates ]; then
|
||||||
|
return 0;
|
||||||
|
fi
|
||||||
cd ${STORAGE}/${1}/templates
|
cd ${STORAGE}/${1}/templates
|
||||||
RETVAL=0
|
RETVAL=0
|
||||||
for file in $(find . -type f | sed s/"^\.\/"//g)
|
for file in $(find . -type f | sed s/"^\.\/"//g)
|
||||||
@@ -103,7 +111,32 @@ function template() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
rm -f /tmp/$$.template.time
|
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
|
$1 $2
|
||||||
|
|||||||
Reference in New Issue
Block a user