Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Bash Scripting


  • Please log in to reply
3 replies to this topic

#1 cryptodan

cryptodan

    Bleepin Madman


  • Members
  • 21,868 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Catonsville, Md
  • Local time:09:45 PM

Posted 28 June 2010 - 11:36 AM

I want to create a script that will allow me to run my HLDS Server as user hlds so it isn't running as root on boot up. This will be placed in the rc.local command via path to the script which will be /home/hlds/half-life

So what do I need to put in the script to set the script to run as user HLDS?

BC AdBot (Login to Remove)

 


#2 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,250 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:02:45 PM

Posted 28 June 2010 - 06:14 PM

This should work... haven't really tested it, though:

in the /etc/rc.local file, just before the "exit 0" part, put this

su hlds -c sh /home/hlds/half-life


#3 cryptodan

cryptodan

    Bleepin Madman

  • Topic Starter

  • Members
  • 21,868 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Catonsville, Md
  • Local time:09:45 PM

Posted 30 June 2010 - 09:03 AM

Do you know how I can return the command line after running the bash script?

#!/bin/bash
cd /home/hlds/half-life
./hlds_run +ip 192.168.1.6 -port 27015 +map crossfire +maxplayers 16 -autoupdate > hlds.out 2>1&;
exit 0

That's what I have so far, yet the exit doesn't exit.

#4 Andrew

Andrew

    Bleepin' Night Watchman


  • Moderator
  • 8,250 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:Right behind you
  • Local time:02:45 PM

Posted 30 June 2010 - 11:46 AM

Do you know how I can return the command line after running the bash script?

#!/bin/bash
cd /home/hlds/half-life
./hlds_run +ip 192.168.1.6 -port 27015 +map crossfire +maxplayers 16 -autoupdate > hlds.out 2>1&;
exit 0

That's what I have so far, yet the exit doesn't exit.

Off the top of my head:

#!/bin/bash
nohup sh /home/hlds/half-life/hlds_run +ip 192.168.1.6 -port 27015 +map crossfire +maxplayers 16 -autoupdate > hlds.out 2>1&; &
exit 0

Might do it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users