Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a gaming server and i want to develop a start/stop/restart script for it. Now, the start, stop and restart can all be different scripts it doesn't matter. But, i need to be able to run them from a website.
a) What type of script should it be
b) what type of website scripting?
c) Where does the script need to be on the server?
I would probably do the site script with php, because I know you can execute programs with it.
You can do the script to start the server with bash ie:
#start -check out /etc/rc.d/rc.3/somefile for an example of how this works
case $1 in
start)
start stuff here
;;
stop)
kill it here
;;
restart)
stop
start
;;
esac
#EOF
then chmod it to make executable: ie chmod 777
As far as I know this script will need to be on the same machine as the server in order to call it with php. You can put it anywhere the server can access as long as it as permissions to execute the file and you reference it with its absolute filename. I am not sure about any security issues involved with this though. I'm sure there is other ways but this way seems easy.
Edit: to execute you script with php, you can use exec()
Ok, im a little bit of a n00b. Explain how to execute it using exec(). I have figured that i may use the script by using authentication on the http protocol. This means that the script will link up to the game on the server and i can remotely start/stop it wherever i like. =)
So can you give me an example of the exec() string?
Ok, thats working great.
Now, i am sure its possible but how do i get my php script to execute the shell which is on another server. Note: i can put the script online (http) if it makes it any easier?
1. write a client/server app with c. client listens on port x for start server sentinal, then starts with execl(). Server side gets executed by php app, which then opens socket to client and sends sentinal
2. run apache on the other server(s2) on a non standard port.
When you want to start the script on s2: server1 opens the page on s2 with whatever authentication string/variables you want in the url. When page gets opened on s2, php executes the script.
use a different variable in the url to signal stop, etc
I am sure there is an easier way but this is the only way I know how to do it. Hope it helps.
Im actually working on that now =P haha...
only problem is, i can't specify a password in the ssh command line and the thing keeps asking me if i want to continue, which, when i don't have control over input will screw it up. Any solutions?
You can make ssh work without using a password by using public/private keys. You generate these with ssh-keygen, and then append the contents of ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys2 on the other machine.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.