diff options
-rw-r--r-- | src/service/LMI_ServiceProvider.c | 4 | ||||
-rw-r--r-- | src/service/util/serviceutil.c | 9 | ||||
-rwxr-xr-x | src/service/util/serviceutil.sh | 19 |
3 files changed, 18 insertions, 14 deletions
diff --git a/src/service/LMI_ServiceProvider.c b/src/service/LMI_ServiceProvider.c index 0381dfa..034418e 100644 --- a/src/service/LMI_ServiceProvider.c +++ b/src/service/LMI_ServiceProvider.c @@ -225,6 +225,10 @@ unsigned int Service_RunOperation(const char *service, const char *operation, CM int res = Service_Operation(service, operation, output, sizeof(output)); if (res == 0) { KSetStatus2(_cb, status, OK, output); + /* serviceutil.sh returns '1' in case of unsupported method, SysV initscript should return '2' + * and print 'Usage:' string when called with unknown operation */ + } else if (res == 1 || res == 2) { + KSetStatus2(_cb, status, ERR_NOT_SUPPORTED, output); } else { KSetStatus2(_cb, status, ERR_FAILED, output); } diff --git a/src/service/util/serviceutil.c b/src/service/util/serviceutil.c index e2a041e..121360d 100644 --- a/src/service/util/serviceutil.c +++ b/src/service/util/serviceutil.c @@ -219,13 +219,12 @@ Service_Operation(const char *service, const char *method, char *result, int res snprintf(cmd, cmd_size, "%s%ul", proc_path, tfd); snprintf(cmdbuffer, OPERATION_BUFSIZE, "%s %s %s > %s", suscript, method, service, cmd); - if (system(cmdbuffer) != 0) { - return -1; - } + + res = system(cmdbuffer); /* we got some output? */ read(tfd, result, resultlen); close(tfd); - res = 0; - return res; + + return WEXITSTATUS(res); } diff --git a/src/service/util/serviceutil.sh b/src/service/util/serviceutil.sh index fa3832b..fcce0b9 100755 --- a/src/service/util/serviceutil.sh +++ b/src/service/util/serviceutil.sh @@ -57,11 +57,12 @@ then elif [ -f $SYSV_SDIR/$2 ]; then case "$1" in - start|stop|reload|restart|condrestart) + start|stop|reload|restart|try-restart|condrestart|reload-or-restart|reload-or-try-restart) $SYSV_SDIR/$2 $1 + exit $? ;; status) - output=`$SYSV_SDIR/$2 status` + output=`LANG=C $SYSV_SDIR/$2 status` if echo "$output" | grep "stopped" > /dev/null 2>&1; then echo "stopped" elif echo "$output" | grep "not running" > /dev/null 2>&1; then @@ -71,16 +72,16 @@ then fi ;; is-enabled) - CUR_RLVL=`runlevel | cut -d " " -f 2` - output=`chkconfig --list tog-pegasus | cut -f $((CUR_RLVL + 2))` - if echo "$output" | grep "on" > /dev/null 2>&1; then + CUR_RLVL=`runlevel | cut -d " " -f 2` + output=`chkconfig --list $2 | cut -f $((CUR_RLVL + 2))` + if echo "$output" | grep "on" > /dev/null 2>&1; then echo "enabled" - elif echo "$output" | grep "off" > /dev/null 2>&1; then + elif echo "$output" | grep "off" > /dev/null 2>&1; then echo "disabled" - fi - ;; + fi + ;; enable) - chkconfig $2 on + chkconfig $2 on ;; disable) chkconfig $2 off |