ID:724528
 
[Thanks to ATHK for this post!] If you do have root access run copy and paste the below into the terminal
wget http://www.byond.com/download/build/496/496.1138_byond_linux.zip
wget http://www.byond.com/download/build/gcc/libstdc++-libc6.2-2.so.3
wget http://www.byond.com/download/build/gcc/libstdc++.so.5
unzip 496.1138_byond_linux.zip
cd byond
make install
DreamDaemon -version
The two GCC libs are downloaded incase you need them although it may not be needed Then you can run the game like so
DreamDaemon game.dmb 12345 -trusted -logself
If you want to have the game hosted even when you logout and close your window, use the & operator. Will cause the command to be forked and run in the background (you can always kill it by itís PID).
DreamDaemon game.dmb 12345 -trusted -logself &
-logself will out put errors and the like, also if it can connect to the hub using the supplied port. Also remember you may need to open the port in iptables.
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport PORT -j ACCEPT &
PORT would be the one you chose prior.
This is my step-by-step protocol for setting up BYOND for Linux. It includes everything from installation up through some more-advanced implementations, such as how to set up an automatic game launcher or an auto-updater.

note: terminal commands are shown in code quotes



----- Standard Use: Installing BYOND -----

1) install your favorite flavor of Linux and update your system

2) open your browser and visit http://www.byond.com/download/

3) right click the link for "Linux" and then click "copy link location"

4) open a terminal window

5) download the latest version of BYOND for Linux:
wget [middle click]
middle click pastes the copied link, so your command should look something like this:
wget http://www.byond.com/download/build/479/479.1086_byond_linux.zip
(but with the latest Linux version). Press enter to download the files.

6) unzip the install files
unzip *_byond_linux.zip

7) install BYOND. Here you have two options. You can either "source" BYOND for local use (can only be used by a single user and has some other limitations) or you can install BYOND as root for use by all users. You need to have administrator privileges to install BYOND for all users.
--- 7a) to install as root:
cd byond
sudo make install
[enter your password]
cd ..
rm -rf *byond*
--- 7b) to install for local use:
nano ~/.bashrc
add the line:
source /home/user/byond/bin/byondsetup
(You can install BYOND elsewhere if you like; just make sure you source "byondsetup", wherever it's located)
Ctrl-O to save; Ctrl-X to exit

Congratulations, you can now host games in Linux! Simply navigate to the location of your host files and use the command:
DreamDaemon [yourgame].dmb [port] [options]

Options can include things like -invisible to host in invisible mode, -trusted to allow access outside of the game folder, etc.
If you use the command
DreamDaemon
by itself, it will show you a list of valid options.

As an example, your game hosting command might look something like this:
DreamDaemon MyGame.dmb 1234 -invisible

now, for another basic Linux concept:



----- Standard Use: Running in Background -----

If you host a game in the terminal and then close the terminal, logout, shutdown, or press Ctrl-C, it will kill your game. To prevent this from happening, you can run your game in the background by adding a '&' to the end of your DreamDaemon command. e.g.:
DreamDaemon mygame.dmb 1234 -invisible &
[press enter once again]
Now you can close the terminal or even logout completely, and your game will continue running. (Of course, if you reboot your computer, it will kill the game.)

Now for the cool stuff...



----- Intermediate: Automatic Game Hosting -----

This is a great feature if you want a game to run automatically after a server reboot, if you want your game to go back up after crashes even if you aren't around, or if you want to setup a simple auto-updater for your game (more on that later). Although it is possible to setup auto-hosting using other techniques, this is the method that I use.

First, make a folder for scripts (in a place that's easy to find/manage). Let's use the home directory. In the terminal:
cd
mkdir cron
cd cron
nano
(I recommend nano because it's universal, though I prefer gedit.)

Now, "copy" the following code and paste it into the nano text editor by middle clicking.
#!/bin/bash
for t in {1..12}
do
if [ -z "$(ps -C DreamDaemon | grep DreamDaemon)" ]
then
/usr/local/bin/DreamDaemon /path/to/game.dmb port -options &
fi
sleep 5
done

So what does this script do? This script checks every 5 seconds (for a total of 55 seconds) to see whether DD is running. If it isn't, it executes DD to re-launch your game.

some notes:
1) I recommend using the full path for DD for reasons I'll show later. If you installed BYOND for local use, you will need to edit the path as applicable.
2) /path/to/game.dmb is the location of your game's .dmb, e.g. /home/user/mygame/mygame.dmb
3) port is a number, e.g. 1234
4) for info on -options, use the DreamDaemon command in terminal
5) use '&' to run in background

Once you've configured the file as needed, use Ctrl-O to save it (call it launch_mygame.sh), and Ctrl-X to exit nano.

Now we need to configure crontab to run the script.

