Ver Fonte

set script name correctly when invoked via sysv-style init

Niklas Aldergren há 11 anos atrás
pai
commit
671620e5a7
1 ficheiros alterados com 10 adições e 1 exclusões
  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