diff --git a/client/bin/disco b/client/bin/disco index 0e3e039..c06f89e 100755 --- a/client/bin/disco +++ b/client/bin/disco @@ -7,14 +7,22 @@ else DISCOROOT=/var/disco/testfs/real fi -function main() { +. ${DISCOCFG}/client.cfg + +function colorize() { + sed s/"^info:\(.*\)"/"${COLOR_CYAN}info:\1${COLOR_NORMAL}"/g |\ + sed s/"^warning: \(.*\)"/"${COLOR_YELLOW}warning: \1${COLOR_NORMAL}"/g |\ + sed s/"^error: \(.*\)"/"${COLOR_RED}error: \1${COLOR_NORMAL}"/g +} + +function dance() { mount | grep $DISCOROOT >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "error: disco filesystem does not appear to be mounted, please exec disco-fs-init, disco-fs-mount, and try again." exit 1 fi - + disco-ball fetch_params if [ $? -ne 0 ]; then echo "error: Unable to fetch parameters for this host from remote server" @@ -45,4 +53,4 @@ function main() { done } -main $@ \ No newline at end of file +$1 "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" diff --git a/client/bin/disco-fs-diff b/client/bin/disco-fs-diff index 0632f17..f0c0e4e 100755 --- a/client/bin/disco-fs-diff +++ b/client/bin/disco-fs-diff @@ -11,32 +11,44 @@ fi cd $DISCOROOT -diff -r ./rootfs ./scratchfs |\ - grep -v "^Only in ./rootfs" |\ - sed s/"^Only in \.\/scratchfs\(.*\): \(.*\)"/"info: File: created \1\/\2 : (CONTENT)"/g |\ - sed s/"\/\/"/"\/"/g |\ - grep -v "File: created /.unionfs" |\ - sed s/"^Binary files .\/rootfs\(.*\) and .\/scratchfs.*"/"info: File: modified \1 : (OLDMD5SUM) => (NEWMD5SUM)"/g |\ - sed s/"^diff -r .\/rootfs\(.*\) .\/scratchfs\(.*\)"/"info: File: modified \1 :"/g > /tmp/$$.discofsdiff +rsync --checksum --times --perms --owner --group -ani ./scratchfs/ ./rootfs/ |\ + grep -v ".unionfs.*/$" |\ + sed s/"\.\/scratchfs"/""/ |\ + sed s/"\.unionfs\/"/""/ |\ + grep -v "./$" |\ + sed s/"^[<>ch\.*]d"/"File: directory: "/ |\ + sed s/"^[<>ch\.*]f"/"File: file: "/ |\ + sed s/"^[<>ch\.*]L"/"File: symlink: "/ |\ + sed s/"^[<>ch\.*]D"/"File: device: "/ |\ + sed s/"^[<>ch\.*]S"/"File: special: "/ |\ + sed s/": \([\.cstpoguax+]*\) \(.*\)$"/": \2 : \1"/ |\ + sed s/"+++++++++$"/"Created"/ |\ + sed s/" [\.cstpoguax]*$"/" Modified"/ |\ + sed s/"_HIDDEN~ : Created"/" : Deleted"/ |\ + sed s/"^\(.*\)\$"/"info: \1"/g |\ +while read LINE +do + 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_OLD=$(md5sum /${FNAME} 2>/dev/null| cut -d " " -f 1) + PERMS_NEW=$(stat --format "%G:%U %a" ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null) + PERMS_OLD=$(stat --format "%G:%U %a" /${FNAME} 2>/dev/null) + if [ ! -d /${FNAME} ] && [ ! -d ${DISCOROOT}/scratchfs/${FNAME} ]; then + DIFF=$(echo; diff /${FNAME} ${DISCOROOT}/scratchfs/${FNAME} 2>/dev/null > /tmp/$$.diff ) + fi + file ${DISCOROOT}/scratchfs/${FNAME} 2>&1 | grep ASCII >/dev/null 2>&1 + if [ $? -eq 0 ]; then + CONTENT=$(echo "Text"; cat ${DISCOROOT}/scratchfs/${FNAME} | sed s/"^"/"> "/g > /tmp/$$.content) + fi + echo $LINE |\ + sed -e s/"Created$"/"Created : md5=[${MD5_NEW}] perms=[${PERMS_NEW}]"/ |\ + sed -e s/"Modified$"/"Modified : md5=[${MD5_OLD} => ${MD5_NEW}] perms=[${PERMS_OLD} => ${PERMS_NEW}]"/ + if [ -f /tmp/$$.diff ]; then + cat /tmp/$$.diff + elif [ -f /tmp/$$.content ]; then + cat /tmp/$$.content + fi + rm -f /tmp/$$.content /tmp/$$.diff 2>/dev/null +done -find ./scratchfs/.unionfs -iname "*_HIDDEN~" |\ - sed s/"^.\/scratchfs\/.unionfs\(.*\)_HIDDEN~"/"info: File: deleted \1"/g >> /tmp/$$.discofsdiff - -# Find the permissions/timestamp diffs from rsync -# FIXME: This should be the root of all diffs, not tacked on at the end. -rsync -ani ./scratchfs/* ./rootfs/ |\ - grep -v "_HIDDEN~\$" |\ - grep -v .unionfs |\ - sed s/"\.\/scratchfs"/""/g |\ - sed s/"^\(.*\)\$"/"info: \1"/g - -# Swap out the (CONTENT) and (MD5SUM) hashes for actual content and md5s -# FIXME: Stop calling a python script for this. -cat /tmp/$$.discofsdiff | NOOP=$NOOP python ${SCRIPTROOT}/disco-fs-fixup.py > /tmp/$$.newfile -mv /tmp/$$.newfile /tmp/$$.discofsdiff - - -cat /tmp/$$.discofsdiff |\ - sed s/"^info:\(.*\)"/"${COLOR_CYAN}info:\1${COLOR_NORMAL}"/g |\ - sed s/"^warning: \(.*\)"/"${COLOR_YELLOW}warning: \1${COLOR_NORMAL}"/g |\ - sed s/"^error: \(.*\)"/"${COLOR_RED}error: \1${COLOR_RED}"/g +rm -f /tmp/$$* \ No newline at end of file diff --git a/client/bin/disco-fs-init b/client/bin/disco-fs-init index 8ad3791..8bcc00c 100755 --- a/client/bin/disco-fs-init +++ b/client/bin/disco-fs-init @@ -46,7 +46,7 @@ if [ "$NOOP" != "" ]; then echo "export PATH=${DISCOROOT}/restricted/bin:${DISCOROOT}/munge/mungebin" >> ${DISCOROOT}/munge/etc/bashrc # Make default wrapper - echo -e "#!/bin/bash\necho \"info: Would execute : \$(basename \$0) \$@\"" > ${DISCOROOT}/restricted/bin/_disco_restricted_cmd + echo -e "#!/bin/bash\necho \"warning: Would execute : \$(basename \$0) \$@\"" > ${DISCOROOT}/restricted/bin/_disco_restricted_cmd chmod +x ${DISCOROOT}/restricted/bin/_disco_restricted_cmd # Now link everything to the default wrapper diff --git a/universe/bin/disco-ball b/universe/bin/disco-ball index 5380c20..4ac1dfb 100755 --- a/universe/bin/disco-ball +++ b/universe/bin/disco-ball @@ -40,7 +40,8 @@ function fetch() { echo ${RSYNC} ${SERVERURI}::${1}/files/* / > /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 - /bin/bash /tmp/$$.sh + /bin/bash /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 @@ -71,7 +72,7 @@ function template() { fi DESTROOT="" if [ "$NOOP" != "" ]; then - DESTROOT=/var/disco/testfs/noop + DESTROOT=/var/disco/testfs/noop/scratchfs fi cd ${STORAGE}/${1}/templates for file in $(find . -type f | sed s/"^\.\/"//g) diff --git a/universe/bin/disco-param b/universe/bin/disco-param index ca8d731..01d7513 100755 --- a/universe/bin/disco-param +++ b/universe/bin/disco-param @@ -3,9 +3,9 @@ PARAMROOT=/var/disco/parameters function check_names_regex() { - echo "$1" | grep -E '^[a-zA-Z0-9_-\./]*$' >/dev/null 2>&1 + echo $1 | grep -E '^[a-zA-Z0-9_\-\.\/]*$' >/dev/null 2>&1 if [ $? -ne 0 ]; then - echo "error: Invalid characters in pathname '$1'. Valid pathname characters are [a-zA-Z0-9_-\.\/]*." >&2 + echo "error: Invalid characters in pathname '$1'. Valid pathname characters are [a-zA-Z0-9_-.\/]*." >&2 exit 1 fi echo "$1" | grep "^/" >/dev/null 2>&1