Skip to content

Commit 385894f

Browse files
authored
Merge pull request #2427 from LindholmLabs/feat/factorio
New script: Factorio headless server
2 parents ca20082 + 5572bbd commit 385894f

3 files changed

Lines changed: 154 additions & 0 deletions

File tree

‎ct/factorio.sh‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
_CS_DEFAULT_URL="https://raw.githubusercontent.com/community-scripts/DevScripts/main"
3+
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
4+
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")
5+
# Copyright (c) 2021-2026 community-scripts ORG
6+
# Author: William Lindholm (LindholmLabs)
7+
# License: MIT | https://github.com/community-scripts/DevScripts/raw/main/LICENSE
8+
# Source: https://www.factorio.com/
9+
10+
APP="Factorio"
11+
var_tags="${var_tags:-gaming}"
12+
var_cpu="${var_cpu:-1}"
13+
var_ram="${var_ram:-2048}"
14+
var_disk="${var_disk:-8}"
15+
var_os="${var_os:-debian}"
16+
var_version="${var_version:-13}"
17+
var_unprivileged="${var_unprivileged:-1}"
18+
var_arm64="${var_arm64:-yes}"
19+
20+
header_info "$APP"
21+
variables
22+
color
23+
catch_errors
24+
25+
function update_script() {
26+
header_info
27+
check_container_storage
28+
check_container_resources
29+
30+
if [[ ! -x /opt/factorio/bin/$(arch_resolve "x64" "arm64")/factorio ]]; then
31+
msg_error "No Factorio Installation Found!"
32+
exit 1
33+
fi
34+
35+
msg_info "Stopping Factorio"
36+
systemctl stop factorio
37+
msg_ok "Stopped Factorio"
38+
39+
create_backup /opt/factorio/config /opt/factorio/config-path.cfg \
40+
/opt/factorio/server-settings.json /opt/factorio/saves /opt/factorio/mods \
41+
/opt/factorio/player-data.json /opt/factorio/server-adminlist.json \
42+
/opt/factorio/server-banlist.json /opt/factorio/server-whitelist.json
43+
44+
fetch_and_deploy_from_url "https://factorio.com/get-download/stable/headless/$(arch_resolve "linux64" "linux-arm64")" "/opt/factorio"
45+
46+
restore_backup
47+
48+
msg_info "Starting Factorio"
49+
systemctl start factorio
50+
msg_ok "Started Factorio"
51+
msg_ok "Updated Factorio successfully!"
52+
53+
exit
54+
}
55+
56+
start
57+
build_container
58+
description
59+
60+
msg_ok "Completed Factorio setup successfully!\n"
61+
echo -e "${INFO}${YW}Connect in Factorio using the following address (UDP):${CL}"
62+
echo -e "${GATEWAY}${BGN}${IP}:34197${CL}"

‎install/factorio-install.sh‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2026 community-scripts ORG
4+
# Author: William Lindholm (LindholmLabs)
5+
# License: MIT | https://github.com/community-scripts/DevScripts/raw/main/LICENSE
6+
# Source: https://www.factorio.com/
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
fetch_and_deploy_from_url "https://factorio.com/get-download/stable/headless/$(arch_resolve "linux64" "linux-arm64")" "/opt/factorio"
17+
18+
msg_info "Configuring Factorio"
19+
sed 's/"public":[[:space:]]*true/"public": false/' /opt/factorio/data/server-settings.example.json >/opt/factorio/server-settings.json
20+
cat <<EOF >/opt/factorio/server-adminlist.json
21+
[]
22+
EOF
23+
msg_ok "Configured Factorio"
24+
25+
msg_info "Creating Factorio Save"
26+
mkdir -p /opt/factorio/saves
27+
$STD /opt/factorio/bin/$(arch_resolve "x64" "arm64")/factorio --create /opt/factorio/saves/save.zip
28+
msg_ok "Created Factorio Save"
29+
30+
msg_info "Creating Factorio Service"
31+
cat <<EOF >/etc/systemd/system/factorio.service
32+
[Unit]
33+
Description=Factorio Headless Server
34+
Wants=network-online.target
35+
After=network-online.target
36+
37+
[Service]
38+
Type=simple
39+
User=root
40+
WorkingDirectory=/opt/factorio
41+
ExecStart=/opt/factorio/bin/$(arch_resolve "x64" "arm64")/factorio --start-server-load-latest --server-settings /opt/factorio/server-settings.json --server-adminlist /opt/factorio/server-adminlist.json
42+
KillSignal=SIGINT
43+
TimeoutStopSec=120
44+
Restart=on-failure
45+
RestartSec=5
46+
47+
[Install]
48+
WantedBy=multi-user.target
49+
EOF
50+
systemctl enable -q --now factorio
51+
52+
msg_ok "Created Factorio Service"
53+
54+
motd_ssh
55+
customize
56+
cleanup_lxc

‎json/factorio.json‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "Factorio",
3+
"slug": "factorio",
4+
"categories": [24],
5+
"date_created": "2026-10-13",
6+
"type": "ct",
7+
"updateable": true,
8+
"privileged": false,
9+
"interface_port": null,
10+
"documentation": "https://wiki.factorio.com/Multiplayer",
11+
"website": "https://factorio.com/",
12+
"repository": "",
13+
"architectures": ["amd64", "arm64"],
14+
"platforms": ["pve"],
15+
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/factorio.webp",
16+
"description": "Factorio headless multiplayer server using the current stable Linux release.",
17+
"install_methods": [
18+
{
19+
"type": "default",
20+
"script": "ct/factorio.sh",
21+
"config_path": "/opt/factorio/server-settings.json",
22+
"resources": {
23+
"cpu": 1,
24+
"ram": 2048,
25+
"hdd": 8,
26+
"os": "Debian",
27+
"version": "13"
28+
}
29+
}
30+
],
31+
"default_credentials": {"username": null, "password": null},
32+
"notes": [
33+
{"text": "Connect using the Factorio client to <container IP>:34197. Clients need the same Factorio version and mods as the server.", "type": "info"},
34+
{"text": "Saves are stored in /opt/factorio/saves. The service loads the most recent save on restart.", "type": "info"}
35+
]
36+
}

0 commit comments

Comments
 (0)