Hey guys,
I'm both new to Linux and to this Forum.
I own a virtual CentOS6 server and I'm hosting x1 website and 1x teamspeak 3 server in there, now I'm trying to create a auto run script to my teamspeak but I'm having trouble running that script in a normal user account, root I was able to set it up.
The autostart script I'm trying using is this one:
Code:
#!/bin/sh
# chkconfig: 2345 99 10
# description: Started and Stop the TeamSpeak 3 Server
#
# Modified for working in CentOS 5.4 Systems (and maybe others)
#
USER="MYUSER" # TS3 User
TS3='/home/MYUSER/ts' # Script Location
STARTSCRIPT="$TS3/ts3server_startscript.sh" # Startscript for TS3
cd $TS3
case "$1" in
'start')
su $USER -c "$STARTSCRIPT start"
;;
'stop')
su $USER -c "$STARTSCRIPT stop"
;;
'restart')
su $USER -c "$STARTSCRIPT restart"
;;
'status')
su $USER -c "$STARTSCRIPT status"
;;
*)
echo "Usage $0 start|stop|restart|status"
esac
When I try to run this script in root, I get this error and the server will not start:
"Starting the TeamSpeak 3 server
/home/MYUSER/ts/ts3server_startscript.sh: line 68: ts3server.pid: Permission denied
TeamSpeak 3 server started, for details please view the log file"
Please note:
1. I've created a "
ts" file in /etc/init.d/ folder.
2. I gave it "
chmod 755 /etc/init.d/ts" for permission.
3. I've add "
chkconfig --level 2345 ts on" to the starting services.
I manage to run this script if I change the
MYUSER to
ROOT in the script file, but then the TS server will run as root and for what I've read, that's very dangerous...
Can some one please give me a hand with this? I'm lost here..