Xonotic Forums
Start/stop/restart git version with Webmin shell scripts? - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3)
+--- Forum: Xonotic - Server Administration (https://forums.xonotic.org/forumdisplay.php?fid=16)
+--- Thread: Start/stop/restart git version with Webmin shell scripts? (/showthread.php?tid=4499)



Start/stop/restart git version with Webmin shell scripts? - end user - 10-02-2013

Just wondering if its possible to use a shell script to start/stop/restart a git version of Xon server.

I'm looking into using Webmin to allow people to run Xon servers on my server. This is to reduce the need to give users SSH access to the server to run their Xon server. Also Webmin doesn't require php/mysql like all the other game panels so saves me from having to install extra packages.

With Webmin and the Custom Command module seems I can create action buttons to let the user execute scripts through Webmin.

Now this would work for running the server_linux.sh script but have no idea how I could do this for the git versions in case someone wanted to do custom stuff for their server.


RE: Start/stop/restart git version with Webmin shell scripts? - Mr. Bougo - 10-02-2013

(10-02-2013, 04:40 PM)end user Wrote: Now this would work for running the server_linux.sh script but have no idea how I could do this for the git versions in case someone wanted to do custom stuff for their server.

How so?


RE: Start/stop/restart git version with Webmin shell scripts? - end user - 10-02-2013

(10-02-2013, 04:51 PM)Mr. Bougo Wrote:
(10-02-2013, 04:40 PM)end user Wrote: Now this would work for running the server_linux.sh script but have no idea how I could do this for the git versions in case someone wanted to do custom stuff for their server.

How so?

Sorry maybe I worded it wrong. Main concern is how to start/stop the git version using shell scripts just in case somone asks if the can run a different git branch . Actually I guess I could get the script to start a Tmux session and use another script to kill the Tmux session? You posted this on another thread

tmux new-session -d -s my_xonotic_server './all run dedicated'

Now only other thing is how would I lock the server port in the cfg file? Is this possible.


RE: Start/stop/restart git version with Webmin shell scripts? - end user - 10-03-2013

Haven't tested it yet but I guess if I want to give people access to run git I would do the follwoing


So to start a git version of xonotic you have to type in the following. I then would use custom commands to create the buttons.

./all run dedicated or ./all run dedicated -sessionid xon


so to start and stop the git version in tmux I need to create two shell scripts with the following

start.sh

Code:
#!/bin/sh

tmux new-session -d -s $USER './all run dedicated -sessionid $USER'


stop.sh

Code:
#!/bin/sh

tmux kill-session -t $USER


I guess I can do the same but no need for tmux for updating and compiling git.

updategit.sh

Code:
#!/bin/sh

./all update

compilegit.sh

Code:
#!/bin/sh

./all compile dedicated



RE: Start/stop/restart git version with Webmin shell scripts? - Mr. Bougo - 10-04-2013

What happens when one presses start twice?

Also, do you want to have an entire copy of the 15-something gigabytes of git repository for each user?


RE: Start/stop/restart git version with Webmin shell scripts? - end user - 10-04-2013

(10-04-2013, 01:27 AM)Mr. Bougo Wrote: What happens when one presses start twice?

Also, do you want to have an entire copy of the 15-something gigabytes of git repository for each user?

I throws an errorand the second instance wont start, I guess because I'm using a session name.

As of the space well not much I can do about it unless I found away for each user to have a different .xonotic/data directory in their home and only use one install server wide.


RE: Start/stop/restart git version with Webmin shell scripts? - end user - 10-04-2013

Actually I guess I can still do it with one install but not sure how clean this would be.

I would have to install xon as one user and set it executible for every one. I would need to run a small webserver and upload as many maps as I can into the public_html folder and into the .xonotic/data folder. For each user I'd have to create a new server-user.cfg file and then change the start up scrip to

Code:
tmux new-session -d -s $USER 'cd /home/$USER/xonotic && ./all run dedicated -sessionid $USER +serverconfig server-$USER'

In the server-$USER.cfg file I'd add exec custom.cfg file whch Id make only editable and readable by the owner. I think I'd also have to have xonotic user in every user group so I can read the custom.cfg file.

For the maps I guess people would have to go though and add them in manually into their custom.cfg file.

Haven't test it yet but so far look like I can also use the custom commands module to run commnads on the server with out needed rcon. Wll test that out today, but because its going though tmux the user doesn't see the console output in Webmin so I might have to stick to the non gt versions which I wont need tmux to run.


RE: Start/stop/restart git version with Webmin shell scripts? - Mr. Bougo - 10-04-2013

(10-04-2013, 03:20 AM)end user Wrote: As of the space well not much I can do about it unless I found away for each user to have a different .xonotic/data directory in their home and only use one install server wide.

Huh. But different users have different home directories. It works by design.

EDIT: I have no idea what you mean there... Just have the whole git clone accessible by all users as you're saying (for example in /opt/xonotic-git) and make users run from there.

This will automatically use $HOME/.xonotic/ as userdir. Lock files and crypto keys will be stored in the userdir as well, so there's no need for user-specific session IDs.

In your setup, don't different users have different user accounts and therefore different home dirs? If they're all the same, it's much easier to separate userdirs by using -userdir (default action being -userdir $HOME/.xonotic/)


RE: Start/stop/restart git version with Webmin shell scripts? - end user - 10-04-2013

Ok so if I install it in /opt do I run it as root or chown xonotic to a different user and allow it write access to the $HOME/.xonotic/data dirs?

Edit Installed it as root and when ran by a user ./all run dedicated the user gets a .xonotitc/data dir's created in the home dir. That makes things WAY cleaner and easier. So now I can store maps and models on a server and all the user has to do is download the files into their .xonotic/data dir and fs_rescan to have them available. Also removes the need to have a public folder for each user on the http server.


RE: Start/stop/restart git version with Webmin shell scripts? - Mr. Bougo - 10-05-2013

Why would you want to run it as root? It can be root-owned and run by users (see: literally everything in /usr/bin).

This is how all other software works. Place in user-readable system directory, make binaries user-executable, and store personal data in home directory.


RE: Start/stop/restart git version with Webmin shell scripts? - end user - 10-06-2013

(10-05-2013, 06:14 AM)Mr. Bougo Wrote: Why would you want to run it as root? It can be root-owned and run by users (see: literally everything in /usr/bin).

This is how all other software works. Place in user-readable system directory, make binaries user-executable, and store personal data in home directory.

My bad the process is owned by the user that starts it since anyone is allowed to execute it.

Ok couple more ideas.

Allow ssh connections but set their shell to screen/tmux. The login script would have to detect if a screen/tmux session is running and attach the session if not show a message saying Please start the server from your Webmin account or restrict their shell commands to only allow to start a script in screen/tmux that starts the server. Also in webmin the custom commnd would have to detect an already running tmux session and quit so they either have to start from Webmin or SSH.

This still gives the user access to the running game server console with out having to use rcon from game console and then restricts them to have to use Webmin to upload/modify their cfg files. They can also use the Webmin command console module for SSH connections if they want.

Forcing them into a screen/tmux session with a predefined session name seems easy but I dont know much about bash to be able to restrict all commands but allowd the execution of one script.


RE: Start/stop/restart git version with Webmin shell scripts? - Mr. Bougo - 10-06-2013

tmux has a command prompt that lets you launch any command. Using a restricted shell won't help if you're using tmux.

Perhaps you should use something different from tmux. Something more lightweight like a pid file.

Anyway, I'm not a multi-user system administrator, so I have no idea what the proper way would be to do all this. But what you're suggesting has loopholes.


RE: Start/stop/restart git version with Webmin shell scripts? - end user - 10-07-2013

Ok getting along some more. I tried using screen but was getting some weird things with it so gave up. I managed to send commands from Webmin to a tmux session.

I can use Webmin custom commnads to send something like this to an excisting Tmux session.

Code:
tmux send-keys -t xonotic:0 'restart' ENTER

This caused the server to accept the restart command in the server console. I can do the same for any other command. Would be nice to have a restricted tmux session but in due time.

Now is this usefull, hmm not sure but I allows me to give people access to run a server and use rcon with game console for basic commands and the Webmin custom actions for commands not available with rcon. Also keeps me from having to give people shell access on the server.


RE: Start/stop/restart git version with Webmin shell scripts? - end user - 10-16-2013

Something new I discovered tmux session can be set to read only. So if a tmux session is created in webmin using tmux -S /var/tmp/sessionname a user can log into ssh and if they have the right permissions to /var/tmp/sessionname which they will as webmin runs as that user the can do the following in ssh tmux -S /var/tmp/sessionname attach -r and see the xonotic server console with out being able to interact with it. Now when they run xonotic server commands in webmin it'll show up in the read only tmux session.

I'd still have to set up proper ssh jail and set their login to something like below

#!/bin/bash
exec /usr/local/bin/tmux -S /var/tmp/sessionname attach -r

So their ssh session starts with the read only tmux session.

I got the idea from here http://brianmckenna.org/blog/guest_tmux