<commit_before># Factorio As A Service

This python script has 2 major purposes: create easily a systemd service for factorio on Linux and 
updating the game automatically.

## Requirements

* Linux supporting systemd
* Sudo installed
* python >= 3.4
* git

## How to download it ?
Go to the desired directory for the installation and use this command:
```bash
git clone https://github.com/Pirheas/factorio_as_a_service.git
```

## How to use it ?

First, I recommand to create a new user who will own both this script and the whole game directory.

Use the `-v` flag for verbose. It may be useful for debugging

Type this command for help:
```bash
$ python3 ./faas.py -h
```

#### 1. Configuration file

Edit the configuration file (`config.ini`)


You will have to configure at least these fields:

* __factorio-path__ : Path of the factorio directory (it should contains a `bin` and a `data` directory)
* __save-path__ : Path of the saved game (zip file). If you don't have created it yet, consider reading [this tuto](https://wiki.factorio.com/Multiplayer#Dedicated.2FHeadless_server)
* __user__ : The user who will execute the factorio server (choose an existing linux user, `root` is a bad idea but will works)

> NB: When you are using a relative path, the working directory will always be the directory that contains `faas.py`. Please consider using absolute path

#### 2. Download/Update the server

Once the destination is defined in the configuration file, execute the update command.
It will perform an update to the latest version (even if the directory is empty)

```bash
$ python3 ./faas.py -u
```

##### 2.1
If it's not done yet, [create your server save file](https://wiki.factorio.com/Multiplayer#Dedicated.2FHeadless_server)
and specify its path in `config.ini`

> Be sure that the user who is configured to launch the server has all permissions needed.<commit_msg>Updated doc for new parameters -C<commit_after># Factorio As A Service

This python script has 2 major purposes: create easily a systemd service for factorio on Linux and 
updating the game automatically.

## Requirements

* Linux supporting systemd
* Sudo installed
* python >= 3.4
* git

## How to download it ?
Go to the desired directory for the installation and use this command:
```bash
git clone https://github.com/Pirheas/factorio_as_a_service.git
```

## How to use it ?

First, I recommend to create a new user who will own both this script and the whole game directory.

Use the `-v` flag for verbose. It may be useful for debugging

Type this command for help:
```bash
$ python3 ./faas.py -h
```

#### 1. Configuration file

Edit the configuration file (`config.ini`)


You will have to configure at least these fields:

* __factorio-path__ : Path of the factorio directory (it should contains a `bin` and a `data` directory)
* __save-path__ : Path of the saved game (zip file). If you don't have created it yet, consider reading [this tuto](https://wiki.factorio.com/Multiplayer#Dedicated.2FHeadless_server)
* __user__ : The user who will execute the factorio server (choose an existing linux user, `root` is a bad idea but will works)

By default the script will be looking for the file in: `/etc/faas/config.ini`. You need to create this folder manually:
```bash
mkdir /etc/faas
cp ./config.ini /etc/faas/config.ini
```

> NB: When you are using a relative path, the working directory will always be the directory that contains `faas.py`. Please consider using absolute path

#### 2. Download/Update the server

Once the destination is defined in the configuration file, execute the update command.
It will perform an update to the latest version (even if the directory is empty)

```bash
$ python3 ./faas.py -u
```

##### 2.1
If it's not done yet, [create your server save file](https://wiki.factorio.com/Multiplayer#Dedicated.2FHeadless_server)
and specify its path in `config.ini`

> Be sure that the user who is configured to launch the server has all permissions needed.
{'fraction_non_alphanumeric': 0.0832913940613991, 'fraction_numerical': 0.0055359838953195776, 'mean_word_length': 4.257936507936508, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1001050', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1098, 'n_words': 559}