yast -i somesoftware fails with: another process is accessing the database

I am using autoyast to install many things in my initscript. on slower machines I sometimes get the above error however never on faster machines... here is part of our initscript to help document the issue:


# Register with ZLM and perform RUG UPDATE
/bin/echo 'registering to ZLM'
/usr/bin/rug shutdown -f; rm /var/lib/zmd/services; /usr/sbin/rczmd start
/usr/bin/rug set require-verified-certs false; /usr/bin/rug set security-level checksum
/usr/bin/rug sa https://zlm1lx -k SLED10SP2-PROD
/bin/echo 'registration to ZLM complete'

/usr/bin/rug sub SLED-CUSTOM-APPS ZLM72IR2-Hot-Patch
/usr/bin/rug sa --type=zypp nfs://zlm1lx/install/sled10sp2_prod/sled10sp2_i386 "SLED10SP2-Distro"; /usr/bin/rug sub "SLED10SP2-Distro"

# on very slow optiplex machines, the following sleep 30 was not enough to guarantee that the "rug up -y" would work so we are adding in addition a rug shutdown and zmd restart to see if that fixes the issue (march 12, 09)

sleep 30; /usr/bin/rug shutdown -f; /usr/sbin/rczmd start; sleep 45
/usr/bin/rug up -y; /bin/echo 'Updates from ZLM complete'; sleep 30

# Install Novell Client and Custom Novell Client Single Signon Package
# This also allows all updates to be included as an add-on location including the latest kernel :)
/sbin/yast -i novell-client novell-filesystem novell-konqueror-plugin novell-nautilus-plugin novfs-kmp-default novfs-kmp-smp

/bin/rpm -U --nodeps --force /net/zlm1lx/install/sled10sp2_prod/software/ncl_ss_pamscript/ncl_ss_pamscript-1.0-rpmpm.i586.rpm


notice the sleep commands... I had to do this to get older machines to work, however even the 30 to 45 seconds is not long enough to fix all slow machines... this is really frustrating. Can anyone enlighten me on how I can actually check to see (using bash scripts) if the rpm database is now ready for another yast -i command? I have looked into rug and rpm commands to see if there some way to report on rpm database status, I looked to see if ps would report something helpful and also if lock files or lsof would cleanly report if the rpm database was in use, but I am so far not able to find a clear way to see if the package database is not ready for a yast installation I would like to add a loop that checks this, would wait till the database is ready, then have my autoyast initscript run the required yast -i commands as needed.

Does anyone have any good ideas on this?