|
| 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}" |
0 commit comments