Starbound

Starbound

44 ratings
CentOS 32-bit/64-bit and Starbound Server installation, chroot, startup script and newest libstdc++.so.6
By class101 [ѕtеαмdеcκ]
WARNING : The guide was designed for Alpha pre release of Starbound, but experimented Linux users might still find usefull and working informations on how to secure your server into a CentOS chroot without a lot of effort. It still works under CentOS 7. If you need more informations, feel free to contact me on my profile page. Have fun in Starbound !

This guide explains from A to Z how to cleanly install a Starbound server on the Enterprise-class Linux Distribution CentOS.
No changes are made in the base system, no conflicts with the current services, everything is installed under the chroot directory /chroot-starbound/ so that you can wipe and restart at anytime with a single command rm /chroot-starbound -fr. Also it is important to note that this method does not edit the Starbound files unlike the bspatch method. It also demonstrates how you can compile gcc to get the libstdc++.so.6 and libgcc_s.so.1 to match the version Chucklefish used to support.

[community.playstarbound.com]

Once everything is set you will have access to few more commands:

From inside the chroot
Command
Informations
chroot /chroot-starbound
Enter the chroot
/etc/init.d/starbound start
Start the Starbound server
/etc/init.d/starbound stop
Stop the Starbound server
/etc/init.d/starbound connect
Connect to the screen session, Ctrl-A+D to detach once you have done, useful for looking at live logs of the service
/etc/init.d/starbound restart
Stop and start the Starbound server

Or from outside
Command
Informations
service chroot_env start
Start the Starbound server (executed by system as service boot)
service chroot_env stop
Stop the Starbound server
service chroot_env restart
Stop and start the Starbound server

Note: This is a generic method, it has been successfully tested with Starbound on CentOS 6.x 32-bit and 64-bit and also after some slight modifications with Terraria and King Arthur's Gold servers.

Guide version : 1.0.6 (Latest changes)
Guide difficulty : Easy
System Requirements : CentOS 6.x 32-bit or 64-bit (i686 and x86_64)
   
Award
Favorite
Favorited
Unfavorite
1. Install: All the commands (for advanced users)
In the block below all the commands of the guide, if you are new with Linux I recommend to start at section 2.

