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 the call through Docker CMD shows that I might have some sort of escaping/quotes error,
CMD ["zkServer.sh", "start-foreground"]
resulting in the following output; obviously there is a misplacement for the username field in the command sequence.
No passwd entry for user 'start-foreground'
But what is then the difference to the original (su-exec), which works fine? And how to get it right with su?
====
UPD: su-exec is here a third-parthy Alpine Linux package https://github.com/ncopa/su-exec
su, as such it's usually better, add--to separate su option from shell options of -c. I.e:su -c "$0" "$ZOO_USER" -- "$@"to avoid an argument of the command to be taken bysu– Tensibai Nov 10 '17 at 16:24$ZOO_USERneed to be the last argument? – chicks Nov 10 '17 at 16:25su [options] [username], as suchsu -c command username -- remaining options to pass to command– Tensibai Nov 10 '17 at 16:25-cand not the username. – Tensibai Nov 10 '17 at 16:27su username -- -c command argsin fact. (nice catch for the order problem anyway, it didn't strike me when reading the question) – Tensibai Nov 10 '17 at 16:32suwould be in Alpine Linux and it doesn't support additional arguments according to the docs. – chicks Nov 17 '17 at 04:01