Spartanfrog Wrote:Yeah your right lol. I know muppet was looking for beta testers for a control panel. Shoot him a PM.
Not me I already have one - the guy you're looking for is Masher.
Linux init script to start server on boot
|
Spartanfrog Wrote:Yeah your right lol. I know muppet was looking for beta testers for a control panel. Shoot him a PM. Not me I already have one - the guy you're looking for is Masher.
12-14-2007, 11:12 AM
O crap yeah Im sorry. Too many M's and its too late lol.
realchamp Wrote:Hazz Wrote:Has someone helped you on these forums? If so, help someone else Mooga Wrote:OrangeBox is a WHORE.
12-21-2007, 10:43 PM
(This post was last modified: 12-22-2007, 01:42 AM by Eternal Bliss.)
Nice script, but i'm trying to modify it so it will run as a user(su - srcds) but without any luck
Could you give me a hand here? Code: #!/bin/sh
04-23-2008, 02:54 AM
Hey folks!
Long time to see, eh? I put my SRCDS mini-projects on hiatus for a while, but now I'm back and hopefully I have helpful scripts to share! First up is a TF2 Linux server install script. It's in no way what I would consider completed form. It will work as advertised (install a TF2 server) but there is just so much more I would like to add (server.cfg autocreation, interactive setup mode, etc.) Hope you enjoy and, as always, suggestions, comments and concerns are always welcome. Cheers! Dan Code: #!/usr/bin/env bash
Thanks for such great scripts Scriptfu.
I went and edited your init script for functions I needed. I still gotta get some more stuff in there but this one will allow the server to keep running even if the whole machine was rebooted and pid remained. Comand List: start|stop|restart|clear|update start: will check the game folder for pid then verify if that pid is running on the server. If it is not it will then delete the pids and then start the server. If the server is running it will exit out like before. stop: Acts the same only changed the AND to OR incase there is still a left over pid it will go through and clean up anything left. restart: Behaves the same calling the stop and start commands like normal. clear: Not really needed anymore but I left it in incase one wanted to clean up pid files after manually killing the server and screen. update: will run the stop command and clear command. Then will update steam and run the game update. After the update finishes the server will be started. The changes made will allow you to crontab a the start and update commands with out having to worry about orphen pids not allowing the server starting up. You can @reboot the start command and have it or have it run as often as you want to keep the server running incase of hard crash. I'll be adding more changes and updates as the need arises for me. Code: #Source Dedicated Server Init Script
09-11-2008, 06:42 PM
scriptfu Wrote:Hi everyone, A small change in the above script could be this: Code: USER_NAME="tf2" and for starting the app: Code: if [ "$CURRENT_USER" = "$USER_NAME" ]; then A chrooted environment setup would be interesting to see.
09-11-2008, 11:00 PM
ogre.
su would work since we just be using it for the server startup command. It just needs to be run by root or the actually user. I forget these things but I think any user that doesn't have the right to run as the intended user will prompt for password. Would be fine if its intended during that case to be used by an actual user. It would render the script useless in cronjobs. Wasn't going to test this but it just peaked my interest and now I am not sleeping. oh well. I did get it to work. There should be no need for all the if statements since sudo will run with whatever user you set it to even if its the same user running it but I think you need to do a little bit more on the system side by adding the user into sudoers so for the sake of saving additional headaches I will just use the if statements. Also this is just changing for the server start up I didn't add it in for updating. but if you just follow the same idea below it would work. If you want to to this just replace the line Code: # Screen command with Code: # Screen command and after Code: chmod 666 $STEAM/$GAME/*.pid 1> /dev/null 2> /dev/null add Code: # Make any pid files created by different users owned by the set user. Updated with working changes. Code: Code:
09-12-2008, 07:28 PM
Arujei Wrote:ogre. I run my cronjobs related to that user as that user, so cron jobs work fine. As you say, when i use su I don't have to add sudoers. Since only root and the actual user should be able to run the file it works fine for my purposes.
Thanks Arujei, if users want to know how to protect this as well, here it is, copy everything Arujei updated:
Since it isn't a great idea to run this script as root, specifying which user to update it would be a better and ideal way to do this. To run this script in a chrooted environment, one can do the following: So we have to keep in mind that a server might have multiple users, so I said user "tf2dev" owns the server files. So in the sudoers file One thing to change is to add an item to the sudoers file Code: sudo visudo /etc/sudoers Add this to the end: Code: %tf2dev ALL=(tf2dev) NOPASSWD: /usr/local/games/tf2dev/ That says, any person in group "tf2dev" can run any script inside "/usr/local/games/tf2dev/" with the user "tf2dev" of course with no password. That will restrict only users in tf2dev group to execute anything in that directory. Then you will create a tunnel script so that you can run that file with sudo tf2dev Code: #! /bin/sh Server-launch is the original script. Now inside the current (original) script, only one thing needs to be modified... would be this area: Find this: Code: # Screen command Replace with this: Code: INTERFACE="/usr/bin/screen -A -m -d -S $NAME" That will force the user to run under the script under $USER. So now anyone with tf2dev as their group could start, run, and execute it. Now the question would be, how would we allow different users to screen into that server?
nevermind, got it now
Having a problem with this script. It's throwing errors on 'service_stop'.
The error is: Code: Stopping server The script: Code: service_start() {
02-05-2009, 03:28 AM
scriptfu Wrote:Hmm, I only host one server for now, and it's not even populated 90% of the time I'm surprised there's no open source one out there. Heck, I think I just found my next project there is one: hldstart
03-13-2009, 04:16 AM
Code: # Game options Possible to use a dyndns adress instead of an ip number. My ip changes now and then. Not so often that it disturbs but it would be easier if could use a dyndns adress. Or even better if if the script takes the info from eth0
03-15-2009, 07:27 AM
Arujei thank you very much for your script modification! Everything works GREAT!
But i`ve found one bug. Which cases baaad errors... Here is the fix: Code: service_start() { if you shutdown your pc inproperly the pid file is not deleted. I`ve fixed it. Tested on Gentoo Linux.
07-09-2010, 01:14 AM
Sorry for digging up an old thread, but I'm wondering what you all would recommend for when you want to run multiple servers.
Right now I'm modifying the code to start CSS with the startup script, but I'm also making it expandable for L4D, and L4D2. Right now I'm writing the script in Perl, and possibly python, but I think this is getting over complicated, anyone recommend something different? |
« Next Oldest | Next Newest »
|