Results 1 to 5 of 5

Thread: I need help writing a script to launch a server inside tmux <3

  1. #1
    Join Date
    Aug 2020
    Beans
    3

    Question I need help writing a script to launch a server inside tmux <3

    He guys, i'm an admin/owner of a local hosted server, hosting 2 LinuxGSM servers one csgo and one Minecraft, then a modded minecraft 1.12.2 server, not with linuxGSM. i don't want all the servers to be launched at once i was looking for a way to run a sh bash file that would launch tmux as the servers user . then run the start command which for the gsm servers is "./mcserver start" and "./csgoserver start" . and then the launch parameters for the modded minecraft server is "java -Xms8G -Xmx8g -jar forge-1.12.2-14.23.5.2854.jar --port 25567 nogui" . if anyone knows how to make a good script for both starting and stopping each server individually in separate tmux session.

    I'd appreciate any help, advice or concerns <3
    thanks guy

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: I need help writing a script to launch a server inside tmux <3

    Take everything you are typing and put those commands into a file. That is a script.

    Do that as your first draft. Does it work?

    Creating a "good script" s highly subjective. It takes years to get good at scripting. Really, most scripts just need to be good enough, no more.
    There are hundreds of example scripts on your Linux computer already, if you need examples to follow.

    The "Beginning Bash Scripting Guide" and "Advanced Bash Scripting Guide" are worth a quick look too.

    I don't think tmux has anything to do with the script. I don't use tmux.

  3. #3
    Join Date
    Aug 2020
    Beans
    3

    Re: I need help writing a script to launch a server inside tmux <3

    the problem is getting the script to work, i know how to make the bash script, but every script i make doesn't work XD and i can log into tmux with as the server's user but i can't run any commands in tmux from the script

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: I need help writing a script to launch a server inside tmux <3

    Quote Originally Posted by cosmic2910 View Post
    the problem is getting the script to work, i know how to make the bash script, but every script i make doesn't work XD and i can log into tmux with as the server's user but i can't run any commands in tmux from the script
    Please post the script, if you'd like help.
    Also, show the ls -l for that script file.

    Any please, please, please, please, use code tags. Otherwise, it will be too hard to read, so few people will.

  5. #5
    Join Date
    Nov 2009
    Beans
    Hidden!
    Distro
    Kubuntu 20.04 Focal Fossa

    Re: I need help writing a script to launch a server inside tmux <3

    from https://minecraft.gamepedia.com/Tuto...ng_up_a_server
    On macOS, Linux, and FreeBSD

    All these systems use a common scripting language called the "POSIX shell script" on the command line. Create a text file in the folder where you put the jar as "start.sh" and write the following in:
    Code:
    #!/bin/sh
    cd "$(dirname "$0")"
    exec java -Xms1G -Xmx1G -jar server.jar --nogui
    
    Now save the file. Run chmod a+x start.sh (or path to wherever you put the script) to make it executable. You can now run the file by double-clicking or by running ./start.sh in the folder (or using a whole path from outside there).
    If you want to add a pausing part like the Windows example, remove the exec word, and add a line of read -n 1 -p "Waiting..." to the end. This is useful if you are running the script by double-clicking on the GUI
    then you can install screen to run it in background. or to run multiple servers in background at the same time.
    Read the easy to understand, lots of pics Ubuntu manual.
    Do i need antivirus/firewall in linux?
    Full disk backup (newer kernel -> suitable for newer PC): Clonezilla
    User friendly full disk backup: Rescuezilla

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •