run command as user
hey
quick question in my /etc/rc.d/rc.local file, i am adding a command to start my teamspeak server on the boot of my webserver....everything ok, right? BUT, i dont want to run it as root, ive configured this user "tss" to be able to run the teamspeak server with the command: sh /home/httpd/vhosts/bfserver.com/games/tss2_rc2/teamspeak2-server_startscript start which is in the file which has: #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local sh /home/httpd/vhosts/bfserver.com/games/tss2_rc2/teamspeak2-server_startscript start SO..... how can i run this at startup as my user tss instead of root? thanks |
hah, also so the server shutsdown cleanly at a reboot, where would i put the stop command for the teamspeak server?
|
for doing stuff as other users without logging in, I think the command is "su user -c command". For shutting down the server, put something in the equavalent of /etc/rc.d/rc.0 on FC.
|
Quote:
http://www.gsp.com/cgi-bin/man.cgi?section=1&topic=su on there it says it would ask for a password...its a remote webserver so i wouldent be able to type one in...how would i handle this?? and im on redhat9...so would the file still be rc.0? |
Root can run "su <someuser>" without having to enter a password. If you just want to execute one command su'd instead of starting a shell logged in as that user, you use the -c option. So it'd be 'su -c "<command to run>" <user>'.
As for shutdown, most distributions have scripts that are used when you change runlevels (shutdown is changing to runlevel 0, reboot is changing to runlevel 6). So you need to find where Red Hat stores scripts for these runlevels, and add the command to stop the server there. I'm not 100% sure, but I think if you create /etc/rc.d/rc0.d/K??teamspeak, and /etc/rc.d/rc6.d/K??teamspeak (replace ?? with numbers... the scripts in the directory will execute in the order they're numbered), and put the commands in there (make sure that the files are executable), that might do it. |
ok so i tried running this from the terminal as user tss:
su tss -c sh /home/httpd/vhosts/bfserver.com/games/tss2_rc2/teamspeak2-server_startscript.sh start it then asked for my password, which i typed in, then it prompts: sh-2.05b$ (cursor) and i enter in /home/httpd/vhosts/bfserver.com/games/tss2_rc2/teamspeak2-server_startscript.sh start, and it starts the server.... so i need a way to automate this |
Quote:
and i understant if im asking from root to run as tss i shouldent need a password...but read the last post I made, and see that it requireds a 2nd command after the first..hmmmm |
hmm now i get this when running root
[root@BFSERVER root]# su tss -c sh /home/httpd/vhosts/bfserver.com/games/tss2_rc2/teamspeak2-server_startscript start bash: /root/.bashrc: Permission denied sh-2.05b$ |
bumpatize me captin
|
cmon guys please.....lol
|
All times are GMT -5. The time now is 04:57 AM. |