Skip to content

Commit

Permalink
Add prompt to client data extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
mserajnik committed Jan 24, 2025
1 parent 5ae82b1 commit 8ee5800
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ previously, you can place it directly into
[`./storage/mangosd/extracted-data`](storage/mangosd/extracted-data) and skip
the next steps.

To generate the data, first copy the contents of your client directory into
To extract the data, first copy the contents of your client directory into
[`./storage/mangosd/client-data`](storage/mangosd/client-data). Next, simply
run the following command:

Expand All @@ -181,15 +181,30 @@ There are two things to look out for here:
the data from; see the table further above in the
[Docker Compose configuration section](#adjusting-the-docker-compose-configuration)

Generating the data can take many hours (depending on your hardware). Some
notices/errors during the extraction process are normal and nothing to worry
about.
Extracting the data can take many hours (depending on your hardware). Some
notices/errors during the process are normal and usually nothing to worry
about (as long as the execution continues afterwards).

Once the extraction is finished you can find the data in
[`./storage/mangosd/extracted-data`](storage/mangosd/extracted-data). Note that
you may want to re-run the process in the future if VMaNGOS makes changes (to
benefit from potentially improved mob pathing etc.).

If you re-run the extraction, it will automatically detect previously extracted
data and ask you if you want to continue and overwrite the old data. For
automation purposes you can also skip this prompt (and force the re-extraction)
by adding the `--force` flag to the `extract-client-data` command, like this:

```sh
docker run \
-v ./storage/mangosd/client-data:/opt/vmangos/storage/client-data \
-v ./storage/mangosd/extracted-data:/opt/vmangos/storage/extracted-data \
--rm \
--user 1000:1000 \
ghcr.io/mserajnik/vmangos-server:5875 \
extract-client-data --force
```

### Providing the Warden modules (optional)

Optionally, if want to use Warden you have to provide the
Expand Down Expand Up @@ -266,7 +281,7 @@ To update, pull the latest images:
docker compose pull
```

Afterwards, recreate the containers:
Afterwards, re-create the containers:

```sh
docker compose up -d
Expand Down
39 changes: 33 additions & 6 deletions docker/server/docker-cmd-extract-client-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,48 @@ extracted_data_dir="/opt/vmangos/storage/extracted-data"
extractors_dir="/opt/vmangos/bin/Extractors"
client_version_dir="$extracted_data_dir/$VMANGOS_CLIENT_VERSION"

if [ ! -d "$client_data_dir" ]; then
echo "[vmangos-deploy]: Client data bind mount is missing, aborting extraction" >&2
# The `--force` flag can be used to skip the confirmation prompt when
# previously extracted data is found. This is useful for automation where the
# user is not able to interact with the prompt.
force=false

# Loop through all passed arguments, shifting them out each time
while [ "$#" -gt 0 ]; do
case "$1" in
-f|--force)
# If user passes -f or --force, set 'force' to true
force=true
shift
;;
*)
# For any other options, just move to the next argument
shift
;;
esac
done

if [ ! -d "$client_data_dir" ] || [ ! -d "$client_data_dir/Data" ]; then
echo "[vmangos-deploy]: Client data not found in $client_data_dir, aborting extraction" >&2
exit 1
fi

if [ ! -d "$extracted_data_dir" ]; then
echo "[vmangos-deploy]: Extracted data bind mount is missing, aborting extraction" >&2
echo "[vmangos-deploy]: Extracted data target directory $extracted_data_dir doesn't exist, aborting extraction" >&2
exit 1
fi

cd "$client_data_dir"

if [ ! -d "./Data" ]; then
echo "[vmangos-deploy]: Client data is missing, aborting extraction" >&2
exit 1
if [ "$force" = false ]; then
if [ -d "$extracted_data_dir/maps" ] || [ -d "$extracted_data_dir/mmaps" ] || [ -d "$extracted_data_dir/vmaps" ] || [ -d "$client_version_dir" ]; then
echo "[vmangos-deploy]: Previously extracted data has been found in $extracted_data_dir, continue with the extraction (which will overwrite the old data)? [Y/n]"
read -r choice
choice=${choice:-y}
if [ "$choice" = "n" ] || [ "$choice" = "N" ]; then
echo "[vmangos-deploy]: Aborting extraction"
exit 1
fi
fi
fi

# Remove any potentially previously extracted data from the client directory
Expand Down

0 comments on commit 8ee5800

Please sign in to comment.