note: You have the option of using your local user-specific crontab; however, if you do so, the script will only be executed while you are logged in (whether you are sitting in front of the machine or using SSH). If possible, I recommend using the "root" crontab; doing so will execute your script any time the computer is running, even if no one is logged in.)

to use the "root" crontab, type:
sudo su
[enter your password if necessary]
The next steps are the same regardless of whether you're using the "root" or "user" crontab:
crontab -e
If you've never used crontab before, it will ask you to select an editor. Use nano unless you're familiar with one of the others. Scroll to the bottom of the script and add the line:
* * * * * /bin/bash /home/user/cron/launch_mygame.sh > /dev/null 2>&1
(obviously, you need to edit /home/user as applicable)
Ctrl-O to save, and Ctrl-X to exit
if logged in as root:
exit

So what does this do? * * * * * means that, every minute, the job scheduler will run the command specified, i.e. running your launch_mygame.sh script using bash. Any output is sent to /dev/null and ignored

Congratulations, you now have an auto-launching BYOND-game in Linux.



----- Advanced: Multi-Auto-Hosting -----

As you may have noticed in the previous section, launch_mygame.sh only checks to see if DreamDaemon is running
if [ -z "$(ps -C DreamDaemon | grep DreamDaemon)" ]
but this doesn't specify what game DD is running.

So here we'll set up a script to auto-run TWO different games.
cd ~/cron
nano launch_mygame.sh


now edit the file so it looks like this:
#!/bin/bash
for t in {1..12}
do
if [ -z "$(ps -C CustomDaemon1 | grep CustomDaemon1)" ]
then
/usr/local/bin/CustomDaemon1 /path/to/game1.dmb port -options &
fi
if [ -z "$(ps -C CustomDaemon2 | grep CustomDaemon2)" ]
then
/usr/local/bin/CustomDaemon2 /path/to/game2.dmb port -options &
fi
sleep 5
done
You can choose any name you want in place of CustomDaemon.

Our modified script now checks, for each game, whether its custom implementation of DD is running. Now we need to setup the custom daemons. If you've installed BYOND as root:
sudo su
[enter password if applicable]
cd /usr/local/bin
ln -s /usr/local/byond/DreamDaemon CustomDaemon1
ln -s /usr/local/byond/DreamDaemon CustomDaemon2
exit
If you're running BYOND for local use:
cd ~/byond/bin
ln -s DreamDaemon CustomDaemon1
ln -s DreamDaemon CustomDaemon2

And... we're done! Now, using CustomDaemon1 or CustomDaemon2 in the terminal launches DD but reports (in top or ps -x) as if it were a program called CustomDaemon{1,2}. Thus our launch_mygame.sh script can check whether each program is running based on whether its dedicated daemon is running.

note: If you installed as root, your symlinks will be retained even if you update your BYOND version using "sudo make install" (e.g. when a new linux version comes out). If you installed for local use, you can retain your symlinks by installing BYOND thus:
unzip *_byond_linux.zip
and when prompted to replace a file, enter 'A' for all. In this way, the BYOND files will be updated but your symlinks won't be effected.



----- Advanced: Auto-Updater -----

So you already have a system in place to host your game whenever it's down. Now let's take it a step further, to have our game check whether an update is present, kill itself, and then relaunch using the updated host files.

First, create a game subfolder called update.
cd ~/path/to/mygame
mkdir update

Now, edit your game (yes, you can do this through bash by parsing the job ID, but it's easiest this way) and add the following, either to your startup script or into your game's equivalent of crontab.
spawn() for()
if(fexists("update/mygame.dmb"))
world.Del()
sleep(10)

Thus, your game will check once per second to see whether an update is available (and shut itself down if there is an update available).

note: Other implementations of this system are possible, such as FFO's automatic 10-minute shutdown timer when an update is detected. (See? There is a reason to do this in-game instead of using bash...)

Now we edit launch_mygame.sh to implement the update:
    ...
if [ -z "$(ps -C MyCustomDaemon | grep MyCustomDaemon)" ]
then
mv /path/to/mygame/update/* /path/to/mygame/
/usr/local/bin/MyCustomDaemon /path/to/mygame/mygame.dmb port -options &
fi
...

Thus, if there's anything in the update folder, it will be moved to the game's root folder and overwrite it. If there's nothing in the folder, the mv error is ignored (sent to /dev/null as you may recall), and the script launches the existing host files. This allows you to update your game by either depositing a .dmb in the appropriate folder (e.g. using scp, SSH Secure Shell, or equivalent) or by uploading it directly through your game.
In response to Gakumerasara
Depending if you have ROOT access or not it is pretty simple (with root)

apt-get install make wget unzip zip
wget http://www.byond.com/download/build/493/493.1116_byond_linux.zip
unzip 493.1116_byond_linux.zip
cd byond
make install
DreamDaemon -version


Start a game from terminal and leave it running in the background

DreamDaemon "/home/blah anme/123 123.dmb" PORT -safe -logself &