Skip to content

Commit 3dd207c

Browse files
committed
Use bash's select menu to choose the KSP directory if multiple are found
1 parent 234587f commit 3dd207c

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

entry.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,43 @@ echo ">>> Using CKAN version $(ckan version)"
1111

1212
echo ">>> Setting up..."
1313

14-
buildID=$(find / \
14+
readarray -d '' buildIDs < <(find / \
1515
-not \( -path /proc -prune \) \
1616
-not \( -path /usr -prune \) \
1717
-not \( -path /var -prune \) \
1818
-not \( -path /etc -prune \) \
1919
-not \( -path /root -prune \) \
20-
-name buildID.txt | head -n 1)
20+
-not \( -path /run -prune \) \
21+
-not \( -path /tmp -prune \) \
22+
-not \( -path /sys -prune \) \
23+
-not \( -path /dev -prune \) \
24+
-name buildID.txt -print0)
2125

22-
if [ -z "$buildID" ]; then
26+
for i in "${!buildIDs[@]}"; do
27+
buildIDs[$i]=$(dirname ${buildIDs[$i]})
28+
done
29+
30+
PS3="#? "
31+
kerbal="";
32+
if ((${#buildIDs[@]}==1)); then
33+
kerbal=${buildIDs[0]}
34+
else
35+
echo "Choose which KSP directory to use as the default:"
36+
select file in "${buildIDs[@]}"; do
37+
kerbal=$file
38+
break
39+
done
40+
fi
41+
42+
if [ -z "$kerbal" ]; then
2343
echo "No buildID.txt found, did you mount your KSP directory?"
2444
echo "Use '--mount type=bind,source=<KSP_PATH>,target=/kerbal' in"
2545
echo "your 'docker run' command, and replace <KSP_PATH>."
2646
echo ""
2747
echo "'ckan' is still available, but you will have no KSP to work with."
2848
exec_user=root
2949
else
30-
kerbal=$(dirname "$buildID")
31-
32-
echo "Found $buildID, using $kerbal as KSP directory"
50+
echo "Using $kerbal as default KSP directory"
3351

3452
gid=$(stat -c '%g' "$kerbal/GameData")
3553
uid=$(stat -c '%u' "$kerbal/GameData")

0 commit comments

Comments
 (0)