#!/bin/sh

USER="root"
if [ ! -z "$GROUP_ID" ] && [ ! -z "$USER_ID" ] ; then
	deluser rancherize > /dev/null 2>&1
	addgroup -g $GROUP_ID rancherize
	adduser -u $USER_ID -G rancherize -D -s /bin/sh rancherize
	USER="rancherize"
fi

if [ -x "$1" ] ; then
	su-exec "$USER" $*
	exit $?
fi

su-exec "$USER" php /opt/rancherize/rancherize $@
#!/bin/sh

USER="root"
if [ ! -z "$GROUP_ID" ] && [ ! -z "$USER_ID" ] ; then
	deluser rancherize > /dev/null 2>&1
	addgroup -g $GROUP_ID rancherize
	adduser -u $USER_ID -G rancherize -D -s /bin/sh rancherize
	USER="rancherize"
fi

if [ hash "$1" ] ; then
	su-exec "$USER" $*
	exit $?
fi

su-exec "$USER" php /opt/rancherize/rancherize $@

Use hash to check for regular command
Use hash to check for regular command

optimize for #34