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

Notices


Reply
  Search this Thread
Old 07-30-2004, 12:08 PM   #1
Munniac
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Rep: Reputation: 0
Battlefield Startup Script


Okay, I am new to linux so I need some very detailed instructions. I have a Salckware 10 server at home that I am running a Battlefield 1942 server on along with the Blackbag Ops server manager.

I have the server in /usr/local/games/bf1942 and want to run a file called "bfsm" on startup.

All this so I just have to reboot it and I can log back into the Server Manager and start the server again.

I have no idea how to do this and I have searched these forums for what feels like days to find help and haven't crossed anything. Can someone please give the new guy a hand..

Thanks
Mike
 
Old 07-30-2004, 12:19 PM   #2
Necronomicom
Member
 
Registered: Jun 2004
Distribution: Slackware, Solaris
Posts: 127

Rep: Reputation: 15
do a which bfsm, and it should return you a adress like /usr/local/bin/bfsm

open /etc/rc.d/rc.local with a text editor and place the line /usr/local/bin/bfsm in it
 
Old 07-30-2004, 12:20 PM   #3
Mephisto
Member
 
Registered: Oct 2002
Location: Washington D.C, USA
Distribution: Slack 12, Etch, Gutsy
Posts: 453

Rep: Reputation: 31
Re: Battlefield Startup Script

Quote:
Originally posted by Munniac
Okay, I am new to linux so I need some very detailed instructions. I have a Salckware 10 server at home that I am running a Battlefield 1942 server on along with the Blackbag Ops server manager.

I have the server in /usr/local/games/bf1942 and want to run a file called "bfsm" on startup.

All this so I just have to reboot it and I can log back into the Server Manager and start the server again.

I have no idea how to do this and I have searched these forums for what feels like days to find help and haven't crossed anything. Can someone please give the new guy a hand..

Thanks
Mike
Does bfsm run as a background process or is it in the foreground? i.e. when you type bfsm from the command line does it return you to the command line or does it display the server in the terminal until you shutdown the server? Also under what user account does the server run? Finally what is the command to shutdown the server?

You are going to want to add a line or two to /etc/rc.d/rc.local but it will depend on how it runs as to what the command should be.
 
Old 07-30-2004, 12:30 PM   #4
Munniac
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
It runs in the foreground.

Here is what I have to enter to start it and the output I get when I do...

Quote:
/usr/local/games/bf1942# ls
LICENSE* bf1942_lnxded@ bf1942_lnxded.static* bfsmd* fixinstall.sh* pb/ readmes/
README* bf1942_lnxded.dynamic* bfpridaemon/ bfsmd.log mods/ playermenu.con* start.sh*
root@Slack:/usr/local/games/bf1942# ./bfsmd
2004-07-29 11:28:48 : Battlefield 1942 Server Manager v2.0 beta 4e
2004-07-29 11:28:48 : Started under Linux Slack 2.4.26 #6 Mon Jun 14 19:07:27 PDT 2004 i686
2004-07-29 11:28:49 : Listening on 10.0.0.2:14667.
 
Old 07-30-2004, 12:40 PM   #5
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
try add :

/usr/local/games/bf1942/bfsmd &

in your /etc/rc.d/rc.local
(it will run in background as all servers do)
 
Old 07-30-2004, 12:40 PM   #6
gbonvehi
Senior Member
 
Registered: Jun 2004
Location: Argentina (SR, LP)
Distribution: Slackware
Posts: 3,145

Rep: Reputation: 53
Just curious, what does bfpridaemon and start.sh do?

Also, if you want to get a fancy control over your server try: http://www.blackbagops.com/bf1942/bfsm/index.shtml (i don't play games so i never used it, but it looks promising)

Last edited by gbonvehi; 07-30-2004 at 12:44 PM.
 
Old 07-30-2004, 12:56 PM   #7
Munniac
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
That is actually what I am using

The start.sh starts the actual server, but the bfsmd is the Blackbag Ops Server Manager. I am not sure what the bfpridaemon do.
 
Old 07-30-2004, 01:26 PM   #8
Munniac
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by Cedrik
try add :

/etc/rc.d/rc.local &

in your /etc/rc.d/rc.local
(it will run in background as all servers do)
I tried "/usr/local/games/bf1942/bfsmd &" and "/usr/local/games/bf1942/bfsmd" in my rc.local and it didn't work.


I also did a which bfsmd and got this error.


which: no bfsmd in (/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/usr/lib/java/bin:/usr/lib/java/jre/bin:/opt/kde/bin:/usr/lib/qt/bin)


Any other ideas?

Last edited by Munniac; 07-30-2004 at 01:37 PM.
 
Old 07-30-2004, 01:55 PM   #9
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
So just try to put that in /etc/rc.d/rc.local :

/usr/local/games/bf1942/start.sh

Of course /etc/rc.d/rc.local need to be executable (if not chmod +x it)

