1. When making a thread, please tag your thread accordingly using the menu to the left of the textfield where you name your thread where applicable. Server Advertisements and Mod Releases should be contained to their respective subforums.

Server Discussion Setting up an Ubuntu 12.04 server

Discussion in 'Multiplayer' started by DeMossiah, Dec 5, 2013.

  1. DeMossiah

    DeMossiah Master Chief

    Revision on http://community.playstarbound.com/index.php?threads/how-to-set-up-a-linux-server-on-ubuntu.34623/


    First off start by downloading and extracting the Steam command line client:
    Code:
    mkdir steam
    cd steam/
    wget http://media.steampowered.com/client/steamcmd_linux.tar.gz
    tar xzf steamcmd_linux.tar.gz

    Cleanup and move the Steam directory into place.
    Code:
    rm steamcmd_linux.tar.gz
    cd ..
    mv steam/ /opt/

    Create and appoint the steam user:
    Code:
    adduser --disabled-login steam
    chown -R steam:steam /opt/steam/

    Update the Steam client:
    Code:
    su - steam -c "/opt/steam/steamcmd.sh"

    Once you see the "Steam>" command line appearing it's time to install Starbound (This process can take a while, be patient)*, **:
    Code:
    login username password
    app_update 211820
    quit

    After it's done installing you got your basic server ready to go, you can test it by entering the following command***:
    Code:
    su - steam -c "/home/steam/Steam/SteamApps/common/Starbound/linux64/launch_starbound_server.sh"

    If everything checks out you can now create a startup script, use the following command***:
    Code:
    nano /etc/init.d/starbound
    Code:
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:        starbound
    # Required-Start:    networking
    # Default-Start:    2 3 4 5
    # Default-Stop:        S 0 1 6
    # Short-Description:    Starbound Server Daemon
    # Description:        Starts/Stops/Restarts the Starbound Server Daemon
    ### END INIT INFO
    
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    DESC="Starbound Server Daemon"
    NAME=starbound
    DIR=/home/steam/Steam/SteamApps/common/Starbound/linux64
    DAEMON=$DIR/starbound_server
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    
    USER=steam
    GROUP=steam
    DAEMON_ARGS=""
    
    STEAM_DIR=/opt/steam
    STEAM_DAEMON=$STEAM_DIR/steamcmd.sh
    
    STEAM_USER=anonymous
    STEAM_PASS=
    STEAM_APP=211820
    
    [ -x "$DAEMON" ] || exit 0
    
    . /lib/init/vars.sh
    . /lib/lsb/init-functions
    
    do_start() {
        if [ -e $PIDFILE ]; then
            PID=`cat $PIDFILE`
    
            if ( ps -p $PID > /dev/null ); then
                log_failure_msg "$DESC '$NAME' is already running."
                return 1
            else
                rm -f $PIDFILE
    
                start-stop-daemon --start --background --chdir $DIR --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --quiet --exec $DAEMON --test > /dev/null || return 1
                start-stop-daemon --start --background --chdir $DIR --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --quiet --exec $DAEMON -- $DAEMON_ARGS || return 2
            fi
        else
            start-stop-daemon --start --background --chdir $DIR --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --quiet --exec $DAEMON --test > /dev/null || return 1
            start-stop-daemon --start --background --chdir $DIR --chuid $USER:$GROUP --make-pidfile --pidfile $PIDFILE --quiet --exec $DAEMON -- $DAEMON_ARGS || return 2
        fi
    }
    
    do_stop() {
        if [ -e $PIDFILE ]; then
            PID=`cat $PIDFILE`
    
            if ( ps -p $PID > /dev/null ); then
                start-stop-daemon --stop --signal 2 --quiet --pidfile $PIDFILE
                [ "$?" = 2 ] && return 2
            else
                log_failure_msg "$DESC '$NAME' is not running."
                rm -f $PIDFILE
                return 1
            fi
        else
            log_failure_msg "$DESC '$NAME' is not running."
            return 1
        fi
    }
    
    case "$1" in
        start)
            log_daemon_msg "Starting $DESC..." "$NAME"
            do_start
    
            case "$?" in
                0|1) log_end_msg 0 ;;
                1) log_end_msg 1 ;;
            esac
        ;;
        stop)
            log_daemon_msg "Stopping $DESC..." "$NAME"
            do_stop
    
            case "$?" in
                0|1) log_end_msg 0 ;;
                2) log_end_msg 1 ;;
            esac
        ;;
        restart)
            log_daemon_msg "Restarting $DESC..." "$NAME"
            do_stop
    
            case "$?" in
                0|1)
                    do_start
    
                    case "$?" in
                        0) log_end_msg 0 ;;
                        *) log_end_msg 1 ;;
                    esac
                ;;
                *)
                    log_end_msg 1
                ;;
            esac
        ;;
        status)
            if [ -e $PIDFILE ]; then
                PID=`cat $PIDFILE`
    
                if ( ps -p $PID > /dev/null ); then
                    log_success_msg "$DESC '$NAME' is running (pid $PID)."
                    exit 0
                else
                    log_failure_msg "$DESC '$NAME' is not running."
                    rm -f $PIDFILE
                    exit 1
                fi
            else
                log_failure_msg "$DESC '$NAME' is not running."
                exit 1
            fi
        ;;
        update)
            su - $USER -c "$STEAM_DAEMON +login $STEAM_USER $STEAM_PASS +app_update $STEAM_APP +quit"
            ;;
        *)
            log_action_msg "Usage: $SCRIPTNAME {start|stop|restart|status|update}"
            exit 0
        ;;
    esac
    Code:
    chmod +x /etc/init.d/starbound

    If all is working well you can now start the server by using:
    Code:
    service starbound start

    And autostart the server when Ubuntu boots:
    Code:
    update-rc.d starbound defaults

    Code:
    * It's possible Steam requires you to enter the SteamGuard verification code.
    ** You will be logged out of Steam on other machines.
    *** If you're running on 32 bit linux replace "linux64" with "linux32".
     
    Last edited: Dec 7, 2013
  2. InterSlayer

    InterSlayer Void-Bound Voyager

    Thanks! Especially for the startup script. Workin great so far.
     
    Ceetee likes this.
  3. Bradlfett

    Bradlfett Orbital Explorer

    thx for the great tutorial!

    some additions to the startup script:

    EDIT:
    startup script change not necessary. Just move the default log to /var/log/steam and symlink it back to its original location
     
    Last edited: Dec 6, 2013
    InterSlayer likes this.
  4. sb_blakphyre

    sb_blakphyre Yeah, You!

    When trying to run the service I'm recieving the following - 'start-stop-daemon: group 'steam' not found. Any idea what may be the issue?
     
  5. DeMossiah

    DeMossiah Master Chief

    Did you perhaps skip this part?
    Code:
    adduser --disabled-login steam
     
  6. Syntax42

    Syntax42 Pangalactic Porcupine

    If / when they add server commands, how will we manipulate the server from the command line if we use that startup script? I'm guessing we won't be able to. I am also guessing it might not be an issue if admin commands can be executed from connected clients who have admin privileges.
     
  7. sb_blakphyre

    sb_blakphyre Yeah, You!

    Ah, I see. I started using the other thread on here about setting it up and then tried to just roll into using your service script. Looks like I've broken it.
     
  8. DeMossiah

    DeMossiah Master Chief

    You could mod the init script and leave out the user/group settings, but then it would be running as root which isnt the best of idea's.
     
  9. liamdawe

    liamdawe Subatomic Cosmonaut

    I cant seem to run this:
    As it gives me this:
    root@starbound2:~# su - steam -c "/home/steam/Steam/SteamApps/common/Starbound/linux64/launch_starbound_server.sh"
    -su: /home/steam/Steam/SteamApps/common/Starbound/linux64/launch_starbound_server.sh: No such file or directory

    Edit:
    It seems it installed to:
    /opt/steam/SteamApps/common/Starbound/linux64/

    Not sure why, followed the guide!
     
    Last edited: Dec 5, 2013
  10. sb_blakphyre

    sb_blakphyre Yeah, You!

    You might need to download 32 bit libraries if you're running 64 bit ubuntu (https://developer.valvesoftware.com/wiki/SteamCMD#32-bit_libraries_on_64-bit_Linux_systems)
     
  11. Syntax42

    Syntax42 Pangalactic Porcupine

    Is your OS 64-bit? What do you see when you type this? cat /etc/*-release
     
  12. bibby

    bibby Void-Bound Voyager

    Does it take you guys like, forever to download the game?

    App state (0x300502) downloading, progress: 1.14 (35265919 / 3082463860)

    It's only increased 1 % in the last 4 hours for me, and my vps is on a Gbps connection.
     
  13. entropyrat

    entropyrat Aquatic Astronaut

    Seeing this:

    root@debt:/home/steam/Steam/SteamApps/common/Starbound/linu3.2# service starbound start
    * Starting Starbound Server Daemon... starbound [ OK ]
    root@debt:/home/steam/Steam/SteamApps/common/Starbound/linu3.2# service starbound status
    * Starbound Server Daemon 'starbound' is not running.

    (Added the . between the 3 and 2 due to the auto-emoticon)

    No idea what is going on here. Any ideas?
     
  14. DeMossiah

    DeMossiah Master Chief

    @liamdawe, I have no idea why it did that, not that familiar with how the Steam client works. But as long as all the files are owned by the steam user it's all good. Some guesses as to what could've happened:
    You added the steam user after installing the game.
    You didn't CHMOD the entire steam folder (using -R).
    But again, not sure how it happened.

    @entropyrat, You can see the full textual output by running
    Code:
    su - steam -c "/home/steam/Steam/SteamApps/common/Starbound/linux64/launch_starbound_server.sh"
    In there should be a clear indication as to why thing's arn't working. If that works flawlessly then I'll look into it tomorrow.
     
  15. Ceetee

    Ceetee Void-Bound Voyager

    Im attempting to get this working. When I enter the command
    Code:
    su - steam -c "/home/steam/Steam/SteamApps/common/Starbound/linux32/launch_starbound_server.sh"
    it starts up, but with MANY warnings. Things like
    etc

    if i enter the script you mentioned, and then try to execute it, it tells me
    and if I enter the auto-execute command, it tells me
    While I have no real experience with linux (short of trying out a ubuntu distro on my PC for a month just to see what it was like) as far as I can tell, the problem seems to either be a bug with the starbound server itself, or it wasn't properly installed, however, if it is the latter, I have no idea how to go about uninstalling it then reinstalling it.

    If it makes any difference, I am using a VPS, running Ubuntu 12.04 32-bit (Minimal)
     
    GennyP likes this.
  16. Altwazar

    Altwazar Void-Bound Voyager

    I just added LD_LIBRARY_PATH=./ after do_start() {
     
  17. SavageCore

    SavageCore Void-Bound Voyager

    This creates 4 processes and service starbound stop does not close the correct one (last created)

    Any ideas?

    Running Ubuntu 13.10 x64
     
    Last edited: Dec 6, 2013
  18. TypoTech

    TypoTech Big Damn Hero

    Instead of using --disabled-login during user creation, you could create a service account. This will allow you to sudo su - steam from your regular user if you wish:

    Code:
    useradd -r -m -d /opt/steam -s /bin/bash steam
    This will create a system account for steam (-r), create the home directory (-m) in /opt/steam (-d) and set the shell (-s) for the steam user to bash.
     
  19. Kerpal

    Kerpal Orbital Explorer

    service starbound start doesn't working for me... i get always this
    Code:
    starbound: unrecognized service
    Any idea why?

    Server start works but it gets Killed after some minutes :/
    Code:
    su - steam -c "/home/steam/Steam/SteamApps/common/Starbound/linux64/launch_starbound_server.sh"
     
    Last edited: Dec 6, 2013
  20. SavageCore

    SavageCore Void-Bound Voyager

    Code:
    chmod +x /etc/init.d/starbound
    Now it should work
     

Share This Page