Browse Source

set script name correctly when invoked via sysv-style init

Niklas Aldergren 11 years ago
parent
commit
671620e5a7
1 changed files with 10 additions and 1 deletions
  1. 10 1
      extra/centos/celeryd

+ 10 - 1
extra/centos/celeryd

@@ -28,7 +28,16 @@
 #
 # Setting `prog` here allows you to symlink this init script, making it easy
 # to run multiple processes on the system.
-prog="$(basename $0)"
+
+# If we're invoked via SysV-style runlevel scripts we need to follow the 
+# link from rcX.d before working out the script name.
+if [[ `dirname $0` == /etc/rc*.d ]]; then
+    target="$(readlink $0)"
+else
+    target=$0
+fi
+
+prog="$(basename $target)"
 
 # Source the centos service helper functions
 source /etc/init.d/functions