blob: c920d0fd57b202c2cc950ad34ab5710c29f6f1e9 (
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
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/sh
## Streets of Rage Remake 5
## Linux wrapper for multi-user support.
## Where to store the session. This is an environment variable.
SORR_SESSION="${SORR_SESSION:-$HOME/.sorr}"
sorr_folder="$(dirname "$(realpath "$0")")"
## Make folder if non-existent.
make_folder() {
[ ! -d "$SORR_SESSION/$1" ] && mkdir -p "$SORR_SESSION/$1"
}
## Make symlink if non-existent or dangling.
make_symlink() {
if [ ! -h "$SORR_SESSION/$1" ] || [ ! -e "$SORR_SESSION/$1" ]; then
ln -sf "$sorr_folder/$1" "$SORR_SESSION/$1"
fi
}
make_folder
[ ! -w "$SORR_SESSION" ] && echo >&2 "SORR_SESSION=$SORR_SESSION is not writable." && exit 1
for link in bgdc bgdi data palettes SorMaker.dat SorR.dat; do
make_symlink "$link"
done
make_folder mod
make_folder mod/games
for link in music namesong.txt system.txt; do
make_symlink mod/"$link"
done
# Rename mod files to lowercase. This is necessary for mods to work.
#
# The -name check is not mandatory, but greatly improves the average
# performance.
#
# To remain POSIX we need this tortuous find call.
# The mini-script is followed by _ and {}.
# When 'sh -c' executes a command, the next argument after the command is used
# as $0 (the script's "name" in the process listing), and subsequent arguments
# become the positional parameters ($1, $2, etc.).
renamelower=$(cat <<'EOF'
echo >&2 "Renaming mod files/folders to lowercase."
for f; do
filename=${f##*/}
case "$f" in
*/*) dirname="${f%/*}" ;;
*) dirname="." ;;
esac
nf="$(echo "$filename" | awk '{print tolower($0)}')"
newname="${dirname}/${nf}"
[ -e "$newname" ] && echo >&2 "error: '$newname' exists" && continue
mv -nv "$f" "$newname"
done
EOF
)
find "$SORR_SESSION/mod/games" -depth -name '*[[:upper:]]*' -exec sh -c "$renamelower" _ {} +
cd "$SORR_SESSION"
LD_LIBRARY_PATH=./data ./bgdi ./SorR.dat
|