1. UltimateByte

    UltimateByte Wood Hoarder

    "Native" Linux support for Rust is back since February 2016 ! Garry Newman on Twitter

    That allowed us to add a Rust Server Script into the Linux Game Server Managers (LGSM) project.
    LGSM is a command line tool for quick, simple deployment and management of a Rust Linux dedicated server.

    As information is dispatched all around the web which is a pain, i'm trying to centralize it for you.
    If you need more information or have issues, just ask !

    System requirements

    Server Specs
    The Rust game server process will take up from 6 to 10GB RAM, depending on your map size.
    It will also use constantly 50-65% of one core from a Xeon E5-1650V3 (6 cores 12 threads, 3.8Ghz), regardless of the amount of people connected. As most game servers, it seems like it's mainly monothread, so you'd better have some good monothread performances, and at least 16GB or RAM. So don't take a stupid server with 150 cores @1,2Ghz, prefer a quad/hexa core @3,3Ghz+, check benchmarks before choosing your server.
    The server autosave can cause lags, depending on your CPU and disk speed.
    As always, VPS are not advised for game servers, especially for a Rust server that requires a lot and constant CPU power.
    So to sum up :
    • VPS not advised, performance will most likely suck, use a true dedicated server
    • CPU : good monothread performance
    • RAM : 12GB and more
    • Bandwidth shouldn't be an issue, aim for a 10-15mb/s+ connection minimum

    Server Linux Distribution
    You will need Glibc greater or equal to v2.15 (more info Glibc · dgibbs64/linuxgsm Wiki · GitHub )
    So you need :
    • Ubuntu 12.04 LTS or greater
    • Debian 8 or greater
    • CentOS 7 or greater

    Useful Links

    Manual Installation and general information

    LGSM Installation
    LGSM Support
    Updater Script for Oxide
    Oxide for Linux
    Rusty Rcon Tool

    Rust Server with LGSM Video tutorial
    If you need some help, here is a video that shows how to use LGSM, it also explains the basics of a Rust Server, and other stuff, that's why it's 20 minutes long, otherwise, if you're experienced, you can get your server up and running in around 5 minutes without any mods.




    LGSM Tutorial

    0) Make sure you have all the dependencies

    And make sure you match the distro requirement by using your eyes and brain reading this : rustserver: Rust |

    1) Make a new user
    and login to it
    As root, do :
    Code (Text):
    adduser rust
    ...
    login rust
    2) Get LGSM and make it executable
    Code (Text):
    wget http://gameservermanagers.com/dl/rustserver
    chmod +x rustserver
    3) Run the installer and follow the instructions
    Code (Text):
    ./rustserver install
    4) Edit rustserver to fit your needs
    You'd better use nano or vim, but you could also use a text editor line notepad++, which is way less convenient. If you need help about what to configure, watch the video.
    Code (Text):
    nano rustserver
    5) Edit server.cfg
    Located in serverfiles/server/rust-server/cfg

    6) Make sure everything is allright
    Start your server
    Code (Text):
    cd ~
    ./rustserver start
    Then check your logs
    Code (Text):
    cat serverfiles/game*.log
    The log will be called game-{FULL-CURRENT-DATE}.log to not be erasted on every restart.
    Upon a server start (or restart), this log will be moved to log/server and a new one will be created. This is a workaround for the crappy default log management in Rust.

    7) Install Oxide
    You just have to download Oxide and extract it in a temp folder, then copy to your serverfiles folder, and clean the temp folder.
    Of course, shut down the server first.
    A good idea is to run a "save" command using Rusty or RCON before stopping your server. See 9) for more info.

    Manual Way
    Code (Text):
    ./rustserver stop
    mkdir temp && cd temp
    wget https://github.com/OxideMod/Snapshots/raw/master/Oxide-Rust.zip
    unzip Oxide-Rust.zip
    rm Oxide-Rust.zip
    cp * /home/rust/serverfiles
    cd ~
    ./rustserver start
    Setup the automated way
    Code (Text):
    mkdir zip-updater && cd zip-updater
    wget https://raw.githubusercontent.com/UltimateByte/zip-updater/master/zip-updater
    chmod +x zip-updater
    Then edit zip-updater accordingly
    Code (Text):
    nano zip-updater
    targetdir="/home/rust/serverfiles"
    ziplinks="https://github.com/OxideMod/Snapshots/raw/master/Oxide-Rust.zip"

    And ad the end, add /home/rust/rustserver stop and /home/rust/rustserver start

    # Running functions
    echo ""
    echo "Thanks for using this script made by UltimateByte"
    fn_error_check
    echo ""
    echo "Start downloading or updating zips ?"
    fn_prompt_continue
    /home/rust/rustserver stop
    fn_create_dirs
    fn_dl_zip
    fn_extract_zip
    fn_lowercase
    fn_copy
    fn_rm_extractdir
    fn_backup
    fn_rm_zipsdir
    fn_complete
    /home/rust/rustserver start
     
    Now any time there is an Oxide update, just run ./zip-updater

    Better check your logs again and check that Oxide is loading properly


    8) Install Oxide addons
    Just put them into serverfiles/server/rust-server/oxide/plugins
    They will load automatically.
    If you need to edit their configs, it will be located in :
    serverfiles/server/rust-server/oxide/config

    If you updated an addon and wish to reload it without restarting the server, you'll need Rusty. Once you've got it, run :
    Code (Text):
    oxide.reload PluginName
    9) Connect in RCON using Rusty
    Grab it here Rusty - Server RCON administration tool | Oxide
    If you can't know your IP or domain name, you're a jerk.
    If you can't remember the RCON port you set or password (that you MUST change), just use :
    Code (Text):
    ./rustserver details
    Essential commands
    Code (Text):
    save ; will save the server state (useful before a stop or restart)
    oxide.reload PluginName ; will reload a plugin after updating it
    server.writecfg ; to save config commands you ordered into Rusty, including new admins
    ownerid STEAMID64 "Nickname" "Reason" ; to add an owner
    moderatorid STEAMID64 "Nickname "Reason" ; to add a moderator
    10) Avoid a security breach and allow you to run multiple servers
    By default, a user can see all started processes from other users, which is bad, but also their start parameters, which is pretty dangerous. Those start parameters can contain sensitive information, such as RCON password, Steam API keys, GSLTokens...
    Upon start, a Rust dedicated server is checking if the process name started in all users, and will prevent you from running it again if it finds it, displaying "Player is already running".
    To avoid that, run
    Code (Text):
    mount -o remount,rw,hidepid=2 /proc
    And to keep the changes upon machine reboot
    Code (Text):
    nano /etc/fstab

    proc    /proc    proc    defaults,hidepid=2    0    0
    Of course, you still need to make one user per server, change ports, and repeat the install process.

    11) Setup automated reboot or any task
    You will need to use Linux Cronjobs. For more information, see Automation · dgibbs64/linuxgsm Wiki · GitHub

    Basically, i advise you to setup root cronjobs.
    The syntax for root cronjobs is (replace things between <> by the actual value)
    Code (Text):
    0 5 * * * su - <username> -c '/home/<username>/rustserver <command>' > /dev/null 2>&1
    Example for a restart every day at 5 :
    Login to Root
    Code (Text):
    su
    crontab -e
    0 5 * * * su - rust -c '/home/rust/rustserver restart' > /dev/null 2>&1

    save and exit (ctrl +x, y, enter)
    You can run a monitor cronjob every few minutes to make sure your server is up and runing.
    Code (Text):
    */3 * * * *  su - rust -c '/home/rust/rustserver monitor' > /dev/null 2>&1
    12) Updating Rust
    Just run
    Code (Text):
    ./rustserver update
    If needed, run
    Code (Text):
    ./rustserver validate
    Then update oxide once the new version is released. If you followed this guide entirely :
    Code (Text):
    ./zip-updater/zip-updater

    Special Thanks :
     
    Last edited by a moderator: Jan 12, 2017 at 3:43 PM
    Caffeine, Jaw3l, Makedonas and 4 others like this.
  2. Brandjuh

    Brandjuh Wood Hoarder

    Thanks!!!
    Can this be a sticky post?
     
  3. Brko™

    Brko™ Shotgun Ace

    Will probably jump to linux soon since I use Debian most of my time in work :) Great job on this tutorial! Thumbs up for sticky post
     
  4. UltimateByte

    UltimateByte Wood Hoarder

    Well, seems like it's been granted ! ^^
    Hopefully "Wine for Linux setup for Rust" will one day no longer be required for anyone as there is now a good native support !

    Wise choice bro ! As long as you're comfortable with Linux, this is certainly the fastest and most powerful way to manage a server !


    Here are some piece of advice for the beginners, those who know nothing about Linux.

    I started Linux by hosting a forum (it required SSH and domain names knowledge, and FTP/PHP/Apache2 server deployments) and a TeamSpeak server, then a Garry's Mod server (needed SteamCMD knowledge). It took me one or two sleepovers to be happy with my machine which i firstly reinstalled a few times before even considering it stable enough to host a website and a TS. But I didn't start with the easiest system, I was using ESXI which is very powerful but a pain to set up for the first time. It allowed me to run several Debian Linux virtual machines under the same server, and allowed me to save snapshots of my system to be able to rollback after critical mistakes. That way i could test risky commands that i would have never tried otherwise. I'd advise not to do that but to prefer buying a cheap VPS or making a Linux VM (with no interface) to run all tests you want, just to get comfy with Linux First.

    Then, I discovered LGSM, which changed my life and the way i was managing my game servers quite a bit by simplifying deployment and maintenance, and started making more and more servers.

    If you're jumping into Linux for the first time, get ready to Google a lot, (documentation for Linux is very abundant) to first learn the basics of SSH. That will also help you understanding the basics of Shell (scripts). Don't bother with a remote interface, it will be useless because you'll end up using only a command prompt for a server anyways. And you'd better spend a few hours or even a few days to learn the basics of Linux (Installing packages, updating your server, monitor and manage your server -munin / webmin - setup a proper FTP server, configure some stuff for safety...), then you'll probably continue to learn stuff about Linux every day for quite a while... :)
    For the distribution, i can only advise Debian or Ubuntu, which are very stable, very updated, and very well documented with a great community.

    Welcome and good luck to all Linux beginners !
     
    Last edited: Mar 14, 2016
    Brko™ likes this.
  5. dj_fun_star

    dj_fun_star Naked Wanderer

    Hello,
    I try to follow your tutorial. Aside step 3 does its work. I put the logs.

    Code (Text):
     rustoxide@debian:~$ ./rustserver install
        fetching functions/core_functions.sh...FAIL
    savez de quoi sa peut venir, merci ?
    --- Double Post Merged, Mar 11, 2016 ---
    We successfully executed in the beginning of step 3, but now I'm missing file "libstdc ++ 6: i386". I try to download but its not working. I put the logs.


    Code (Text):
    root @ debianhome # apt-get install libstdc ++ 6: i386
    Reading package lists ... Done
    Shaft Construction dependencies
    Reading state information ... Done
    E: Could not find the libstdc ++ 6
    E: Could not find package matching the regular expression "libstdc ++ 6"
     
  6. UltimateByte

    UltimateByte Wood Hoarder

    You missed step 0). So you should go back to step 0, install required dependencies, and come back to tell us it's working ;)

    And don't forget before anything else :
    Code (Text):
    dpkg --add-architecture i386
    apt-get update
     
  7. Brandjuh

    Brandjuh Wood Hoarder

    @UltimateByte How can I make that typing restart in the console is restarting the server?
     
  8. UltimateByte

    UltimateByte Wood Hoarder

    Rust doesn't provide a console. What you see when running ./rustserver console , it's useless until facepunch eventually decides to provide a server console.
    If you wish to restart, use ./rustserver restart
    You can setup an auto restart using cronjobs (see Automation · dgibbs64/linuxgsm Wiki · GitHub )

    I've got one restart per day at 6:30, and it's enough, at least on my machine, no lag whatsoever. I used the "notifier" addon to tell people "daily restart at 6:30" and before the reboot "reboot in 30/5/1 minutes". Of course, it doesn't run a "save" command, it just closes then re-open the server, but if you got the default savetime of 300s (5 minutes), it shouldn't be a problem.
     
  9. Brandjuh

    Brandjuh Wood Hoarder

    I know and I have the same setup at the moment. I use a save intervall of 120second since its a build server. But I am at the point I need a head-admin and I want that the person can restart the server without getting in the ssh of the server. Thats why I have this question. Since the restart command has a timer but only do a exit on the server.
     
  10. UltimateByte

    UltimateByte Wood Hoarder

    I know, it's hard to trust someone for SSH... If you know a bit of PHP you could make a password protected page with a button that would trigger the restart command. You could also do several programmed reboots every day at fixed hours.
    Still, the only way to manually save is to use RCON... So good luck to integrate that in a PHP page (it's possible, some frameworks exists, but does it worth the effort ?!).
     
    Brandjuh likes this.
  11. Brandjuh

    Brandjuh Wood Hoarder

    Well I have made more automatic restarts.
     
    Last edited: Mar 14, 2016
  12. UltimateByte

    UltimateByte Wood Hoarder

    The proper way to run multiple servers :
    It's the most simple, clean, and efficient way to do it !

    - Apply the fix mentioned in "10)" part of this tutorial
    - Make a new user
    - Install the new server on that new user, and make sure you set up different ports.

    The stupid way to do it :
    If you wish to run 2 servers under the same user (which is most likely a bad idea), you'll have to do some more shitty stuff.
    I consider it the bad way to do this, i can't advise this shit, especially because you're gonna have issues on any Rust update... but still, if you wanna do that, the process is documented here : Multiple Servers · dgibbs64/linuxgsm Wiki · GitHub
    But for Rust, it will require some other tweaks due to its stupid process name checking. So you'll have to change the name of the executable and Data dir.
    So here is the full process :

    Of course, Make 2 separate folders, one per server.
    On the second installation :
    1) In LGSM script (rustserver), change the "executable" variable to : executable="./RustDedicated2"
    2) In LGSM script (rustserver), change the "servicename" to a whole different name like : servicename ="second-rust". (You need a very different name because you might have issues with Tmux mixing up names suchs as "rust-server" and "rust-server2"
    3) Rename serverfiles/RustDedicated to serverfiles/RustDedicated2
    4) Rename serverfiles/RustDedicated_Data to serverfiles/RustDedicated2_Data

    The even more stupid way to do it, but useful if you have a very limited disk space :
    If you wish to have 2 servers in the same folder (i wouldn't advise that neither, but who knows, maybe your server HDD is 20GB and still one will wanna host several servers on this shit...), i didn't try it for Rust, but it should work :

    1) Copy rustserver to rustserver2
    2) In rustserver2 (LGSM script), change the "servicename" to a whole different name like : servicename ="second-rust". (You need a very different name because you might have issues with Tmux mixing up names suchs as "rust-server" and "rust-server2")
    3) In rustserver2 (LGSM script), change the "executable" variable to : executable="./RustDedicated2"
    4) Copy serverfiles/RustDedicated to serverfiles/RustDedicated2
    5) Copy serverfiles/RustDedicated_Data to serverfiles/RustDedicated2_Data
     
    Last edited: Mar 14, 2016
  13. Brandjuh

    Brandjuh Wood Hoarder

    You are to fast, I alrady removed the question since I found the error I made, haha.
    I did replace a server backup that rollback my changes to the userhide.

    But thanks anyway, it will provide other help aswell! :)
     
  14. Supreme Master 2

    Supreme Master 2 Naked Wanderer

    Hello, I did encounter a problem while installing my server, i did install the server without any problems, but then when i try to start it just fails. I have linux server using LGSM. No message just FAIL on service name and my rust server name, nothing in debug also. Any help?
     
  15. serezhadelaet

    serezhadelaet Shack Builder Plugin Developer

    Are you sure, that tmux and Glibc are established?
     
  16. Saltant

    Saltant Wood Hoarder

    Hello, i install server 1 day ago, and today i have many errors in gamelog
    Code (Text):

    Unhandled Exception: System.Net.Sockets.SocketException: Too many open files
      at System.Net.Sockets.Socket.Accept (System.Net.Sockets.Socket acceptSocket) [0x00000] in <filename unknown>:0
      at System.Net.Sockets.SocketAsyncEventArgs.AcceptCallback () [0x00000] in <filename unknown>:0


    ERROR building certificate chain: System.IO.IOException: Too many open files
      at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, $
      at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0
      at Mono.Security.X509.X509Store.BuildCertificatesCollection (System.String storeName) [0x00000] in <filename unknow$
      at Mono.Security.X509.X509Store.get_Certificates () [0x00000] in <filename unknown>:0
      at System.Security.Cryptography.X509Certificates.X509Store.Open (OpenFlags flags) [0x00000] in <filename unknown>:0
      at System.Security.Cryptography.X509Certificates.X509Chain.get_Roots () [0x00000] in <filename unknown>:0
      at System.Security.Cryptography.X509Certificates.X509Chain.get_CertificateCollection () [0x00000] in <filename unkn$
      at System.Security.Cryptography.X509Certificates.X509Chain.FindParent (System.Security.Cryptography.X509Certificate$
      at System.Security.Cryptography.X509Certificates.X509Chain.BuildChainFrom (System.Security.Cryptography.X509Certifi$
      at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X50$
      at System.Net.ServicePointManager+ChainValidationHelper.ValidateChain (Mono.Security.X509.X509CertificateCollection$
    Please, report this problem to the Mono team
    [Oxide] 12:36 [Error] Failed to call hook 'IOnBasePlayerAttacked' on plugin 'rustcore v1.0.0' (Exception: sql error: unable to open database file)
    [Oxide] 12:36 [Debug]   at RustNative.SQLite.Insert (System.String query, System.Object[] keys) [0x00000] in <filename unknown>:0
      at UserPersistance.AddLifeStory (UInt64 playerID, ProtoBuf.PlayerLifeStory lifeStory) [0x00000] in <filename unknown>:0
      at BasePlayer.LifeStoryEnd () [0x00000] in <filename unknown>:0
      at BasePlayer.OnKilled (.HitInfo info) [0x00000] in <filename unknown>:0
      at BaseCombatEntity.Die (.HitInfo info) [0x00000] in <filename unknown>:0
      at BasePlayer.Die (.HitInfo info) [0x00000] in <filename unknown>:0
      at BaseCombatEntity.Hurt (.HitInfo info, Boolean useProtection) [0x00000] in <filename unknown>:0
      at BasePlayer.Hurt (.HitInfo info, Boolean useProtection) [0x00000] in <filename unknown>:0
      at BaseCombatEntity.OnAttacked (.HitInfo info) [0x00000] in <filename unknown>:0
      at BasePlayer.OnAttacked (.HitInfo info) [0x00000] in <filename unknown>:0
      at Oxide.Game.Rust.RustCore.IOnBasePlayerAttacked (.BasePlayer player, .HitInfo info) [0x00000] in <filename unknown>:0
      at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
      at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
    [Oxide] 12:36 [Error] Failed to save protobuf data to oxide.covalence.playerdata.data (IOException: Too many open files)
    [Oxide] 12:36 [Debug]   at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
      at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
      at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
      at System.IO.File.Open (System.String path, FileMode mode) [0x00000] in <filename unknown>:0
      at Oxide.Core.ProtoStorage.Save[IDictionary`2] (IDictionary`2 data, System.String[] sub_paths) [0x00000] in <filename unknown>:0
    RustIO map dont work (cant enter on my site map)

    I go try this:
    Code (Text):
     Ubuntu Linux
    Find the current maximum number of open files per user in a single session:
    ulimit -n
    By default the number is 1024 which is too small.
    Edit the limits.conf file:
    sudo gedit /etc/security/limits.conf
    Add the following lines to the file:
    * soft nofile 10000
    * hard nofile 50000
    This sets for all users a soft limit of 10000 open files and a hard limit of 50000. These are just example numbers. Set them according to your system needs. Note that the wildcard option applies only to regular users, not to superuser. If you run Magnolia as superuser replace the asterisk with root.
    Save the file.
    Edit the configuration file for session-related modules:
    sudo gedit /etc/pam.d/common-session
    Add the following line to the file:
    session required pam_limits.so
    Save the file.
    Restart Ubuntu.
    Verify the new maximum number of open files:
    ulimit -n
    The command should now return 10000.
    Restart Rust Server fix all problem, but i think it back later if ulimit dont help.
     
    Last edited by a moderator: Mar 20, 2016
  17. UltimateByte

    UltimateByte Wood Hoarder

    What does the logs say ?

    Interesting, what version of ubuntu do you have ? Interface installed or not? What kind of issues did you get ?
    @DikkatDeli may find this interesting :)
     
  18. Saltant

    Saltant Wood Hoarder

    I have 26~14.04.1-Ubuntu SMP
    Server dont have interface, dont have display or keyboard work only Terminal (i connect from Pytty).
    I google for "Unhandled Exception: System.Net.Sockets.SocketException: Too many open files" and google say me try ulimit.
     
  19. UltimateByte

    UltimateByte Wood Hoarder

    Thanks about that. Never had such an issue with Debian but may help others. At least you had an error to help. To end up with this, i'm curious : Where did you see that error ? (in what log)
     
  20. Saltant

    Saltant Wood Hoarder

    I have spam in my RUSTY and i open log: /rustserver/serverfiles/gamelog-2016-03-20-12-42-16.log
    Log in oxide folder clear, no error found.