Last edited by Cedrik; 07-30-2004 at 01:56 PM.
 
Old 07-30-2004, 01:57 PM   #10
Necronomicom
Member
 
Registered: Jun 2004
Distribution: Slackware, Solaris
Posts: 127

Rep: Reputation: 15
add this to your rc.local:

sh /usr/local/games/bf1942/bfsmd

Last edited by Necronomicom; 07-30-2004 at 01:58 PM.
 
Old 07-30-2004, 03:23 PM   #11
Munniac
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
Okay, I figured it out. Finally.

I figured if it was going to run in the startup script it should run with me just typing it in. I typed in /usr/local/games/bf1942/bfsmd and got this error...

Couldn't find server binary in /root! Use -path to specify server directory and/or verify bf1942_lnxded link exists.

so I put in this script and it worked so I added it to the rc.local

/usr/local/games/bf1942/bfsmd -path /usr/local/games/bf1942/

and it works.

Thanks for all the ideas, I wouldn't have known where to start.
 
Old 07-30-2004, 03:32 PM   #12
Mephisto
Member
 
Registered: Oct 2002
Location: Washington D.C, USA
Distribution: Slack 12, Etch, Gutsy
Posts: 453

Rep: Reputation: 31
The server might not run as root. In which case the sticky bit would need to be set or he sould want to use su - <user> -c "<command>" The easiest way to test is to set up your rc.local, then from the command line as root type "/etc/rc.d/rc.local" and see what it has to say.

Also keep in mind that if the bf1942 server needs to be shutdown a command will need to be added to /etc/rc.d/rc.0 as well. My personal preference, which may be overkill for a simple example, is to set up a script for the server with start, stop, and restart commands (just copy rc.httpd and modify to suit). I then add a call to start in rc.local and stop in rc.0. The benefit is that your added server is consistent with services in a default Slackware install.

From the looks of it the bf1942 server is not freely available so I can't install it. If it is free, let me know where it is and I'll install and write a startup script.


This is an example rc.server script (postgres in this case)
Code:
#!/bin/sh
#
# /etc/rc.d/rc.postgres
#
#

case "$1" in
   'start')
      su - postgres -c "/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l /var/log/postgres/postgres -o '-i'" ;;
# a GUESS as to what the bf1942 command should be
# NOTE: I am wrapping it in a su-c because I don't like to run anything as root that does not 
# need to be and su -c is my preferred way versus setting the sticky bit 
#    su - bf1942User -c "/usr/local/games/bf1942/bfsmd &" ;;
# alternatively you could start bfsmd in a screen like this
#    su - bf1942User -c "screen -d -m /usr/local/games/bf1942/bfsmd" ;;
   'stop')
      su - postgres -c "/usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data" ;;
#same procedure as above but use whatever the stop command is
   'restart')
      su - postgres -c "/usr/local/pgsql/bin/pg_ctl restart -D /usr/local/pgsql/data" ;;
#simplest way would be to copy the stop and start commands here.
   *)
      echo "usage $0 start|stop|restart" ;;
esac
then add a "rc.bf1942 start" to rc.local and "rc.bf1942 stop" to rc.0
 
Old 07-30-2004, 03:36 PM   #13
Munniac
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
The server and DL links are here along with a setup guide for all the stuff I am running on it...

http://bf1942.lightcubed.com/forum/viewtopic.php?t=1048

If you could get me a script that starts and stops it, that would be awesome. I have it starting when linux boots, but is it bad to just let it die when the server reboots, what is the advantage of your script to the on that I have on there now? I am just curious because as I stated, I am not a guru, YET.
 
Old 07-30-2004, 03:58 PM   #14
Mephisto
Member
 
Registered: Oct 2002
Location: Washington D.C, USA
Distribution: Slack 12, Etch, Gutsy
Posts: 453

Rep: Reputation: 31
OK, I am downloading now. I'll set it up later tonight. The benefit to setting it up the way I suggested is that you can start and stop the server from the command line as well as having the service start and stop automatically. Also to enable/disable the service all you would need to do is change the permission to the script. Finally, as I noted, the way you are running it currently the bf1942 server is running as root, which in my opinion is not wise. Any vulnerability in the server would be effectively exploiting root permission.
 
Old 07-30-2004, 04:01 PM   #15
Munniac
LQ Newbie
 
Registered: Jul 2004
Posts: 10

Original Poster
Rep: Reputation: 0
rgr that, I will work on that. I know what to change, it will just take me a while since I am at work.
 
  


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
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
How to call a script from a system startup script? jonatito Linux - Newbie 7 11-11-2005 09:40 PM
startup script Circuit Monkey Linux - Newbie 2 04-13-2005 01:45 PM
Startup Script djinniyah Linux - Newbie 3 09-18-2003 05:20 AM
startup script c0c0deuz Linux - Newbie 3 03-29-2003 03:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:14 AM.

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