linux - run master process as root

This commit is contained in:
bunkerity 2021-07-07 13:38:13 +02:00
parent deb28c5991
commit 2c9c9fb62c
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C

View File

@ -4,7 +4,11 @@ function do_and_check_cmd() {
if [ "$CHANGE_DIR" != "" ] ; then if [ "$CHANGE_DIR" != "" ] ; then
cd "$CHANGE_DIR" cd "$CHANGE_DIR"
fi fi
output=$(su -s "/bin/bash" -c "$1" nginx 2>&1) if [ "$AS_ROOT" != "" ] ; then
output=$("$@" 2>&1)
else
output=$(su -s "/bin/bash" -c "$1" nginx 2>&1)
fi
ret="$?" ret="$?"
if [ $ret -ne 0 ] ; then if [ $ret -ne 0 ] ; then
echo "[!] Error from command : $*" echo "[!] Error from command : $*"
@ -42,7 +46,7 @@ if [ -f "/tmp/nginx.pid" ] ; then
# Otherwise start it # Otherwise start it
else else
echo "[*] Start nginx" echo "[*] Start nginx"
do_and_check_cmd "nginx -g 'daemon on;'" AS_ROOT="yes" do_and_check_cmd nginx -g 'daemon on; user nginx;'
fi fi
# Run post-jobs # Run post-jobs