Commit edb6a25a authored by Dan Reading's avatar Dan Reading
Browse files

Although this file is purly for development it should be version controled

parent 0305809c
#!/usr/local/bin/bash
arg=$1
#list="pc4 pc7 pc133 pc137 pc207 pc208 pc406 pc446 pc511 pc606"
if [ "${arg}" == "static" ] ; then
here=$(pwd)
if [ -d "bin_FreeBSD_static" ] ; then
cd bin_FreeBSD_static
stuff=$(ls)
if [ -n "${stuff}" ] ; then
sudo rsync -a -P * /proj/emulab-ops/nodecheck/bin_freebsd
fi
cd $here
fi
if [ -d "bin_Linux_static" ] ; then
cd bin_Linux_static
stuff=$(ls)
if [ -n "${stuff}" ] ; then
sudo rsync -a -P * /proj/emulab-ops/nodecheck/bin_linux
fi
cd $here
fi
exit 0
fi
#list=$(mysql -B -N -e "select node_id from reserved where pid='emulab-ops' and eid='nodechk';" tbdb)
#blist=$(mysql -B -N -e "select node_id from reserved where pid='tbres' and eid='nodecheck';" tbdb)
blist=$(mysql -B -N -e "select node_id from reserved where pid='emulab-ops' and eid='64nodecheck';" tbdb)
alist=$(mysql -B -N -e "select node_id from reserved where pid='emulab-ops' and eid='nore32';" tbdb)
list="$alist $blist"
echo -n "LIST="
for i in $list ; do
echo -n "$i "
done
echo ""
machines=""
set -u
linux=""
bsd=""
#echo "||$machines||"
#echo "bsd||$bsd||"
#echo "linux||$linux||"
utils="diskcheck memcheck cpucheck checkutils.sh hbis.sh timecheck niccheck checknode"
arg=${arg=""} # use var if set else use ""
case $arg in
disk | mem | cpu | time | nic | Ngetlogs | clearlogs | help | -help | -h | ? ) ;;
pc* | dbox* | pg* )
list=$arg ;;
esac
case $arg in
# don't need OS if not
disk | mem | cpu | time | nic | Ngetlogs | clearlogs | help | -help | -h | ? ) machines=$list ;;
* )
for i in $list
do
os=$(sudo ssh $i uname -s)
if [ "$os" == "FreeBSD" ] ; then
bsd="$bsd $i" ; machines="$machines $i"
elif [ "$os" == "Linux" ] ; then
linux="$linux $i" ; machines="$machines $i"
else
echo "Do not know the $os of $i, skipping"
fi
done
;;
esac
case $arg in
drive | disk | mem | cpu | time | nic)
[[ "$arg" == "drive" ]] && arg=disk
for i in $machines ; do
sudo scp -q ${arg}check $i:/usr/local/etc/emulab
echo -n "$i "
sudo ssh $i "cd /usr/local/etc/emulab; bash /usr/local/etc/emulab/${arg}check /var/emulab/logs/nodecheck.log"
echo ""
done
;;
boot | run )
[[ "$arg" == "boot" ]] && action="boot" || action=''
sudo scp -q rc.nodecheck $i:/usr/local/etc/emulab/rc
for i in $machines ; do
[[ ${linux/${i}//} == ${linux} ]] && echo -n "FreeBSD" || echo -n "Linux"
echo "----------------- $i --------------------"
sudo ssh $i "cd /usr/local/etc/emulab; /usr/local/etc/emulab/rc/rc.nodecheck ${action}"
done
;;
getlogs )
for i in $machines ; do
[[ ${linux/${i}//} == ${linux} ]] && echo -n "FreeBSD" || echo -n "Linux"
echo "----------------- $i --------------------"
sudo ssh $i "cat /var/emulab/logs/nodecheck.log"
done
;;
clearlogs )
for i in $machines ; do
sudo ssh $i "rm -f /var/emulab/logs/nodecheck.log"
done
;;
help | -help | -h | ? )
cat <<EOF
Usage:
Nodes to be operated on $machines
[disk|mem|cpu|diskspeed|time|nic] Update node test and run
[run] Update bootscript and run all the nodetests
[boot] Update bootscript run the nodetests as if run at boot time
[getlog] get and display nodecheck.log files
[clearlog] clear the nodecheck.log files
No argument will update all node with checknode scripts
EOF
;;
* )
for i in $linux
do
echo -n "$i:rc.nodecheck-linux "
sudo scp -p rc.nodecheck ${i}:/usr/local/etc/emulab/rc
# sudo ssh ${i} chown root /usr/local/etc/emulab/rc/rc.nodecheck
# sudo ssh ${i} chgrp root /usr/local/etc/emulab/rc/rc.nodecheck
done
for i in $bsd
do
echo -n "$i:rc.nodecheck-bsd "
sudo scp -p rc.nodecheck ${i}:/usr/local/etc/emulab/rc
# sudo ssh ${i} chown root /usr/local/etc/emulab/rc/rc.nodecheck
# sudo ssh ${i} chgrp wheel /usr/local/etc/emulab/rc/rc.nodecheck
done
for i in $machines
do
echo "${i}:utils "
# sudo rsync -a ${utils} ${i}:/usr/local/etc/emulab
for u in ${utils} ; do
scp -p $u ${i}:/usr/local/etc/emulab
done
# sudo ssh ${i} "cd /usr/local/etc/emulab ; chown root ${utils} "
# sudo ssh ${i} "cd /usr/local/etc/emulab ; chgrp 0 ${utils} "
done
;;
esac
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