-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod-installer.sh
66 lines (54 loc) · 1.5 KB
/
mod-installer.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
if [[ -z $INPUT_OUTPUT_PATH ]]
then
echo 'Input parameter "output path" is required to specify path of the game instance'
exit 2
fi
if [[ -z $INPUT_MODS ]]
then
echo 'Input parameter "mods" is required to specify identifiers of mods to install'
exit 2
fi
# Set up preloaded repo metadata
if [[ -d /usr/local/share/CKAN -a ! -d ~/.local/share/CKAN ]]
then
mkdir -p ~/.local/share
cp -a /usr/local/share/CKAN ~/.local/share
fi
ckan cache set $HOME/.local/share/CKAN/downloads
GAME=${INPUT_GAME:-KSP}
MAIN_GAME_VERSION=${INPUT_GAME_VERSIONS%% *}
OTHER_GAME_VERSIONS=${INPUT_GAME_VERSIONS#* }
if [[ -z $MAIN_GAME_VERSION ]]
then
case $GAME in
KSP)
MAIN_GAME_VERSION=$(jq -rM 'last(.builds[])' /ksp-builds.json)
;;
KSP2)
MAIN_GAME_VERSION=$(jq -rM last /ksp2-builds.json)
;;
*)
echo 'Input parameter "game" is invalid'
exit 2
;;
esac
fi
COMPAT_COMMAND=''
if [[ -n $OTHER_GAME_VERSIONS ]]
then
COMPAT_COMMAND="compat add $OTHER_GAME_VERSIONS"
fi
FILTER_COMMAND=''
if [[ -n $INPUT_INSTALL_FILTERS ]]
then
FILTER_COMMAND="filter add --global $INPUT_INSTALL_FILTERS"
fi
# Need quoting in case the path has spaces
ckan instance fake fake_inst "$INPUT_OUTPUT_PATH" $MAIN_GAME_VERSION --game $GAME --set-default
# Group the remaining commands into one to reduce startup/teardown overhead
ckan prompt --headless <<EOF
$COMPAT_COMMAND
$FILTER_COMMAND
install --no-recommends $INPUT_MODS
EOF