[linux] Dedicated server init script

Find multiplayer games.
Tools/scripts to run a dedicated server.
Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

Blaster wrote:What's the deal with the ../../ in the path configs? Isthere a reason this is there?
Do you mean the:

Code: Select all

[path]
read-data=__PATH__executable__/../../data
write-data=__PATH__executable__/../..
on config/config.ini? If so, this is a reference to "two directory above the executable file", ergo factorio, when running the executable needs a way to reference the root "factorio" directory where all data lives - this is how you reference the top level directory in the factorio directory hierarchy. Alternatively you could omit the executable part and type in your path manually like /absolute/path/to/factorio and /absolute/path/to/factorio/data.

In short, it's there so you don't have to set an absolute path - factorio (and this init script) will use this relative path to know where to store save files and logs etc.
If I may, is this a problem of some kind or why do you ask? :)
Hosting a factorio server? Take a look at this || init script ||.
TheEisbaer
Burner Inserter
Burner Inserter
Posts: 8
Joined: Mon Apr 14, 2014 11:18 am
Contact:

Re: [linux] Dedicated server init script

Post by TheEisbaer »

Hi,

when I try to install this script at

Code: Select all

 systemctl status -l factorio
I get the following output:

Code: Select all

Unit factorio.service entered failed state.
factorio.service failed.
It's my first time using linux CentOS 7, and this message doesn't seem right, any advice?
Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

TheEisbaer wrote:It's my first time using linux CentOS 7, and this message doesn't seem right, any advice?
I've given you some suggestions in your github issue.
Hosting a factorio server? Take a look at this || init script ||.
nevniv
Inserter
Inserter
Posts: 49
Joined: Wed Sep 21, 2016 1:37 am
Contact:

Re: [linux] Dedicated server init script

Post by nevniv »

Hi Bisa,

I just wanted to say thank you for making this script. I used it back when 14 was experimental and I'm about to host a server for some friends and I'll be using it again this week for 15!
Klynn
Burner Inserter
Burner Inserter
Posts: 6
Joined: Wed Mar 23, 2016 11:08 pm
Contact:

Re: [linux] Dedicated server init script

Post by Klynn »

I'm trying to use the script to install Factorio and am running into a permissions issue. I need permission to write to /opt in order to do the install, but I also believe I should not be running the install as root. What's the best way to get around this issue (sorry I'm a relative novice with Linux).

Also the tar arguments in the script don't seem to work as it appears Wube has changed the way they zip the servers. I modified the script per the issue on Github and that worked.

Also thanks for all of your work on this!
nevniv
Inserter
Inserter
Posts: 49
Joined: Wed Sep 21, 2016 1:37 am
Contact:

Re: [linux] Dedicated server init script

Post by nevniv »

I can try to explain with my intermediate linux knowledge and beer I have consumed tonight..hopefully I make sense :)

Did you make an extra user account for factorio yet? That would be best practice.

If you do a "ls -l" on the directory, you should see who owns the files you are trying to modify. You could do the install with any account, not a real big deal. But at the end when you actually want to run it, that's when I'd recommend you use the separate factorio account.

If the accounts are owned by your username, or root, you can do "chown -R username:username *" to give ownership of the directory you are in and all subdirectories to whatever factorio account you have created.

Then to run the init script you can do sudo -u (username here) service factorio (command). For example I do "sudo -u factorio service factorio start"

As long as your factorio account owns all the files for factorio and the init scripts, when you try to run it you should be good to go I think.
Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

nevniv wrote:I just wanted to say thank you for making this script.
You are most welcome, glad you find it useful :)
Klynn wrote:I need permission to write to /opt in order to do the install, but I also believe I should not be running the install as root.
Ouch, I had not thought that one through, currently the user running the install script needs write permission in the directory where you want to install the "factorio" directory.

To get around this, you can either:
1. Install in a directory where the factorio user has write access (such as it's own home directory /home/factoriouser/factorio)
3. Grant the factorio user temporary write permissions in /opt (I do not endorse this approach but it is an option...)
2. Run as root (but yes, good call, do not blindly run things as root!)

Thank you for pointing this out, I'll see if I can make it more clear that the directory in which you want to install needs to be writable.
Hosting a factorio server? Take a look at this || init script ||.
Klynn
Burner Inserter
Burner Inserter
Posts: 6
Joined: Wed Mar 23, 2016 11:08 pm
Contact:

Re: [linux] Dedicated server init script

Post by Klynn »

nevniv wrote:I can try to explain with my intermediate linux knowledge and beer I have consumed tonight..hopefully I make sense :)

