Browse Source

Merge branch 'OEP/fix-inits'

Ask Solem 11 years ago
parent
commit
49f2da6ac2
2 changed files with 14 additions and 12 deletions
  1. 7 6
      extra/generic-init.d/celerybeat
  2. 7 6
      extra/generic-init.d/celeryd

+ 7 - 6
extra/generic-init.d/celerybeat

@@ -23,7 +23,7 @@
 VERSION=10.0
 echo "celery init v${VERSION}."
 
-if [ $(id -u) ne 0 ]; then
+if [ $(id -u) -ne 0 ]; then
     echo "Error: This program can only be used by the root user."
     echo "       Unpriviliged users must use 'celery beat --detach'"
     exit 1
@@ -43,10 +43,11 @@ SCRIPT_NAME="$(basename "$SCRIPT_FILE")"
 # Make sure executable configuration script is owned by root
 _config_sanity() {
     local path="$1"
-    local owner=$(stat -Lr "$path" | awk '{print $5}')
-    local perm=$(stat -Lr "$path" | awk '{print $3}')
+    local owner=$(ls -ld "$path" | awk '{print $3}')
+    local iwgrp=$(ls -ld "$path" | cut -b 6)
+    local iwoth=$(ls -ld "$path" | cut -b 9)
 
-    if [ "$owner" != "0" ]; then
+    if [ "$(id -u $owner)" != "0" ]; then
         echo "Error: Config script '$path' must be owned by root!"
         echo
         echo "Resolution:"
@@ -58,7 +59,7 @@ _config_sanity() {
         exit 1
     fi
 
-    if [ "$(($perm & 02))" -ne 0 ]; then  # S_IWOTH
+    if [ "$iwoth" != "-" ]; then  # S_IWOTH
         echo "Error: Config script '$path' cannot be writable by others!"
         echo
         echo "Resolution:"
@@ -69,7 +70,7 @@ _config_sanity() {
         echo "    $ sudo chmod 640 '$path'"
         exit 1
     fi
-    if [ "$(($perm & 020))" -ne 0 ]; then  # S_IWGRP
+    if [ "$iwgrp" != "-" ]; then  # S_IWGRP
         echo "Error: Config script '$path' cannot be writable by group!"
         echo
         echo "Resolution:"

+ 7 - 6
extra/generic-init.d/celeryd

@@ -30,7 +30,7 @@
 #
 VERSION=10.0
 echo "celery init v${VERSION}."
-if [ $(id -u) ne 0 ]; then
+if [ $(id -u) -ne 0 ]; then
     echo "Error: This program can only be used by the root user."
     echo "       Unprivileged users must use the 'celery multi' utility, "
     echo "       or 'celery worker --detach'."
@@ -58,10 +58,11 @@ CELERY_DEFAULTS=${CELERY_DEFAULTS:-"/etc/default/${SCRIPT_NAME}"}
 # Make sure executable configuration script is owned by root
 _config_sanity() {
     local path="$1"
-    local owner=$(stat -Lr "$path" | awk '{print $5}')
-    local perm=$(stat -Lr "$path" | awk '{print $3}')
+    local owner=$(ls -ld "$path" | awk '{print $3}')
+    local iwgrp=$(ls -ld "$path" | cut -b 6)
+    local iwoth=$(ls -ld "$path" | cut -b 9)
 
-    if [ "$owner" != "0" ]; then
+    if [ "$(id -u $owner)" != "0" ]; then
         echo "Error: Config script '$path' must be owned by root!"
         echo
         echo "Resolution:"
@@ -73,7 +74,7 @@ _config_sanity() {
         exit 1
     fi
 
-    if [ "$(($perm & 02))" -ne 0 ]; then  # S_IWOTH
+    if [ "$iwoth" != "-" ]; then  # S_IWOTH
         echo "Error: Config script '$path' cannot be writable by others!"
         echo
         echo "Resolution:"
@@ -84,7 +85,7 @@ _config_sanity() {
         echo "    $ sudo chmod 640 '$path'"
         exit 1
     fi
-    if [ "$(($perm & 020))" -ne 0 ]; then  # S_IWGRP
+    if [ "$iwgrp" != "-" ]; then  # S_IWGRP
         echo "Error: Config script '$path' cannot be writable by group!"
         echo
         echo "Resolution:"