summarylogtreecommitdiffstats
path: root/launch-thiswarofmine.sh
blob: 9f9e2077acbb0cbcc435e896227133eceeac19e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

# This is a wrapper that works around the application's single-user design for multi-user systems.

set -e
set -u

game_dir="/opt/thiswarofmine-gog"
: ${XDG_DATA_HOME:=$HOME/.local/share}
user_dir="$XDG_DATA_HOME/thiswarofmine-gog"

make_user_dir() {
    echo "Creating a user directory for the game. This only needs to be done once, future runs will skip this step."

    mkdir -p "$user_dir/"

    # Read-only
    find "$game_dir/" -maxdepth 1 -print0 | xargs -0 ln -s -t "$user_dir/"

    echo "User directory has been created."
}

launch_game() {
    cd "$user_dir"
    ./KosovoLinux
}

if [ ! -d "$user_dir/Mods" ]
then
    echo "Updating user directory to v2 file layout"
    mv "$user_dir" "${user_dir}_v1"
fi

if [ ! -e "$user_dir/KosovoLinux" ]
then
    make_user_dir
fi

launch_game