From 20c525bd59c282855310b9f34b506e4ee0fc6cd8 Mon Sep 17 00:00:00 2001 From: JSTayco Date: Wed, 29 Mar 2023 10:53:15 -0700 Subject: [PATCH] Enable more arbitrary install locations Default to master branch (user can override with an argument), update the repo if we find a git folder but no venv folder (indicating blank env), rename BASE_DIR to PARENT_DIR to be more obvious, enable PARENT_DIR to account for an arbitrary amount of folders. --- setup.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index 9af9320..7965fbd 100755 --- a/setup.sh +++ b/setup.sh @@ -24,7 +24,7 @@ EOF # Variables defined before the getopts loop, so we have sane default values. DIR="/workspace/kohya_ss" -BRANCH="dev" +BRANCH="master" GIT_REPO="https://github.com/bmaltais/kohya_ss.git" RUNPOD=false @@ -48,7 +48,7 @@ done shift $((OPTIND - 1)) # This must be set after the getopts loop to account for $DIR changes. -BASE_DIR="$(echo "$DIR" | cut -d "/" -f2)" +PARENT_DIR="$(dirname "${DIR}")" VENV_DIR="$DIR/venv" if [[ "$OSTYPE" == "linux-gnu"* ]]; then @@ -127,10 +127,18 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then sed -i "s/interface.launch(\*\*launch_kwargs)/interface.launch(\*\*launch_kwargs,share=True)/g" ./kohya_gui.py else echo "Clean installation on a runpod detected." - cd "$BASE_DIR" || exit 1 - git clone "$GIT_REPO" - cd "$DIR" || exit 1 - git checkout "$BRANCH" + cd "$PARENT_DIR" || exit 1 + if [ ! -d "$DIR/.git" ]; then + echo "Cloning $GIT_REPO." + git clone "$GIT_REPO" + cd "$DIR" || exit 1 + git checkout "$BRANCH" + else + cd "$DIR" || exit 1 + echo "git repo detected. Attempting tp update repo instead." + echo "Updating: $GIT_REPO" + git pull "$GIT_REPO" + fi fi fi