starbound server copy-paste installation (supports 32-bit & 64-bit)
(See the guide section 2. for more details)
cd / mkdir -p /chroot-starbound/ mkdir -p /chroot-starbound/var/lib/rpm rpm --rebuilddb --root=/chroot-starbound/ # CentOS 7.1 ? # rpm -i --root=/chroot-starbound --nodeps http://mirror.centos.org/centos/7/os/$(uname -i)/Packages/centos-release-7-1.1503.el7.centos.2.8.$(uname -m).rpm rpm -i --root=/chroot-starbound --nodeps http://mirror.centos.org/centos/6/os/$(uname -i)/Packages/centos-release-6-7.el6.centos.12.3.$(uname -m).rpm yum --installroot=/chroot-starbound install -y rpm-build yum cp /etc/resolv.conf /chroot-starbound/etc/resolv.conf cp /etc/sysconfig/network /chroot-starbound/etc/sysconfig/network cp /etc/rc.d/init.d/functions /chroot-starbound/etc/rc.d/init.d/functions echo "/dev /chroot-starbound/dev none bind 0 0" >> /etc/fstab echo "/dev/pts /chroot-starbound/dev/pts none bind 0 0" >> /etc/fstab echo "/proc /chroot-starbound/proc proc defaults,noatime 0 0" >> /etc/fstab echo "/sys /chroot-starbound/sys sysfs defaults,noatime 0 0" >> /etc/fstab mount -a cp /chroot-starbound/etc/skel/.??* /chroot-starbound/root chroot /chroot-starbound yum -y install screen wget gcc gcc-c++ make zip tar glibc procps vi nano initscripts SDL libvorbis libogg libpng freetype openssl yum -y update mkdir -p /tools/installers_to_delete/ --[ Building the newer c++ lib to /tools/gcc-4.8.2/ ]-- cd /tools/installers_to_delete/ wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz tar -xzvf gcc-4.8.2.tar.gz cd gcc-4.8.2 ./contrib/download_prerequisites cd .. mkdir gcc-4.8.2-obj cd gcc-4.8.2-obj/ $PWD/../gcc-4.8.2/configure --prefix=/tools/gcc-4.8.2 --enable-languages=c++ --disable-nls --disable-multilib --disable-libgcj --without-headers --disable-static --[ WARNING: can take several hours on single procs, and just around 20min on i7-like procs, can be quicker to generate at home and upload ]-- make -j6 make -j6 install useradd starbound mkdir /starbound mkdir -p /tools/steamcmd_linux mkdir -p /var/run/starbound --[ Installing Starbound Dedicated Server ]-- cd /tools/steamcmd_linux yum -y install glibc.i686 libstdc++.i686 wget http://media.steampowered.com/client/steamcmd_linux.tar.gz tar -xzvf steamcmd_linux.tar.gz ./steamcmd.sh +login login password +force_install_dir /starbound/ +app_update 211820 validate +quit --[ Linking the newer c++ lib to Starbound ]-- ln -s /tools/gcc-4.8.2/lib*/libstdc++.so.6 /starbound/linux$(getconf LONG_BIT)/libstdc++.so.6 ln -s /tools/gcc-4.8.2/lib*/libgcc_s.so.1 /starbound/linux$(getconf LONG_BIT)/libgcc_s.so.1 chown starbound:starbound /starbound -R chown starbound:starbound /var/run/starbound -R chmod 774 /starbound -R find /starbound -type d -exec chmod g+s {} \; chmod g+s /var/run/starbound su starbound /starbound/linux$(getconf LONG_BIT)/launch_starbound_server.sh

Starbound server launcher script (removed since update Furious Koala)
(See the guide section 2. for more details)
#!/bin/sh cd "$(dirname "$0")" LD_LIBRARY_PATH=./ ./starbound_server

Starbound server startup script (start stop restart connect easily)
(See the guide section 3. for more details)
#!/bin/bash # chkconfig: 345 70 30 # description: Start/stop Starbound server # tip: Ctrl-A + D (to detach from an interactive screen window) NAME="starbound_server" USERID=starbound BINDIR=/starbound/linux$(getconf LONG_BIT) SCREENDAEMON=/usr/bin/screen DAEMON=launch_starbound_server.sh PIDFILE=/var/run/starbound/sb.pid # All important args DAEMONARGS="" # Command sent to server to exit, try just "exit" to save world before exit. You WILL need to increase EXIT_TIMEOUT (try 30+) EXIT_COMMAND="exit" # wait X seconds for the server to exit EXIT_TIMEOUT=30 # Source function library. . /etc/rc.d/init.d/functions # Exit if screen cant be found [ -x "${SCREENDAEMON}" ] || exit 0 # Exit if daemon cant be found [ -r "${BINDIR}/${DAEMON}" ] || exit 0 # Exit if bin folder cant be found [ -d "${BINDIR}" ] || exit 0 checkScreen() { doPID # Wipe the screen session marked as 'Dead' for false-positives checkScreen su ${USERID} -c "${SCREENDAEMON} -wipe" > /dev/null 2>&1 if [ -e /var/run/screen/S-${USERID}/*.${NAME} ]; then return 0; fi return 1 } checkPID() { doPID if [ -e ${PIDFILE} ] && kill -0 $(cat ${PIDFILE} 2>/dev/null) > /dev/null 2>&1; then return 0; fi return 1 } doPID() { pidof -c starbound_server > ${PIDFILE} return 0 } start() { echo -n $"Starting $NAME: " RETVAL=1 if checkScreen || checkPID; then echo -n "(already running)"; else su ${USERID} -c "${SCREENDAEMON} -dmS ${NAME} ${BINDIR}/${DAEMON} ${DAEMONARGS}"; # Wait up to 10 seconds for it to start for i in {0..10}; do if checkPID; then RETVAL=0; break; fi # found running PID sleep 1 done fi if [ $RETVAL = 0 ]; then success else failure fi; echo return $RETVAL } stop() { echo -n $"Stopping $NAME: " RETVAL=1 if ! checkScreen || ! checkPID; then echo -n "(not running, or stale pidfile)" else kill -INT $(cat ${PIDFILE} 2>/dev/null) > /dev/null 2>&1; n=${EXIT_TIMEOUT} for (( i=0; i<n; i++ )); do if ! checkScreen; then RETVAL=0; break; fi; sleep 1; done fi if [ $RETVAL = 0 ]; then success else failure fi; echo return $RETVAL } cd ${BINDIR} case "$1" in start) start ;; stop) stop ;; restart) $0 stop $0 start ;; connect) if checkScreen; then # Use script to bypass TTY issues su ${USERID} -c "script -qc \"${SCREENDAEMON} -dr ${NAME}\" /dev/null" else echo "${NAME}: Connect failed. (screen not running)" fi ;; *) echo "Usage: ${NAME} {start|stop|restart|connect}" 2>&1 ;; esac