Did you make an extra user account for factorio yet? That would be best practice.

If you do a "ls -l" on the directory, you should see who owns the files you are trying to modify. You could do the install with any account, not a real big deal. But at the end when you actually want to run it, that's when I'd recommend you use the separate factorio account.

If the accounts are owned by your username, or root, you can do "chown -R username:username *" to give ownership of the directory you are in and all subdirectories to whatever factorio account you have created.

Then to run the init script you can do sudo -u (username here) service factorio (command). For example I do "sudo -u factorio service factorio start"

As long as your factorio account owns all the files for factorio and the init scripts, when you try to run it you should be good to go I think.
Yes, I do have a Factorio account. I am installing all of the Factorio stuff into /opt/ (isn't that where the install script does it automatically?) It seems to be a bad idea to chown the whole /opt/ directory away from root, right?
Bisa wrote:
Klynn wrote:I need permission to write to /opt in order to do the install, but I also believe I should not be running the install as root.
Ouch, I had not thought that one through, currently the user running the install script needs write permission in the directory where you want to install the "factorio" directory.

To get around this, you can either:
1. Install in a directory where the factorio user has write access (such as it's own home directory /home/factoriouser/factorio)
3. Grant the factorio user temporary write permissions in /opt (I do not endorse this approach but it is an option...)
2. Run as root (but yes, good call, do not blindly run things as root!)

Thank you for pointing this out, I'll see if I can make it more clear that the directory in which you want to install needs to be writable.
Okay, I installed to /opt/ as that seems to be the standard thing to do (and when you're piecing together instructions on the internet to run a program in a command line on an OS you're not super familiar with, it seems like deviating from the standard is asking for confusion).

I ended up getting everything running by running the install command with sudo. Now I'm having an issue that I'm running 15.4 but running "Factorio Update" is telling me there isn't a newer version even though 15.5 is out. Am I missing a flag I need to tell it to look for an experimental build?

Thank you so much for your help!
nevniv
Inserter
Inserter
Posts: 49
Joined: Wed Sep 21, 2016 1:37 am
Contact:

Re: [linux] Dedicated server init script

Post by nevniv »

Klynn wrote:
nevniv wrote:I can try to explain with my intermediate linux knowledge and beer I have consumed tonight..hopefully I make sense :)

Did you make an extra user account for factorio yet? That would be best practice.

If you do a "ls -l" on the directory, you should see who owns the files you are trying to modify. You could do the install with any account, not a real big deal. But at the end when you actually want to run it, that's when I'd recommend you use the separate factorio account.

If the accounts are owned by your username, or root, you can do "chown -R username:username *" to give ownership of the directory you are in and all subdirectories to whatever factorio account you have created.

Then to run the init script you can do sudo -u (username here) service factorio (command). For example I do "sudo -u factorio service factorio start"

As long as your factorio account owns all the files for factorio and the init scripts, when you try to run it you should be good to go I think.
Yes, I do have a Factorio account. I am installing all of the Factorio stuff into /opt/ (isn't that where the install script does it automatically?) It seems to be a bad idea to chown the whole /opt/ directory away from root, right?
I don't do the whole directory, just the factorio-related folders. In my case it is /opt/factorio and /opt/factorio-init. I do not remember if I deviated from the norm at all when installing.

I've never tried to get the auto-update to work, I just download manually. :( Bisa or someone else may have to help you with that.

I just download the headless version, SFTP it up, then tar -xvf it over the current one
Klynn
Burner Inserter
Burner Inserter
Posts: 6
Joined: Wed Mar 23, 2016 11:08 pm
Contact:

Re: [linux] Dedicated server init script

Post by Klynn »

nevniv wrote:
Klynn wrote:
nevniv wrote:I can try to explain with my intermediate linux knowledge and beer I have consumed tonight..hopefully I make sense :)

Did you make an extra user account for factorio yet? That would be best practice.

If you do a "ls -l" on the directory, you should see who owns the files you are trying to modify. You could do the install with any account, not a real big deal. But at the end when you actually want to run it, that's when I'd recommend you use the separate factorio account.

If the accounts are owned by your username, or root, you can do "chown -R username:username *" to give ownership of the directory you are in and all subdirectories to whatever factorio account you have created.

Then to run the init script you can do sudo -u (username here) service factorio (command). For example I do "sudo -u factorio service factorio start"

As long as your factorio account owns all the files for factorio and the init scripts, when you try to run it you should be good to go I think.
Yes, I do have a Factorio account. I am installing all of the Factorio stuff into /opt/ (isn't that where the install script does it automatically?) It seems to be a bad idea to chown the whole /opt/ directory away from root, right?
I don't do the whole directory, just the factorio-related folders. In my case it is /opt/factorio and /opt/factorio-init. I do not remember if I deviated from the norm at all when installing.

I've never tried to get the auto-update to work, I just download manually. :( Bisa or someone else may have to help you with that.

I just download the headless version, SFTP it up, then tar -xvf it over the current one
Ah, I was worried about that dumping my save files. I ended up running the factorio-update script manually, followed by the Factorio --apply-update flag. I noticed when I ran that there was some feedback about downloading the update directly, which makes me wonder if the headless server actually has a built in auto updater?
tacgnol
Inserter
Inserter
Posts: 36
Joined: Sun May 29, 2016 3:51 am
Contact:

Re: [linux] Dedicated server init script

Post by tacgnol »

Hello Bisa,

You seems to be away since a while, and it's okay :)

buy I was wondering if you could update your github project with the current pull request, it would make life a bit easier :0

thanks in advance!
Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

tacgnol wrote:thanks in advance!
You are welcome! ;)
Hosting a factorio server? Take a look at this || init script ||.
Dergonic
Inserter
Inserter
Posts: 44
Joined: Mon Jun 06, 2016 8:56 am
Contact:

Re: [linux] Dedicated server init script

Post by Dergonic »

I just used the script to install my Factorio server on a OVH VPS.
Thanks for it ! This is so easy and no issue at all !
Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

Cool, glad you found it useful :)
Hosting a factorio server? Take a look at this || init script ||.
Defcon5
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Apr 25, 2020 7:58 am
Contact:

