Repository navigation
Expand file tree
/
Copy pathstart-server.sh
More file actions
53 lines (46 loc) · 1.35 KB
/
Copy pathstart-server.sh
File metadata and controls
53 lines (46 loc) · 1.35 KB
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
#!/bin/sh
set -eu
SD_SERVER_PATH="${SD_SERVER_PATH:-}"
MODEL_DIR="./models"
COMMANDLINE_ARGS=""
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -f "$script_dir/start-server.local.sh" ]; then
. "$script_dir/start-server.local.sh"
fi
if [ "${1:-}" != "--version" ]; then
# Split configured arguments on whitespace without expanding wildcards.
set -f
set -- --model-dir "$MODEL_DIR" $COMMANDLINE_ARGS "$@"
fi
run_server() {
printf 'Running:'
for arg do
printf " '%s'" "$(printf '%s' "$arg" | sed "s/'/'\\\\''/g")"
done
printf '\n'
exec "$@"
}
if [ -n "$SD_SERVER_PATH" ]; then
case "$SD_SERVER_PATH" in
*/*) ;;
*) SD_SERVER_PATH="./$SD_SERVER_PATH" ;;
esac
if [ ! -f "$SD_SERVER_PATH" ] || [ ! -x "$SD_SERVER_PATH" ]; then
printf 'SD_SERVER_PATH is not an executable file: %s\n' "$SD_SERVER_PATH" >&2
exit 1
fi
run_server "$SD_SERVER_PATH" "$@"
fi
for server in \
"$script_dir/sd-server" \
"$script_dir/bin/Release/sd-server" \
"$script_dir/bin/sd-server" \
"$script_dir/build/bin/Release/sd-server" \
"$script_dir/build/bin/sd-server"
do
if [ -f "$server" ] && [ -x "$server" ]; then
run_server "$server" "$@"
fi
done
printf '%s\n' 'sd-server was not found. Build it first or set SD_SERVER_PATH to its executable path.' >&2
exit 1