summarylogtreecommitdiffstats
path: root/factorio-headless.install
blob: 7cdadb871c178a6f39519c6bf1083ab204c4edec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
post_install() {
    systemd-sysusers factorio.conf
    [[ -d /var/lib/factorio ]] || install -dm 770 -o factorio -g games /var/lib/factorio

    source /etc/conf.d/factorio

    # create empty game
    if [[ ! -f "$SAVE_FILE" ]]; then
        echo "Generating initial save file: $SAVE_FILE"
        su - factorio -s /bin/sh -c "factorio --create '$SAVE_FILE' 2>&1 >/dev/null"
    fi
}

post_upgrade() {
    (( $(vercmp $2 '0.12.26-4') < 0 )) && chown -R root:root /usr/share/factorio || true
    (( $(vercmp $2 '0.12.26-4') < 0 )) && post_install "$1" || true
    (( $(vercmp $2 '0.14.12-1') < 0 )) && {
        echo "AUTOSAVE_INTERVAL and AUTOSAVE_SLOTS must now be declared in /etc/factorio/server-settings.json"
        echo "Please update /etc/factorio/server-settings.json and /etc/conf.d/factorio now."
        echo
        echo "The systemd service file has been updated, don't forget to run 'systemctl daemon-reload' before restarting factorio."
    } || true
}