[CentOS] yum check-updates script not working correctly

Ljubomir Ljubojevic office at plnet.rs
Thu May 26 19:23:46 UTC 2011


Leonard den Ottolander wrote:
> Hello Brian,
> 
> On Tue, 2011-05-24 at 18:52 -0400, brian wrote:
>> if [ -f /var/lock/subsys/yum ]; then
>>
>>           if [ ${CHECKONLY} = "yes" ];then
>>
>>                  /usr/bin/yum-check
>>           fi
>>           else
>>                  /usr/bin/yum -R 10 -e 0 -d 0 -y update yum
>>                  /usr/bin/yum -R 120 -e 0 -d 0 -y update
>> fi
> 
>> in /etc/sysconfig/yum-check:
>> ---------------------- yum-check -------------------------
>> # yes sets yum to check for updates and mail only if patches are available
>> # no does enable autoupdate if /var/lock/subsys/yum is available
>> CHECKONLY="yes"
> 
> Seems like poor logic nesting if you read the comment above. Auto update
> should only happen if both $CHECKONLY is set to "no"
> *and* /var/lock/subsys/yum is a file.
> 
> if [ $CHECKONLY == "yes" ]; then
> 	/usr/bin/yum-check
> else
> 	if [ -f /var/lock/subsys/yum ]; then
> 		/usr/bin/yum -R 10 -e 0 -d 0 -y update yum
> 		/usr/bin/yum -R 120 -e 0 -d 0 -y update
> 	fi
> fi
> 
> is how this should read according to that comment. If you set CHECKONLY
> to "no" you still have to touch /var/lock/subsys/yum to actually have
> yum autoupdate.
> 
> Regards,
> Leonard.
> 
OP never answered my question if $CHECKONLY is in fact not empty.

So:

echo "CHECKONLY is $CHECKONLY"
echo "{CHECKONLY} is ${CHECKONLY}"
is for starters.

And I would change this to:

if [ $CHECKONLY == "no" ]; then
	if [ -f /var/lock/subsys/yum ]; then
		/usr/bin/yum -R 10 -e 0 -d 0 -y update yum
		/usr/bin/yum -R 120 -e 0 -d 0 -y update
	fi
else
	/usr/bin/yum-check
fi

This way, if $CHECKONLY is empty script will just check, not update.

Ljubomir



More information about the CentOS mailing list