• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

Resolved How use command runuser with vhost user?

Azurel

Silver Pleskian
I have a bash script with this command

USER="myvhostuser"
runuser -l "$USER" -c "$DAEMON $SERVER >> $LOG_FILE &" && echo_success || echo_failure

With USER="root" its working fine, but with USER="myvhostuser" its failed. How I can use this with user from a plesk subscription (vhost domain)?

/var/www/vhosts/example.com
Owner: myvhostuser
Group psaserv

For security reason I can't use the bash with "root" user.

I hope anyone understand what I mean. ^^
 
Hi Azurel,

the command "runuser" may ONLY be executed by the user "root". ( should be documented within your man - pages as well. ;) )

( Pls. remember, that this is not a PLESK - related topic, so pls. consider to open a thread at => Home > Forum > General Discussion > Open Topics for such topics )
 
Yes, I want execute it with "root" but run as user (security reason).

I want execute a nodejs bot. Manual I do it successful with
# /opt/plesk/node/7/bin/node /var/www/vhosts/example.com/nodejs/client.js

But that script stops after close shell console. I wrote a bash script, so I can start and stop the bot like
# sh /var/www/vhosts/example.com/nodejs/bot.sh start

USER="myvhostuser"
DAEMON="/opt/plesk/node/7/bin/node"
ROOT_DIR="/var/www/vhosts/example.com/nodejs"
SERVER="$ROOT_DIR/client.js"
runuser -l "$USER" -c "$DAEMON $SERVER >> $LOG_FILE &" && echo_success || echo_failure

When I not want run this as root, as what then? The username of subscription and owner of vhost folder "example.com" not working. (The "bot.sh" working fine with "root" as user)


EDIT:
Maybe the problem ist with "/opt/plesk/node/7/bin/node" (installed with nodejs plesk extension) its owned by root (Owner/Group)
 
Last edited:
Hi Azurel,

runuser -l "$USER" -c "$DAEMON $SERVER >> $LOG_FILE &" && echo_success || echo_failure
If you desire to use the "-u" string in front of your "$USER", you should as well use it within your command. ;)
 
Hi Azurel,

runuser have no -u parameter
Interesting... well, let's quote from your link then :rolleyes::
runuser [options] -u user [[--] command [argument...]]

runuser [options] [-] [user [argument...]]

... AND ...
Code:
...
      If the option -u is not given, it falls back to su-compatible
      semantics and a shell is executed. ...
 
Back
Top