Bug 461747 - rhn-proxy init script always gives 0 exit code
rhn-proxy init script always gives 0 exit code
Status: CLOSED CURRENTRELEASE
Product: Spacewalk
Classification: Community
Component: Proxy Server (Show other bugs)
0.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Miroslav Suchý
Red Hat Satellite QA List
:
Depends On:
Blocks: space03
  Show dependency treegraph
 
Reported: 2008-09-10 08:24 EDT by Rob James
Modified: 2009-09-17 03:01 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-09-17 03:01:20 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
rhn-proxy init script patch (2.51 KB, patch)
2008-09-10 08:24 EDT, Rob James
no flags Details | Diff

  None (edit)
Description Rob James 2008-09-10 08:24:38 EDT
Created attachment 316304 [details]
rhn-proxy init script patch

Currently the rhn-proxy init script returns 0 no matter what, e.g.:

# service rhn-proxy status
squid is stopped
squid: ERROR: No running copy
httpd is stopped
jabberd router is stopped
# echo $?
0

This patch adds a sensible exit code. It's not LSB compliant since services may have different error code (eg. squid may be "3" and httpd may be "1")

The patch also removes reload being an alias to restart so we don't pretend to implement something we don't. Finally, it also adds condrestart.
Comment 1 Miroslav Suchý 2008-09-11 09:37:25 EDT
I see  problem with this patch:

a) if proxy is not running and you do restart, then the stop action will fail and you carry on the non-zero further. This can be however resolved like:
restart() {
    stop
    RETVAL=0
    sleep 2
    start
}

I done it in commit 873614640c254905a4bd7059b5e3b561310824b7
where I done other minor fixing:
 - add LSB header to initscript and 
 - do not enable proxy if user previously disabled it
Comment 2 Jan Pazdziora 2008-11-05 04:40:04 EST
The bugzilla is not clear whether it only concerns rhn-proxy status or also other rhn-proxy's activities but the example mentions rhn-proxy status, and that seems to return 0 when proxy is running and 1 when it is not. So moving to VERIFIED.

[root@vmware188 ~]# service rhn-proxy status
squid (pid 32669) is running...
httpd (pid 32717 32715 32714 32713 32712 32711 32710 32709 32690) is running...
jabberd router (pid 32730) is running...
[root@vmware188 ~]# echo $?
0
[root@vmware188 ~]# /etc/init.d/rhn-proxy stop
Shutting down rhn-proxy...
Shutting down Jabber router:                               [  OK  ]
Stopping httpd:                                            [  OK  ]
Stopping squid:                                            [  OK  ]
Done.
[root@vmware188 ~]# service rhn-proxy status
squid is stopped
squid: ERROR: No running copy
httpd is stopped
jabberd router is stopped
[root@vmware188 ~]# echo $?
1
[root@vmware188 ~]# /etc/init.d/rhn-proxy start
Starting rhn-proxy...
Starting squid: .                                          [  OK  ]
Starting httpd:                                            [  OK  ]
Starting Jabber services                                   [  OK  ]
Done.
[root@vmware188 ~]# service rhn-proxy status
squid (pid 505) is running...
httpd (pid 563 562 561 560 559 558 557 556 526) is running...
jabberd router (pid 567) is running...
[root@vmware188 ~]# echo $?
0
[root@vmware188 ~]# killall httpd
[root@vmware188 ~]# killall httpd
httpd: no process killed
[root@vmware188 ~]# service rhn-proxy status
squid (pid 505) is running...
httpd dead but subsys locked
jabberd router (pid 567) is running...
[root@vmware188 ~]# echo $?
1
Comment 3 Miroslav Suchý 2009-09-17 03:01:20 EDT
Spacewalk has been released for some time.

Note You need to log in before you can comment on or make changes to this bug.