diff options
author | Peter Jones <pjones@redhat.com> | 2007-03-14 16:40:30 +0000 |
---|---|---|
committer | Peter Jones <pjones@redhat.com> | 2007-03-14 16:40:30 +0000 |
commit | 38f98cdf639b69a6a7896753691d8a6a78a50669 (patch) | |
tree | 5b39fe226f288fd12da3eb09bd4a67bce8698f71 /pm/functions | |
parent | 264aea5efe616901dcf8183d428ae4a43d9b2a5a (diff) |
- use 'service' rather than calling init.d files directly
Diffstat (limited to 'pm/functions')
-rwxr-xr-x | pm/functions | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/pm/functions b/pm/functions index 34a0794..8ea704d 100755 --- a/pm/functions +++ b/pm/functions @@ -229,22 +229,34 @@ modreload() fi } +_service=$(type -p service) +if [ -z "$_service" ]; then + service() { + if [ -x "/etc/init.d/$1" ]; then + "/etc/init.d/$@" + else + echo "$1" $": unrecognized service" 1>&2 + return 1 + fi + } +fi +unset _service + stopservice() { service "$1" status 2>/dev/null | grep -c -q running - if [ "$?" == "0" -a -x "/etc/init.d/$1" ]; then + if [ "$?" == "0" ]; then N=${1//[_.]/_} echo "export ${N}_SERVICE_ACTIVATE=yes" >> /var/run/pm-suspend - "/etc/init.d/$1" stop 2>&1 + service "$1" stop fi } restartservice() { N=${1//[-.]/_} - if [ "x$(eval echo \$${N}_SERVICE_ACTIVATE)" == "xyes" \ - -a -x "/etc/init.d/$1" ]; then - "/etc/init.d/$1" start 2>&1 + if [ "x$(eval echo \$${N}_SERVICE_ACTIVATE)" == "xyes" ]; then + service "$1" start fi } |