Start when the computer start (start stop restart as a system service outside the chroot)
(See the guide section 4. for more details)
#!/bin/bash # # chroot_env Start/Stop chroot env daemons # # chkconfig: 345 55 25 # description: Start/Stop chroot env daemons start() { chroot /chroot-starbound /etc/init.d/starbound start } stop() { chroot /chroot-starbound /etc/init.d/starbound stop } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo "Usage: chroot_env {start|stop|restart}" exit 1 ;; esac
2. Install: Step at step instructions
Chroot creation
The block below will create a new chroot environment in /chroot-starbound:
(The rpm link at http://mirror.centos.org/centos/6/os/ may change after each major CentOS update, I will do my best to update the link, feel free to contact else)
cd / mkdir -p /chroot-starbound/ mkdir -p /chroot-starbound/var/lib/rpm rpm --rebuilddb --root=/chroot-starbound/ # CentOS 7.1 ? # rpm -i --root=/chroot-starbound --nodeps http://mirror.centos.org/centos/7/os/$(uname -i)/Packages/centos-release-7-1.1503.el7.centos.2.8.$(uname -m).rpm rpm -i --root=/chroot-starbound --nodeps http://mirror.centos.org/centos/6/os/$(uname -i)/Packages/centos-release-6-7.el6.centos.12.3.$(uname -m).rpm yum --installroot=/chroot-starbound install -y rpm-build yum cp /etc/resolv.conf /chroot-starbound/etc/resolv.conf cp /etc/sysconfig/network /chroot-starbound/etc/sysconfig/network cp /etc/rc.d/init.d/functions /chroot-starbound/etc/rc.d/init.d/functions echo "/dev /chroot-starbound/dev none bind 0 0" >> /etc/fstab echo "/dev/pts /chroot-starbound/dev/pts none bind 0 0" >> /etc/fstab echo "/proc /chroot-starbound/proc proc defaults,noatime 0 0" >> /etc/fstab echo "/sys /chroot-starbound/sys sysfs defaults,noatime 0 0" >> /etc/fstab mount -a cp /chroot-starbound/etc/skel/.??* /chroot-starbound/root

Enter the chroot
We can now switch to this new chroot with:
chroot /chroot-starbound

Update the chroot
Ensure now the new chroot is up to date and has the tools we need to install:
yum -y install screen wget gcc gcc-c++ make zip tar glibc procps vi nano initscripts SDL libvorbis libogg libpng freetype openssl yum -y update

Get the newest GNU Standard C++ Library v3 to /tools/gcc-4.8.2
We will now compile the latest libstdc++.so.6 for the game server only. This is because by default CentOS 6.x ships with an older libstdc++ version and is not compatible with most modern game servers, this could be a very long step on older systems:
(Tip: On single processors , use -j1 instead of -j6)
mkdir -p /tools/installers_to_delete/ cd /tools/installers_to_delete/ wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz tar -xzvf gcc-4.8.2.tar.gz cd gcc-4.8.2 ./contrib/download_prerequisites cd .. mkdir gcc-4.8.2-obj cd gcc-4.8.2-obj/ $PWD/../gcc-4.8.2/configure --prefix=/tools/gcc-4.8.2 --enable-languages=c++ --disable-nls --disable-multilib --disable-libgcj --without-headers --disable-static make -j6 make -j6 install

Install Steam Command Line Client SteamCMD
The Valve developers provide a way to download Steam games directly from the command line:
useradd starbound mkdir /starbound mkdir -p /tools/steamcmd_linux mkdir -p /var/run/starbound cd /tools/steamcmd_linux yum -y install glibc.i686 libstdc++.i686 wget http://media.steampowered.com/client/steamcmd_linux.tar.gz tar -xzvf steamcmd_linux.tar.gz

Login to Steam and download Starbound
In the command line below replace login and password with yours:
(Tip: You may need to use the escape character \ with special characters)
./steamcmd.sh +login login password +force_install_dir /starbound/ +app_update 211820 validate +quit

Link the new C++ Library v3 to Starbound
The command line below supports both 32-bit and 64-bit version:
ln -s /tools/gcc-4.8.2/lib*/libstdc++.so.6 /starbound/linux$(getconf LONG_BIT)/libstdc++.so.6 ln -s /tools/gcc-4.8.2/lib*/libgcc_s.so.1 /starbound/linux$(getconf LONG_BIT)/libgcc_s.so.1

Create launch_starbound_server.sh
Since Furious Koala update, you need to create manually once the launch_starbound_server.sh script
Type nano /starbound/linux$(getconf LONG_BIT)/launch_starbound_server.sh and paste the following code
#!/bin/sh cd "$(dirname "$0")" LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./ ./starbound_server

Set the permissions
Set the game folder permissions more permissive to the starbound user:
chown starbound:starbound /starbound -R chown starbound:starbound /var/run/starbound -R chmod 774 /starbound -R find /starbound -type d -exec chmod g+s {} \; chmod g+s /var/run/starbound

Run the game server for the first time
Test now it runs fine under the user starbound:
su starbound /starbound/linux$(getconf LONG_BIT)/launch_starbound_server.sh

Congratulations ! You made it !

Now you just need to put this as a service to have it running at computer start, to do so, follow the next section.
3. Starbound server startup script
  • If you followed the previous steps, the server should be running, hit Ctrl-C to close it now
  • Copy the block below in a new file and name it starbound, for this you can execute nano starbound
    #!/bin/bash # chkconfig: 345 70 30 # description: Start/stop Starbound server # tip: Ctrl-A + D (to detach from an interactive screen window) NAME="starbound_server" USERID=starbound BINDIR=/starbound/linux$(getconf LONG_BIT) SCREENDAEMON=/usr/bin/screen DAEMON=launch_starbound_server.sh PIDFILE=/var/run/starbound/sb.pid # All important args DAEMONARGS="" # Command sent to server to exit, try just "exit" to save world before exit. You WILL need to increase EXIT_TIMEOUT (try 30+) EXIT_COMMAND="exit" # wait X seconds for the server to exit EXIT_TIMEOUT=30 # Source function library. . /etc/rc.d/init.d/functions # Exit if screen cant be found [ -x "${SCREENDAEMON}" ] || exit 0 # Exit if daemon cant be found [ -r "${BINDIR}/${DAEMON}" ] || exit 0 # Exit if bin folder cant be found [ -d "${BINDIR}" ] || exit 0 checkScreen() { doPID # Wipe the screen session marked as 'Dead' for false-positives checkScreen su ${USERID} -c "${SCREENDAEMON} -wipe" > /dev/null 2>&1 if [ -e /var/run/screen/S-${USERID}/*.${NAME} ]; then return 0; fi return 1 } checkPID() { doPID if [ -e ${PIDFILE} ] && kill -0 $(cat ${PIDFILE} 2>/dev/null) > /dev/null 2>&1; then return 0; fi return 1 } doPID() { pidof -c starbound_server > ${PIDFILE} return 0 } start() { echo -n $"Starting $NAME: " RETVAL=1 if checkScreen || checkPID; then echo -n "(already running)"; else su ${USERID} -c "${SCREENDAEMON} -dmS ${NAME} ${BINDIR}/${DAEMON} ${DAEMONARGS}"; # Wait up to 10 seconds for it to start for i in {0..10}; do if checkPID; then RETVAL=0; break; fi # found running PID sleep 1 done fi if [ $RETVAL = 0 ]; then success else failure fi; echo return $RETVAL } stop() { echo -n $"Stopping $NAME: " RETVAL=1 if ! checkScreen || ! checkPID; then echo -n "(not running, or stale pidfile)" else kill -INT $(cat ${PIDFILE} 2>/dev/null) > /dev/null 2>&1; n=${EXIT_TIMEOUT} for (( i=0; i<n; i++ )); do if ! checkScreen; then RETVAL=0; break; fi; sleep 1; done fi if [ $RETVAL = 0 ]; then success else failure fi; echo return $RETVAL } cd ${BINDIR} case "$1" in start) start ;; stop) stop ;; restart) $0 stop $0 start ;; connect) if checkScreen; then # Use script to bypass TTY issues su ${USERID} -c "script -qc \"${SCREENDAEMON} -dr ${NAME}\" /dev/null" else echo "${NAME}: Connect failed. (screen not running)" fi ;; *) echo "Usage: ${NAME} {start|stop|restart|connect}" 2>&1 ;; esac

  • Save the file and execute mv starbound /etc/init.d/ to move it in /etc/init.d/
  • Execute chmod 755 /etc/init.d/starbound to make it executable

Congratulations ! You can now use the startup script like that:

Make sure you stand in the chroot:
chroot /chroot-starbound

And:
/etc/init.d/starbound start /etc/init.d/starbound stop /etc/init.d/starbound connect /etc/init.d/starbound restart
4. Start Starbound server when computer starts
This time we will repeat what we have done in 3. but outside the chroot.
  • Important : If you followed the previous steps, execute exit to quit the chroot
  • Copy the block below in a new file and name it chroot_env, for this you can execute nano chroot_env
    (if you don't have nano installed, get it with yum install nano)
    #!/bin/bash # # chroot_env Start/Stop chroot env daemons # # chkconfig: 345 55 25 # description: Start/Stop chroot env daemons start() { chroot /chroot-starbound /etc/init.d/starbound start } stop() { chroot /chroot-starbound /etc/init.d/starbound stop } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo "Usage: chroot_env {start|stop|restart}" exit 1 ;; esac
  • Save the file and execute mv chroot_env /etc/init.d/ to move it in /etc/init.d/
  • Execute chmod 755 /etc/init.d/chroot_env to make it executable
  • Execute chkconfig --add chroot_env to install it as a new system service

Congratulations ! The game server will now automatically start when the computer start

You can also now start, stop and restart the game server from outside the chroot:
service chroot_env start service chroot_env stop service chroot_env restart
Frequently Asked Questions
Q: Help, I'm getting the following error when creating the chroot
warning: /chroot-starbound/var/tmp/rpm-tmp.jcalRs: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY error: open of /chroot-starbound/var/tmp/rpm-tmp.jcalRs failed: No such file or directory
A: You are not running an official image of CentOS, but a modified build provided by OVH. To know if you are running an official CentOS build, type uname -a you should see something similar to 2.6.32-431.1.2.0.1.el6.x86_64 and not 3.10.9-xxxx-grs-ipv6-64 or 3.2.13-grsec-xxxx-grs-ipv6-64. Unfortunately at this time no workaround is known (I hope you understand why in my opinion and in the opinion of many other admins OVH is a bad hosting company)

Q: How do you copy/paste, this is very long to type everything manually
A: It is not required to type every lines manually, get Kitty[www.9bis.net] and connect your 22/SSH tcp and you will be able to copy paste. You can also get WinSCP[winscp.net], good tool for file transfer through the same ssh port.
Latest changes
version 1.0.6 - CentOS 6.7/7.1 link update (August 26th 2015)
version 1.0.5 - CentOS 6.6 link update (November 7th 2014)
version 1.0.4 - Furious Koala changes, launch_starbound_server.sh creation (January 26th 2014)
version 1.0.3 - Updated the FAQ for people not knowing Kitty/WinSCP (January 06th 2014)
version 1.0.2 - Updated the FAQ with a common error seen on CentOS build by OVH (December 31th 2013)
version 1.0.1 - Fixed starbound script to support multiple chrooted game servers (pidof -c) (December 15th 2013)
version 1.0 - Initial guide creation (December 15th 2013)
43 Comments
暮光闪闪 10 Dec, 2019 @ 10:52pm 
太强了,我就喜欢CentOS,命令行系统的性能优于图形化界面,能帮我省下不少的服务器费用。
而且我工作上接触的也比较多~

In English:
Cool.
I love CentOS,because the performance of CLI was excellent than GUI.
And I use it frequent in my work.
class101 [ѕtеαмdеcκ]  [author] 26 Aug, 2015 @ 11:22am 
RPM links updated

CentOS 7.1 => http://mirror.centos.org/centos/7/os/$(uname -i)/Packages/centos-release-7-1.1503.el7.centos.2.8.$(uname -m).rpm

CentOS 6.7 => http://mirror.centos.org/centos/6/os/$(uname -i)/Packages/centos-release-6-7.el6.centos.12.3.$(uname -m).rpm
class101 [ѕtеαмdеcκ]  [author] 7 Nov, 2014 @ 1:16pm 
sure no problem you are welcome
Erica他惊讶的小伙伴狗薯 7 Nov, 2014 @ 8:09am 
that's good~
can i copy this article to other forum and translate it to chinese?
i will add this link on the top of the article
class101 [ѕtеαмdеcκ]  [author] 7 Nov, 2014 @ 5:52am 
Cool glad you got it, updated the guide to 1.0.5 , just changed the link to the rpm of centos 6.6 as the old one of centos 6.5 has been removed from the servers
Erica他惊讶的小伙伴狗薯 21 Oct, 2014 @ 12:53pm 
i ve done it!!!!!! thank you very much for answering my question and the guide is perfect!
i will tell my friend to follow this guide!
\(^o^)/\(^o^)/
Erica他惊讶的小伙伴狗薯 21 Oct, 2014 @ 7:06am 
oh no,there is no file in http://mirror.centos.org/centos/5.6/
Erica他惊讶的小伙伴狗薯 21 Oct, 2014 @ 6:55am 
i typed uname -a ane there is
3.15.4-x86_64-linode45 #1 SMP Mon Jul 7 08:42:36 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

Erica他惊讶的小伙伴狗薯 21 Oct, 2014 @ 6:50am 
= =,it's centos 5.6..
class101 [ѕtеαмdеcκ]  [author] 21 Oct, 2014 @ 6:06am 
maybe you are not on Centos 6.5 but the newer one 7.0 if thats the case this guide is not updated yet for 7.0 but it should be the same with some links to update as the rpm of 7.0 64-bit is here

http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-0.1406.el7.centos.2.3.x86_64.rpm

Or try to type uname -a to verify you are not on a modded centos, you should see something like 2.6.32-431.1.2.0.1.el6.x86_64 and not 3.10.9-xxxx-grs-ipv6-64