Commit 07a06348 authored by Dan Reading's avatar Dan Reading
Browse files

Renamed the saves inventory files and tree so it will never look

crowded. Use relative symlinks instad of absolute paths.
Replace hardwired pathname with variable.
parent 9519ad7c
......@@ -34,6 +34,8 @@ PROJDIR=/proj/emulab-ops
source checkutils.sh
INVDIR=${PROJDIR}/nodecheck
gatherinv_main() {
echo -n ' Gathering Inventory..'
......@@ -62,27 +64,44 @@ gatherinv_main() {
echo "$PROJDIR not mounted can't save info"
exit 1
fi
# start XXX
# decided to change names again, rename if old names -- XXX remove this after all node have run the new code
if [ -d ${INVDIR}/$host ] ; then
owd=$PWD
cd ${INVDIR}/$host
[[ -d full ]] && ( mv full .full ; rm -f $host.full )
[[ -d diff ]] && ( mv diff .diff ; rm -f $host.diff )
[[ -d tbdb ]] && ( mv tbdb .tbdb ; rm -f $host )
cd $owd
fi
# end XXX
# have needed dirs ?
# note: a directory for each node and timestamps for each file
if [ ! -d /proj/emulab-ops/nodecheck/$host/full ] ; then
mkdir -p /proj/emulab-ops/nodecheck/$host/tbdb
mkdir -p /proj/emulab-ops/nodecheck/$host/full
chmod g+x /proj/emulab-ops/nodecheck/$host /proj/emulab-ops/nodecheck/$host/tbdb /proj/emulab-ops/nodecheck/$host/full
if [ ! -d ${INVDIR}/$host/.full ] ; then
mkdir -p ${INVDIR}/$host/.tbdb
mkdir -p ${INVDIR}/$host/full
chmod g+x ${INVDIR}/$host ${INVDIR}/$host/.tbdb ${INVDIR}/$host/.full
fi
# copy over the file including timestamps
timestamp=$(date +%y%m%d%H%M%S)
cp /tmp/nodecheck.log.tb.new /proj/emulab-ops/nodecheck/$host/tbdb/$timestamp
rm -f /proj/emulab-ops/nodecheck/$host/$host #this should be a symlink
ln -s /proj/emulab-ops/nodecheck/$host/tbdb/${timestamp} /proj/emulab-ops/nodecheck/$host/$host
cp /tmp/nodecheck.log.inv /proj/emulab-ops/nodecheck/$host/full/$timestamp
rm -f /proj/emulab-ops/nodecheck/$host/$host.full #another symlink
ln -s /proj/emulab-ops/nodecheck/$host/full/$timestamp /proj/emulab-ops/nodecheck/$host/$host.full
cp /tmp/nodecheck.log.tb.new ${INVDIR}/$host/.tbdb/$timestamp
cp /tmp/nodecheck.log.inv ${INVDIR}/$host/.full/$timestamp
# remove old symlink and make new ones
owd=$PWD
cd ${INVDIR}/$host
rm -f $host #this should be a symlink
rm -f full $host.full #another symlink
ln -s ./.tbdb/${timestamp} ${INVDIR}/$host/$host
ln -s ./.full/$timestamp ${INVDIR}/$host/full
cd $owd
# Test what found locally against what is in the database
readtmcinfo # info from tmcc.bin hwinv
# for testing readtmcinfo /proj/emulab-ops/nodecheck/test
# if testing can do some like readtmcinfo ${INVDIR}/test
copytmcinfo # copy into hwinvcopy
readtmcinfo /tmp/nodecheck.log.tb.new # read local found into hwinv
comparetmcinfo /tmp/nodecheck.diff # file for output
......@@ -90,20 +109,24 @@ gatherinv_main() {
# if we ended up with a diff file handle it
if [ -s /tmp/nodecheck.diff ] ; then
# show it at runtime?? cat /tmp/nodecheck.diff
if [ ! -d /proj/emulab-ops/nodecheck/$host/diff ] ; then
mkdir -p /proj/emulab-ops/nodecheck/$host/diff
chmod g+x /proj/emulab-ops/nodecheck/$host/diff
# decided to change names again, rename if old names
if [ ! -d ${INVDIR}/$host/.diff ] ; then
mkdir -p ${INVDIR}/$host/.diff
chmod g+x ${INVDIR}/$host/.diff
fi
cp /tmp/nodecheck.diff /proj/emulab-ops/nodecheck/$host/diff/${timestamp}
cp /tmp/nodecheck.diff ${INVDIR}/$host/.diff/${timestamp}
cd ${INVDIR}/$host
rm -f diff ${host}.diff
ln -s ./.diff/${timestamp} ${INVDIR}/${host}/diff
else
# no diff maybe it got better, put a marker out
cp /dev/null /proj/emulab-ops/nodecheck/${host}/diff/${timestamp}
# cp /dev/null ${INVDIR}/${host}/.diff/${timestamp}
cd ${INVDIR}/$host
rm -f $host.diff diff
fi
rm -f /proj/emulab-ops/nodecheck/$host/$host.diff
ln -s /proj/emulab-ops/nodecheck/${host}/diff/${timestamp} /proj/emulab-ops/nodecheck/${host}/${host}.diff
# make sure no sudo is needed for read
chmod -R g+rw /proj/emulab-ops/nodecheck/$host
chmod -R g+rw ${INVDIR}/$host
# echo "NEED TO ENABLE rm -f /tmp/nodecheck.log.tb /tmp/nodecheck.log.inv"
# echo "NEED TO ENABLE rm -f /tmp/nodecheck.log.tb.new /tmp/nodecheck.diff"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment