- add -d debug option, remove OPTIND shift
- make a couple of messages debug only
- fix a couple of $pidfile references
- kill zombie vbuild processes before exiting...not sure why these
don't die automatically
# Tristan Koo - tristan.koo@intel-research.net
# William Wung - wungism@uclink.berkeley.edu
#
# Tristan Koo - tristan.koo@intel-research.net
# William Wung - wungism@uclink.berkeley.edu
#
+# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (c) 2004 The Trustees of Princeton University (Trustees).
#
# Copyright (c) 2004 The Trustees of Princeton University (Trustees).
#
+# $Id: vcached,v 1.1 2004/07/30 16:46:24 mlh-pl_kernel Exp $
#
# number of images to keep cached
#
# number of images to keep cached
# run in foreground
foreground=0
# run in foreground
foreground=0
-while getopts 'f' OPT ; do
+while getopts 'fd' OPT ; do
case "$OPT" in
f) foreground=1 ;;
case "$OPT" in
f) foreground=1 ;;
done
# check if we are already running
done
# check if we are already running
-trap "rm -f /var/run/vcached.pid && exit 255" EXIT
-echo $$ > /var/run/vcached.pid
+trap "killall -q -w vbuild ; rm -f $pidfile ; exit 255" EXIT
+echo $$ > $pidfile
: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
test -e "$UTIL_VSERVER_VARS" || {
: ${UTIL_VSERVER_VARS:=$(dirname $0)/util-vserver-vars}
test -e "$UTIL_VSERVER_VARS" || {
# loop forever
while : ; do
# loop forever
while : ; do
- echo "$(date) Checking the cache"
+ [ $debug -ne 0 ] && echo "$(date) Checking the cache"
for i in $(seq 0 $(($slots - 1))) ; do
if [ ! -d "$VROOTDIR/.vcache/v$i" ] ; then
echo "$(date) Caching v$i"
for i in $(seq 0 $(($slots - 1))) ; do
if [ ! -d "$VROOTDIR/.vcache/v$i" ] ; then
echo "$(date) Caching v$i"
echo "$(date) v$i ready"
fi
done
echo "$(date) v$i ready"
fi
done
- echo "$(date) Sleeping for $period seconds"
+ [ $debug -ne 0 ] && echo "$(date) Sleeping for $period seconds"