Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Start/stop/restart git version with Webmin shell scripts?

#1
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.
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply

#2
(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?
Reply

#3
(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.
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply

#4
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
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply

#5
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?
Reply

#6
(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.
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply

#7
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.
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply

#8
(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/)
Reply

#9
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.
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply

#10
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.
Reply

#11
(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.
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply

#12
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.
Reply

#13
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.
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply

#14
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
[MoFo] Servers - North America - Hosted in Montreal Canada - Admin DeadDred [MoFo]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Full server tutorial start-2-finish with maps & config from live server xonotic.us.to ballerburg9005 0 10,063 09-03-2021, 10:21 AM
Last Post: ballerburg9005
  Server does not start saddesad 2 2,612 11-25-2020, 04:39 AM
Last Post: saddesad
  curl_urls.txt update without restart BuddyFriendGuy 6 5,760 06-04-2020, 05:23 PM
Last Post: BuddyFriendGuy
  [NEED HELP] I would like to setup a server; Where do I start? evilkittie 18 20,328 07-13-2017, 06:28 AM
Last Post: evilkittie
  player freeze during start countdown -maniac|Su- 0 2,606 10-31-2016, 04:21 PM
Last Post: -maniac|Su-
  Git and 0.8.1 Beagle 1 2,992 05-01-2016, 12:42 AM
Last Post: BuddyFriendGuy
  [GIT/0.8] Note about weapon updates Mario 1 3,445 12-13-2014, 03:02 AM
Last Post: GoregeousGuy
  [GIT] A note to MinstaGib server owners Mario 9 10,070 12-12-2014, 05:13 AM
Last Post: -maniac|Su-
Question How to start a Server with Mutators ? Wolfseye 1 3,891 07-08-2014, 12:07 PM
Last Post: Mr. Bougo
Brick Shell script to execute rcon commands Melanosuchus 0 7,769 06-05-2014, 04:17 PM
Last Post: Melanosuchus

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-