LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 08-21-2012, 06:45 AM   #1
Kuimera
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Rep: Reputation: Disabled
Teamspeak 3 autostart script


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..

Last edited by Kuimera; 08-21-2012 at 06:46 AM.
 
Old 08-21-2012, 07:30 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
I have a startup line for a ts3 server inside of /etc/rc.local. Which should be the same as having it in /etc/init.d and setting it up to autostart.
Heres the line I have
Code:
#!/bin/sh -e
#
# rc.local
sudo -u teamspeaker /home/teamspeaker/ts3/ts3server_startscript.sh start
exit 0
Dunno where the exact difference between su -C and sudo is but it works for me.

Regarding the error message it is just that the file ts3server.pid could not be created or belongs to another user. I guess it is owned by root due to previous startups with that user. Do a ls -lh /home/MYUSER/ts and see who ownes the file and what permission are on it.
What i wonder about is that line 68 is part of the stop routine:
Code:
stop)
                if [ -e ts3server.pid ]; then
                        echo -n "Stopping the TeamSpeak 3 server"
                        if ( kill -TERM $(cat ts3server.pid) 2> /dev/null ); then
                                c=1
                                while [ "$c" -le 300 ]; do
                                        if ( kill -0 $(cat ts3server.pid) 2> /dev/null ); then
                                                echo -n "."
                                                sleep 1
                                        else
                                                break
                                        fi
                                        c=$((++c))
                                done
                        fi
 
Old 08-21-2012, 07:43 AM   #3
Kuimera
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for the quick reply zhjim!

Well, I did what you told me, I got this:

Code:
drwxr-xr-x  8 1000 1000 4.0K Aug 21 08:16 ./
drwx--x--x 15 MYUSER MYUSER  4.0K Aug 20 14:27 ../
-rw-r--r--  1 1000   1000    38K Jun 29 09:01  CHANGELOG
-rw-r--r--  1 1000   1000    24K Jun 29 09:01  LICENSE
drwxr-xr-x  2 1000   1000    4.0K Jun 29 09:01 doc/
drwx------  5 root   root    4.0K Aug 19 17:07 files/
-rwxr-xr-x  1 1000   1000    213K Jun 29 09:01 libts3db_mysql.so*
-rwxr-xr-x  1 1000   1000    1.1M Jun 29 09:01 libts3db_sqlite3.so*
drwx------  2 root   root    4.0K Aug 19 19:45 logs/
-rw-rw-r--  1 root   root       1 Aug 18 21:30 query_ip_blacklist.txt
-rw-rw-r--  1 root   root      10 Aug 18 21:30 query_ip_whitelist.txt
drwxr-xr-x  2 1000   1000    4.0K Jun 29 09:01 serverquerydocs/
drwxr-xr-x  4 1000   1000    4.0K Jun 29 09:01 sql/
-rw-rw-r--  1 root   root     298 Aug 18 21:30 ts3server.ini
-rw-r--r--  1 root   root    238K Aug 21 08:16 ts3server.sqlitedb
-rwxr-xr-x  1 1000   1000    5.4M Jun 29 09:01 ts3server_linux_amd64*
-rwxr-xr-x  1 1000   1000    1.2K Jun 29 09:01 ts3server_minimal_runscript.sh*
-rwxr-xr-x  1 1000   1000    3.7K Jun 29 09:01 ts3server_startscript.sh*
drwxr-xr-x  2 1000   1000    4.0K Jun 29 09:01 tsdns/
Not sure what that "1000" that comes up allot tho.
 
Old 08-21-2012, 08:38 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
The 1000 is the user that owns the files. Do a "grep 1000 /etc/passwd" to see if there is a user associated with.
To solve the problem do a "chown myuser:myuser /home/MYUSER/ts -R" as root. With that you have all the files belonging to the user and specially the directory so the pid file can be created.
 
Old 08-21-2012, 09:55 AM   #5
Kuimera
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
zhjim,


the premission worked, but when I do a "service ts start" it says the server started but it's not running @ all.. when I do a status check using the script, it says this:

Code:
root@ip-***-***-**-*** [/home/MYUSER]# service ts status
Server seems to have died
the command: "grep 1000 /etc/passwd" does not seem to work, I push enter and he just change line and says nothing, weird...


Your scrip seems much more simple, I will try that one and see how it goes..
 
Old 08-21-2012, 10:36 AM   #6
Kuimera
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Ok I tried your script, same thing happens, when I "service ts" I get this:

Code:
root@ip-146-255-34-134 [/etc/init.d]# service ts start
Starting the TeamSpeak 3 server
TeamSpeak 3 server started, for details please view the log file

here's the log file:

Code:
2012-08-21 15:33:44.156942|INFO    |ServerLibPriv |   | TeamSpeak 3 Server 3.0.6.1 (2012-06-29 07:59:05)
2012-08-21 15:33:44.157348|INFO    |DatabaseQuery |   | dbPlugin name:    SQLite3 plugin, Version 2, (c)TeamSpeak Systems GmbH
2012-08-21 15:33:44.157389|INFO    |DatabaseQuery |   | dbPlugin version: 3.7.3
2012-08-21 15:33:44.157693|INFO    |DatabaseQuery |   | checking database integrity (may take a while)
2012-08-21 15:33:44.203323|WARNING |Accounting    |   | Unable to find valid license key, falling back to limited functionality
2012-08-21 15:33:44.705167|ERROR   |Accounting    |   | failed to register local accounting service
2012-08-21 15:33:44.705242|ERROR   |ServerLibPriv |   | Server() error while starting servermanager, error: instance check error
please advise m8
 
Old 08-22-2012, 01:01 AM   #7
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
I think that both scripts will work when everything else is sorted.
I googled up the line with "ERROR |Accounting | | failed to register local accounting service" and it seems a problem with a file in /dev/shm. See if you have a file like 7gbhujb54g8z9hu43jre8 and delete it.
If this does not help you have to take a closer look at the startup log file. Rename the old one to have only the last startup inside the file. If there are no more errors inside the log you might have to use strace to get down to the nitty gritty. But before this I would get a license file might solve it.
 
Old 01-25-2015, 02:02 AM   #8
sethuper
LQ Newbie
 
Registered: Oct 2013
Posts: 3

Rep: Reputation: Disabled
Talking this will help

I have followed step by step in this tutorial, everything is describe, how to install and configure TeamSpeak3 server with MySQL - MariaDB on Debian/Ubuntu.

http://terminal28.com/how-to-install-and-configure-teamspeak3-server-linux-debian-ubuntu/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] autostart script imatinkerer Linux - Newbie 13 05-07-2011 05:15 PM
KDE 4 Autostart Program Bash Script to Write Autostart Bash Scripts for You! jdmcdaniel3 SUSE / openSUSE 1 05-03-2010 06:17 AM
Shell script adding autostart gnome script Coolrunr Programming 3 01-01-2009 02:23 PM
AutoStart a Script extremebfn Slackware 2 09-11-2004 09:25 PM
How can I autostart a (teamspeak) server! eugeny Linux - Software 0 02-11-2004 01:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration