summarylogtreecommitdiffstats
path: root/setup.sh
blob: b769a144c51c23f93ea06967aacfdfe92d6984cf (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
#!/bin/bash

root_dir="/opt/tModLoader"
user_dir="$HOME/.local/share/tModLoader"

root_version_file="$root_dir/ver.txt"
user_version_file="$user_dir/ver.txt"

install_needed=false

if [[ ! -e "$user_dir" ]]
then
  mkdir -p "$user_dir"
  install_needed=true
elif [[ "$(cat "$root_version_file")" != "$(cat "$user_version_file")" ]]
then
  rm -f "$user_version_file"
  install_needed=true
fi

if [[ $install_needed == true ]]
then
  pack_file="$root_dir/tml.zip"

  echo -n "Extracting tModLoader..."
  unzip -X -o "$pack_file" -d "$user_dir/"
  cp "$root_version_file" "$user_version_file"
  echo "Done"

  echo -n "Enabling scripts..."
  chmod +x "$user_dir/start-"*".sh"
  echo "Done"
fi