Re: script to turn off services

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 16 Aug 2006, Bill Tangren wrote:

> I am trying to write a script that will turn off unneeded services, but I am
> not having any luck. I have tried the following:
> 
> service bluetooth status > /dev/null 2>&1
> EXITVALUE=$?
> if [ $EXITVALUE == 0 ]; then
>    service bluetooth stop
>    chkconfig --level 345 bluetooth off
> fi
> 
> 
> This works if bluetooth is not installed, but not if it IS installed and
> already turned off. In that case, the service command returns zero and the if
> block is executed.
> 
> Does anyone know how to modify this script so that it will run (or tell me
> where I can learn how to modify it)?

The problem is in the bluetooth sysv script. As you probably have noticed, 
for most services this is no problem:

	[root@server1 root]# service gpm status
	gpm is stopped
	[root@server1 root]# echo $?
	3
	[root@server1 root]# service ntpd status
	ntpd (pid 12400) is running...
	[root@server1 root]# echo $?
	0
	[root@server1 root]# service bluetooth status
	bluetooth: unrecognized service
	[root@server1 root]# echo $?
	1
But
	[root@server1 root]# service bluetooth status
	hcid is stopped
	sdpd is stopped
	hidd is stopped
	[root@server1 root]# echo $?
	0

If you look inside the script, you can see that the return code is not 
being captured. Which one should it capture and exit with ?

For other services, where there's only one process to check, it's quite 
simple. Here the solution could be to return 0 if all services are 
running. (ie. take the sum of the return codes)

If you think this is a defect and you expected something else. Open a 
bugreport in bugzilla and then do a support call and point to this 
bugzilla entry.

Kind regards,
--   dag wieers,  dag@xxxxxxxxxx,  http://dag.wieers.com/   --
[all I want is a warm bed and a kind word and unlimited power]

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux