mirror of https://github.com/bmaltais/kohya_ss
29 lines
1.2 KiB
Bash
Executable File
29 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# If it is run with the sudo command, get the complete LD_LIBRARY_PATH environment variable of the system and assign it to the current environment,
|
|
# because it will be used later.
|
|
if [ -n "$SUDO_USER" ] || [ -n "$SUDO_COMMAND" ] ; then
|
|
echo "The sudo command resets the non-essential environment variables, we keep the LD_LIBRARY_PATH variable."
|
|
export LD_LIBRARY_PATH=$(sudo -i printenv LD_LIBRARY_PATH)
|
|
fi
|
|
|
|
# This gets the directory the script is run from so pathing can work relative to the script where needed.
|
|
SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd)
|
|
|
|
# Step into GUI local directory
|
|
cd "$SCRIPT_DIR"
|
|
|
|
# Activate the virtual environment
|
|
source "$SCRIPT_DIR/venv/bin/activate"
|
|
|
|
# If the requirements are validated, run the kohya_gui.py script with the command-line arguments
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
if python "$SCRIPT_DIR"/setup/validate_requirements.py -r "$SCRIPT_DIR"/requirements_macos.txt; then
|
|
python "$SCRIPT_DIR/kohya_gui.py" "$@"
|
|
fi
|
|
else
|
|
if python "$SCRIPT_DIR"/setup/validate_requirements.py -r "$SCRIPT_DIR"/requirements_linux.txt; then
|
|
python "$SCRIPT_DIR/kohya_gui.py" "$@"
|
|
fi
|
|
fi
|