Rewrite a call to su-exec with su or similar?

In this bash script under Linux Alpine they have (line 8):

exec su-exec "$ZOO_USER" "$0" "$@"

As far as I know, su-exec is however an Apache httpd dependecy - can I avoid it installing it under Ubuntu and use some more plain alternative?

I have tested so far:

 su -c "$0 $@" $ZOO_USER

But then this Docker command shows that I might have some sort of escaping/quotes error,

CMD ["zkServer.sh", "start-foreground"]

resulting in the following output. What is the difference to the original, which works fine?

No passwd entry for user 'start-foreground'
1

1 Answer

As colleagues at DevOps SE have pointed out, the proper usage of ´su´ should be:

su -c "$0" "$ZOO_USER" "$@"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like