Re: [linux] Dedicated server init script

Post by Defcon5 »

Hello,

I`m new on this so sorry for maybe the wrong question or not read the whole story.

I have a linux dedicated services running, but i don`t understand how your script excacly works.
Did not install factorio on the server, I just downloaded the headless server and stored the executeable file in the home dir.
This is like this :

/home/factorio/Services/Factorio_a/
# here I put all the files.
- home -> factorio -> Services -> Factorio_a -> Settings
- home -> factorio -> Services -> Factorio_a -> bin
- home -> factorio -> Services -> Factorio_a -> config
- home -> factorio -> Services -> Factorio_a -> data
- home -> factorio -> Services -> Factorio_a -> mods
- home -> factorio -> Services -> Factorio_a -> saves
- home -> factorio -> Services -> Factorio_a -> scenarios
etc...

Now I want to run you script, but seems i get errors like the config file not found... etc..
Where do I change the PATHS and on wich lines?

the reason i did not install the game on the linux server, is that i want to run other programm`s as well.

Maight be wrong, but this is how i always did it and I had help from a good friend of me, he really understand linux much better than me, but during hi`s jobs and other work, he has no time to help me out.
I am like a linux noob, but I understand some of the commands and know how to use them.

So can you help me out?
Currently I run it when I logged in.
factorio version : 0.18.21 (test)

Thanks for the help in advanced.

Regards,
Bisa
Filter Inserter
Filter Inserter
Posts: 450
Joined: Fri Jul 17, 2015 3:22 pm
Contact:

Re: [linux] Dedicated server init script

Post by Bisa »

Defcon5 wrote: Sat Apr 25, 2020 8:14 am Now I want to run you script, but seems i get errors like the config file not found... etc..
Where do I change the PATHS and on wich lines?
Hi, I'm sure you got it sorted eventually ;)
for future reference, please report issues at https://github.com/Bisa/factorio-init/issues (oh, and the changes you were looking for may have been in the config.example file)
Hosting a factorio server? Take a look at this || init script ||.
Post Reply

Return to “Multiplayer / Dedicated Server”