From 20a21f868451b6792ec4122d90256dce151d5d41 Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 25 Mar 2024 23:01:50 +0100 Subject: [PATCH 1/4] new functions + filename change (for rights reset/env) --- 01.sh | 14 +-- 02.forge.sh | 36 ++----- 02.sh | 34 ++----- 03.sh | 11 +-- 04.sh | 27 +----- 05.sh | 52 ++++------ 06.sh | 27 +----- 07.sh | 27 +----- 08.sh.old | 95 ------------------- 20.sh.old | 43 --------- 50.sh | 18 +--- 51.sh | 8 +- 70.sh | 27 +----- custom-sample.sh | 2 +- .../etc/s6-overlay/s6-rc.d/init-chown/run | 4 +- entry.sh | 4 +- functions.sh | 52 ++++++++++ sl_folder.sh | 25 ----- 18 files changed, 110 insertions(+), 396 deletions(-) delete mode 100644 08.sh.old delete mode 100644 20.sh.old create mode 100644 functions.sh delete mode 100644 sl_folder.sh diff --git a/01.sh b/01.sh index 94643b3..f1a3b2c 100755 --- a/01.sh +++ b/01.sh @@ -1,19 +1,12 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD01_DIR=${BASE_DIR}/01-easy-diffusion #clean conda env -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - rm -rf ${SD01_DIR}/conda-env - rm -rf ${SD01_DIR}/installer_files - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" -fi +clean_env ${SD01_DIR}/conda-env +clean_env ${SD01_DIR}/installer_files #Create Conda Env if [ ! -d ${SD01_DIR}/conda-env ]; then @@ -64,3 +57,4 @@ fi #run easy-diffusion cd $SD01_DIR bash start.sh +wait 99999 \ No newline at end of file diff --git a/02.forge.sh b/02.forge.sh index e0b4de7..377a9b3 100644 --- a/02.forge.sh +++ b/02.forge.sh @@ -1,5 +1,6 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh + export PATH="/home/abc/miniconda3/bin:$PATH" export SD02_DIR=${BASE_DIR}/02-sd-webui @@ -10,42 +11,20 @@ export venv_dir="-" # Install or update Stable-Diffusion-WebUI mkdir -p ${SD02_DIR} -# Create Conda virtual env -if [ ! -d ${SD02_DIR}/conda-env ]; then - conda create -p ${SD02_DIR}/conda-env -y -fi - if [ ! -d ${SD02_DIR}/forge ]; then git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git ${SD02_DIR}/forge fi cd ${SD02_DIR}/forge -# check if remote is ahead of local -# https://stackoverflow.com/a/25109122/1469797 -if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ -sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - export active_clean=1 - git pull -X ours -fi +check_remote #clean conda env -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - conda deactivate - rm -rf ${SD02_DIR}/conda-env +clean_env ${SD02_DIR}/conda-env + +# Create Conda virtual env +if [ ! -d ${SD02_DIR}/conda-env ]; then conda create -p ${SD02_DIR}/conda-env -y - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" fi #activate conda env + install base tools @@ -92,3 +71,4 @@ while IFS= read -r param; do fi done < "${SD02_DIR}/parameters.forge.txt" eval $CMD +wait 99999 \ No newline at end of file diff --git a/02.sh b/02.sh index ed35e57..a5f089c 100755 --- a/02.sh +++ b/02.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD02_DIR=${BASE_DIR}/02-sd-webui @@ -10,11 +10,6 @@ export venv_dir="-" # Install or update Stable-Diffusion-WebUI mkdir -p ${SD02_DIR} -# create conda env if needed -if [ ! -d ${SD02_DIR}/conda-env ]; then - conda create -p ${SD02_DIR}/conda-env -y -fi - # clone repository if [ ! -d ${SD02_DIR}/webui ]; then git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git ${SD02_DIR}/webui @@ -23,30 +18,14 @@ fi cd ${SD02_DIR}/webui # check if remote is ahead of local -# https://stackoverflow.com/a/25109122/1469797 -if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ -sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - export active_clean=1 - git pull -X ours -fi +check_remote #clean conda env -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - conda deactivate - rm -rf ${SD02_DIR}/conda-env +clean_env ${SD02_DIR}/conda-env + +# create conda env if needed +if [ ! -d ${SD02_DIR}/conda-env ]; then conda create -p ${SD02_DIR}/conda-env -y - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" fi # activate conda env and install base tools @@ -95,3 +74,4 @@ while IFS= read -r param; do fi done < "${SD02_DIR}/parameters.txt" eval $CMD +wait 99999 \ No newline at end of file diff --git a/03.sh b/03.sh index e8262bd..3583b9a 100755 --- a/03.sh +++ b/03.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export use_venv=0 @@ -14,14 +14,7 @@ if [ ! -f "$SD03_DIR/parameters.txt" ]; then fi #clean conda env -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - rm -rf ${SD03_DIR}/env - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" -fi +clean_env ${SD03_DIR}/env # create conda env if absent if [ ! -d ${SD03_DIR}/env ]; then diff --git a/04.sh b/04.sh index ca454a8..db6215c 100755 --- a/04.sh +++ b/04.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD04_DIR=${BASE_DIR}/04-SD-Next @@ -17,30 +17,11 @@ fi cd ${SD04_DIR}/webui # check if remote is ahead of local -# https://stackoverflow.com/a/25109122/1469797 -if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ - sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - export active_clean=1 - git pull -X ours -fi +check_remote #clean virtual env -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - rm -rf ${SD04_DIR}/env - rm -rf ${SD04_DIR}/webui/venv - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" -fi +clean_env ${SD04_DIR}/env +clean_env ${SD04_DIR}/webui/venv #create conda env if needed if [ ! -d ${SD04_DIR}/env ]; then diff --git a/05.sh b/05.sh index 5a9ef59..cedcfe6 100755 --- a/05.sh +++ b/05.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD05_DIR=${BASE_DIR}/05-comfy-ui @@ -27,42 +27,10 @@ cd ${SD05_DIR}/ComfyUI/custom_nodes/ComfyUI-Manager git pull -X ours # check if remote is ahead of local -# https://stackoverflow.com/a/25109122/1469797 -if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ -sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - export active_clean=1 -# git reset --hard HEAD - git pull -X ours -fi - -# Merge Models, vae, lora, hypernetworks, and outputs -sl_folder ${SD05_DIR}/ComfyUI/models checkpoints ${BASE_DIR}/models stable-diffusion -sl_folder ${SD05_DIR}/ComfyUI/models hypernetworks ${BASE_DIR}/models hypernetwork -sl_folder ${SD05_DIR}/ComfyUI/models loras ${BASE_DIR}/models lora -sl_folder ${SD05_DIR}/ComfyUI/models vae ${BASE_DIR}/models vae -sl_folder ${SD05_DIR}/ComfyUI/models vae_approx ${BASE_DIR}/models vae_approx -sl_folder ${SD05_DIR}/ComfyUI/models embeddings ${BASE_DIR}/models embeddings -sl_folder ${SD05_DIR}/ComfyUI/models upscale_models ${BASE_DIR}/models upscale -sl_folder ${SD05_DIR}/ComfyUI/models clip_vision ${BASE_DIR}/models clip_vision -sl_folder ${SD05_DIR}/ComfyUI/models clip ${BASE_DIR}/models clip -sl_folder ${SD05_DIR}/ComfyUI/models controlnet ${BASE_DIR}/models controlnet +check_remote #clean conda env -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - rm -rf ${SD01_DIR}/env - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" -fi +clean_env ${SD05_DIR}/env #create conda env if needed if [ ! -d ${SD05_DIR}/env ]; then @@ -82,6 +50,20 @@ if [ -d ${SD05_DIR}/venv ]; then rm -rf ${SD05_DIR}/venv fi +# Merge Models, vae, lora, hypernetworks, and outputs +sl_folder ${SD05_DIR}/ComfyUI/models checkpoints ${BASE_DIR}/models stable-diffusion +sl_folder ${SD05_DIR}/ComfyUI/models hypernetworks ${BASE_DIR}/models hypernetwork +sl_folder ${SD05_DIR}/ComfyUI/models loras ${BASE_DIR}/models lora +sl_folder ${SD05_DIR}/ComfyUI/models vae ${BASE_DIR}/models vae +sl_folder ${SD05_DIR}/ComfyUI/models vae_approx ${BASE_DIR}/models vae_approx +sl_folder ${SD05_DIR}/ComfyUI/models embeddings ${BASE_DIR}/models embeddings +sl_folder ${SD05_DIR}/ComfyUI/models upscale_models ${BASE_DIR}/models upscale +sl_folder ${SD05_DIR}/ComfyUI/models clip_vision ${BASE_DIR}/models clip_vision +sl_folder ${SD05_DIR}/ComfyUI/models clip ${BASE_DIR}/models clip +sl_folder ${SD05_DIR}/ComfyUI/models controlnet ${BASE_DIR}/models controlnet + + + #install requirements cd ${SD05_DIR}/ComfyUI pip install -r requirements.txt diff --git a/06.sh b/06.sh index f8cce08..6cadbc9 100755 --- a/06.sh +++ b/06.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD06_DIR=${BASE_DIR}/06-Fooocus @@ -23,31 +23,10 @@ if [ ! -d ${SD06_DIR}/Fooocus ]; then fi # check if remote is ahead of local -# https://stackoverflow.com/a/25109122/1469797 -cd ${SD06_DIR}/Fooocus -if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ -sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - export active_clean=1 -# git reset --hard HEAD - git pull -X ours -fi +check_remote #clean conda env if needed -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - rm -rf ${SD06_DIR}/env - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" -fi +clean_env ${SD06_DIR}/env #create env if missing if [ ! -d ${SD06_DIR}/env ]; then diff --git a/07.sh b/07.sh index 6a978fd..1b2aba8 100755 --- a/07.sh +++ b/07.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD07_DIR=${BASE_DIR}/07-StableSwarm @@ -23,31 +23,10 @@ if [ ! -d ${SD07_DIR}/StableSwarmUI ]; then fi # check if remote is ahead of local -# https://stackoverflow.com/a/25109122/1469797 -cd ${SD07_DIR}/StableSwarmUI -if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ -sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - export active_clean=1 -# git reset --hard HEAD - git pull -X ours -fi +check_remote #clean conda env if needed -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - rm -rf ${SD07_DIR}/env - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" -fi +clean_env ${SD07_DIR}/env #create env if missing if [ ! -d ${SD07_DIR}/env ]; then diff --git a/08.sh.old b/08.sh.old deleted file mode 100644 index e262a26..0000000 --- a/08.sh.old +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash -source /sl_folder.sh - -export PATH="/home/abc/miniconda3/bin:$PATH" -export SD08_DIR=${BASE_DIR}/08-voltaML - -mkdir -p ${SD08_DIR} -mkdir -p /config/outputs/08-voltaML - -if [ ! -f "$SD08_DIR/parameters.txt" ]; then - cp -v "${SD_INSTALL_DIR}/parameters/08.txt" "$SD08_DIR/parameters.txt" -fi - -if [ ! -d "${SD08_DIR}/voltaML-fast-stable-diffusion" ]; then - cd "${SD08_DIR}" && git clone https://github.com/VoltaML/voltaML-fast-stable-diffusion.git -fi - -# check if remote is ahead of local -# https://stackoverflow.com/a/25109122/1469797 -cd ${SD08_DIR}/voltaML-fast-stable-diffusion -if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ -sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - export active_clean=1 -# git reset --hard HEAD - git pull -X ours -fi - -#clean conda env if needed -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - rm -rf ${SD08_DIR}/env - rm -rf ${SD08_DIR}/voltaML-fast-stable-diffusion/venv - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" -fi - -#create conda env if missing -if [ ! -d ${SD08_DIR}/env ]; then - conda create -p ${SD08_DIR}/env -y -fi - -#activate conda env and install packages -source activate ${SD08_DIR}/env -conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.10 pip=22.3.1 gcc gxx --solver=libmamba -y -conda install pytorch torchvision torchaudio -c pytorch --solver=libmamba -y - -#create python venv if missing -if [ ! -d ${SD08_DIR}/voltaML-fast-stable-diffusion/venv ]; then - cd ${SD08_DIR}/voltaML-fast-stable-diffusion - python -m venv venv -fi - -cd ${SD08_DIR}/voltaML-fast-stable-diffusion -source venv/bin/activate - -for fichier in ${SD08_DIR}/voltaML-fast-stable-diffusion/requirements/*.txt; do - echo "installation of requirements" - pip install -r $fichier -done - -pip install --upgrade pip -pip install coloredlogs flatbuffers numpy packaging protobuf==3.20.3 sympy -pip install packaging -pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ -pip install insightface -pip install basicsr -pip install xformers --index-url https://download.pytorch.org/whl/cu121 - -#move models to common folders and create symlinks -sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data models ${BASE_DIR}/models stable-diffusion -sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data lora ${BASE_DIR}/models lora -sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data vae ${BASE_DIR}/models vae -sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data textual-inversion ${BASE_DIR}/models embeddings -sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data upscaler ${BASE_DIR}/models upscale -sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data outputs /config/outputs 08-voltaML - -cd ${SD08_DIR}/voltaML-fast-stable-diffusion -# launch Volta ML -CMD="python3 main.py" -while IFS= read -r param; do - if [[ $param != \#* ]]; then - CMD+=" ${param}" - fi -done < "${SD08_DIR}/parameters.txt" -eval $CMD diff --git a/20.sh.old b/20.sh.old deleted file mode 100644 index 9f3781f..0000000 --- a/20.sh.old +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -source /sl_folder.sh - -export PATH="/home/abc/miniconda3/bin:$PATH" -export SD20_DIR=${BASE_DIR}/20-kubin - -mkdir -p "${SD20_DIR}" -mkdir -p /config/outputs/20-kubin - -if [ ! -d ${SD20_DIR}/env ]; then - conda create -p ${SD20_DIR}/env -y -fi - -source activate ${SD20_DIR}/env -conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.11 pip --solver=libmamba -y - - -if [ ! -f "$SD20_DIR/parameters.txt" ]; then - cp -v "${SD_INSTALL_DIR}/parameters/20.txt" "$SD20_DIR/parameters.txt" -fi - -if [ ! -d ${SD20_DIR}/kuby ]; then - cd "${SD20_DIR}" && git clone https://github.com/seruva19/kubin.git -fi - -cd ${SD20_DIR}/kubin -git config --global --add safe.directory ${SD20_DIR}/kubin -git pull -X ours - -# chown -R diffusion:users ${BASE_DIR} - -if [ ! -d ${SD20_DIR}/venv ]; then - python3 -m venv venv -fi - - -cd ${SD20_DIR} -source venv/bin/activate -cd ${SD20_DIR}/kubin -pip install -r requirements.txt -CMD="python3 src/kubin.py"; while IFS= read -r param; do if [[ $param != \#* ]]; then CMD+=" ${param}"; fi; done < "${SD20_DIR}/parameters.txt"; eval $CMD diff --git a/50.sh b/50.sh index 7c02b99..f4095b1 100755 --- a/50.sh +++ b/50.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD50_DIR=${BASE_DIR}/50-IOPaint @@ -19,27 +19,11 @@ if [ ! -f "$SD50_DIR/parameters.txt" ]; then cp -v "${SD_INSTALL_DIR}/parameters/50.txt" "$SD50_DIR/parameters.txt" fi -#if [ ! -d ${SD50_DIR}/IOPaint ]; then -# cd "${SD50_DIR}" && git clone https://github.com/Sanster/IOPaint -#fi - -#cd ${SD50_DIR}/IOPaint -#git config --global --add safe.directory ${SD50_DIR}/lama_cleaner -#git pull -X ours - -# chown -R diffusion:users ${BASE_DIR} - -# if [ ! -d ${SD50_DIR}/venv ]; then -# su -w SD50_DIR - diffusion -c 'cd ${SD50_DIR} && python3 -m venv venv' -# fi - - cd ${SD50_DIR}/IOPaint #pip install -r requirements.txt pip3 install iopaint - CMD="iopaint start" while IFS= read -r param; do if [[ $param != \#* ]]; then diff --git a/51.sh b/51.sh index 3a5f8a4..14e0887 100755 --- a/51.sh +++ b/51.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD51_DIR=${BASE_DIR}/51-facefusion @@ -29,12 +29,6 @@ conda install -c conda-forge git python=3.11 pip gxx ffmpeg --solver=libmamba -y git config --global --add safe.directory ${SD51_DIR}/facefusion git pull -X ours -# chown -R diffusion:users ${BASE_DIR} - -# if [ ! -d ${SD51_DIR}/venv ]; then -# su -w SD51_DIR - diffusion -c 'cd ${SD51_DIR} && python3 -m venv venv' -# fi - cd ${SD51_DIR}/facefusion pip install -r requirements.txt diff --git a/70.sh b/70.sh index e794a43..40192d4 100755 --- a/70.sh +++ b/70.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" export SD70_DIR=${BASE_DIR}/70-kohya @@ -16,31 +16,10 @@ if [ ! -d ${SD70_DIR}/kohya_ss ]; then fi # check if remote is ahead of local -# https://stackoverflow.com/a/25109122/1469797 -cd ${SD70_DIR}/kohya_ss -if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ -sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - export active_clean=1 -# git reset --hard HEAD - git pull -X ours -fi +check_remote #clean conda env if needed -if [ "$active_clean" = "1" ]; then - echo "-------------------------------------" - echo "Cleaning venv" - rm -rf ${SD70_DIR}/env - export active_clean=0 - echo "Done!" - echo -e "-------------------------------------\n" -fi +clean_env ${SD70_DIR}/env #create conda env if [ ! -d ${SD70_DIR}/env ]; then diff --git a/custom-sample.sh b/custom-sample.sh index 589f425..cfe0931 100644 --- a/custom-sample.sh +++ b/custom-sample.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /sl_folder.sh +source /functions.sh export PATH="/home/abc/miniconda3/bin:$PATH" diff --git a/docker/root/etc/s6-overlay/s6-rc.d/init-chown/run b/docker/root/etc/s6-overlay/s6-rc.d/init-chown/run index bb56287..efa61ef 100755 --- a/docker/root/etc/s6-overlay/s6-rc.d/init-chown/run +++ b/docker/root/etc/s6-overlay/s6-rc.d/init-chown/run @@ -8,7 +8,7 @@ chown -R abc:abc /home/abc #echo -e "-------------------------------------\n" # reset rights if file "Delete this file to reset access rights at next launch" isn't present -if [ ! -f "$BASE_DIR/Delete this file to reset access rights at next launch" ]; then +if [ ! -f "$BASE_DIR/Delete_this_file_to_reset_access_rights_at_next_launch" ]; then echo "-------------------------------------" echo "chown'ing directory to ensure correct permissions." chown -R abc:users $BASE_DIR @@ -16,7 +16,7 @@ chmod -R 774 $BASE_DIR chmod -R 664 $BASE_DIR/models chmod -R 664 $BASE_DIR/outputs find $BASE_DIR -type d -exec chmod 777 {} + -echo Delete this file to reset access rights at next launch > $BASE_DIR/'Delete this file to reset access rights at next launch' +echo Delete this file to reset access rights at next launch > $BASE_DIR/'Delete_this_file_to_reset_access_rights_at_next_launch' echo "Done!" echo -e "-------------------------------------\n" fi \ No newline at end of file diff --git a/entry.sh b/entry.sh index 6ae3aef..e5c6da2 100644 --- a/entry.sh +++ b/entry.sh @@ -8,11 +8,11 @@ if [ ! -f "$BASE_DIR/scripts/custom-sample.sh" ]; then fi # if file "Delete this file to clean virtual env and dependencies at next launch" isn't present -if [ -f "$BASE_DIR/Delete this file to clean virtual env and dependencies at next launch" ]; then +if [ -f "$BASE_DIR/Delete_this_file_to_clean_virtual_env_and_dependencies_at_next_launch" ]; then export active_clean=0 else export active_clean=1 -echo Delete this file to clean virtual env and dependencies at next launch > $BASE_DIR/'Delete this file to clean virtual env and dependencies at next launch' +echo Delete this file to clean virtual env and dependencies at next launch > $BASE_DIR/Delete_this_file_to_clean_virtual_env_and_dependencies_at_next_launch fi . /$WEBUI_VERSION.sh diff --git a/functions.sh b/functions.sh new file mode 100644 index 0000000..a336e5f --- /dev/null +++ b/functions.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +#Function to move folder and replace with symlink +sl_folder() { + echo "moving folder ${1}/${2} to ${3}/${4}" + mkdir -p "${3}/${4}" + if [ -d "${1}/${2}" ]; then + rsync -r "${1}/${2}/" "${3}/${4}/" --verbose + fi + echo "removing folder ${1}/${2} and create symlink" + if [ -d "${1}/${2}" ]; then + rm -rf "${1}/${2}" + fi + + # always remove previous symlink + # b/c if user changed target locations current symlink will be incorrect + if [ -L "${1}/${2}" ]; then + rm "${1}/${2}" + fi + # create symlink + ln -s "${3}/${4}/" "${1}" + if [ ! -L "${1}/${2}" ]; then + mv "${1}/${4}" "${1}/${2}" + fi +} + +clean_env() { +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${1} + echo "Done!" + echo -e "-------------------------------------\n" +fi +} + +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 +check_remote() { + if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ +sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else + if [ "$CLEAN_ENV" = "true" ]; then + echo "Forced wiping venv for clean packages install" + else + echo "Remote branch is ahead. Wiping venv for clean packages install" + fi + export active_clean=1 + git pull -X ours +fi +} \ No newline at end of file diff --git a/sl_folder.sh b/sl_folder.sh deleted file mode 100644 index ea97f74..0000000 --- a/sl_folder.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -#Function to move folder and replace with symlink -sl_folder() { - echo "moving folder ${1}/${2} to ${3}/${4}" - mkdir -p "${3}/${4}" - if [ -d "${1}/${2}" ]; then - rsync -r "${1}/${2}/" "${3}/${4}/" --verbose - fi - echo "removing folder ${1}/${2} and create symlink" - if [ -d "${1}/${2}" ]; then - rm -rf "${1}/${2}" - fi - - # always remove previous symlink - # b/c if user changed target locations current symlink will be incorrect - if [ -L "${1}/${2}" ]; then - rm "${1}/${2}" - fi - # create symlink - ln -s "${3}/${4}/" "${1}" - if [ ! -L "${1}/${2}" ]; then - mv "${1}/${4}" "${1}/${2}" - fi -} From 82dee5dc9b3765ccd2026d18d3d88dd4601714ba Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 25 Mar 2024 23:05:41 +0100 Subject: [PATCH 2/4] remove looping when UI crashes --- 03.sh | 1 + 04.sh | 1 + 05.sh | 1 + 06.sh | 1 + 07.sh | 1 + 50.sh | 2 +- 51.sh | 2 +- 70.sh | 1 + 8 files changed, 8 insertions(+), 2 deletions(-) diff --git a/03.sh b/03.sh index 3583b9a..2a8def6 100755 --- a/03.sh +++ b/03.sh @@ -46,3 +46,4 @@ while IFS= read -r param; do fi done < "${SD03_DIR}/parameters.txt" eval $CMD +wait 99999 \ No newline at end of file diff --git a/04.sh b/04.sh index db6215c..8d4d5b0 100755 --- a/04.sh +++ b/04.sh @@ -80,3 +80,4 @@ while IFS= read -r param; do fi done < "${SD04_DIR}/parameters.txt" eval $CMD +wait 99999 \ No newline at end of file diff --git a/05.sh b/05.sh index cedcfe6..1c7a4e1 100755 --- a/05.sh +++ b/05.sh @@ -76,3 +76,4 @@ while IFS= read -r param; do fi done < "${SD05_DIR}/parameters.txt" eval $CMD +wait 99999 \ No newline at end of file diff --git a/06.sh b/06.sh index 6cadbc9..b9a22f2 100755 --- a/06.sh +++ b/06.sh @@ -62,3 +62,4 @@ while IFS= read -r param; do fi done < "${SD06_DIR}/parameters.txt" eval $CMD +wait 99999 \ No newline at end of file diff --git a/07.sh b/07.sh index 1b2aba8..406c573 100755 --- a/07.sh +++ b/07.sh @@ -59,3 +59,4 @@ while IFS= read -r param; do fi done < "${SD07_DIR}/parameters.txt" eval $CMD +wait 99999 \ No newline at end of file diff --git a/50.sh b/50.sh index f4095b1..4edd25f 100755 --- a/50.sh +++ b/50.sh @@ -32,4 +32,4 @@ while IFS= read -r param; do done < "${SD50_DIR}/parameters.txt" eval $CMD - +wait 99999 diff --git a/51.sh b/51.sh index 14e0887..8a53ceb 100755 --- a/51.sh +++ b/51.sh @@ -36,4 +36,4 @@ conda install -c conda-forge git python=3.11 pip gxx ffmpeg --solver=libmamba -y export GRADIO_SERVER_PORT=9000 CMD="python3 run.py"; while IFS= read -r param; do if [[ $param != \#* ]]; then CMD+=" ${param}"; fi; done < "${SD51_DIR}/parameters.txt"; eval $CMD - +wait 99999 diff --git a/70.sh b/70.sh index 40192d4..1ee8fd4 100755 --- a/70.sh +++ b/70.sh @@ -42,3 +42,4 @@ CMD="python kohya_gui.py"; while IFS= read -r param; do if [[ $param != \#* ]]; +wait 99999 \ No newline at end of file From fbb3288e1111783546ac0bab68eefe0c8a409a8f Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 25 Mar 2024 23:20:04 +0100 Subject: [PATCH 3/4] CD before check update --- 02.forge.sh | 2 +- 02.sh | 2 +- 04.sh | 2 +- 05.sh | 1 + 06.sh | 1 + 07.sh | 1 + 70.sh | 1 + 7 files changed, 7 insertions(+), 3 deletions(-) diff --git a/02.forge.sh b/02.forge.sh index 377a9b3..b86037e 100644 --- a/02.forge.sh +++ b/02.forge.sh @@ -15,8 +15,8 @@ if [ ! -d ${SD02_DIR}/forge ]; then git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git ${SD02_DIR}/forge fi +# check if remote is ahead of local cd ${SD02_DIR}/forge - check_remote #clean conda env diff --git a/02.sh b/02.sh index a5f089c..c16ee3e 100755 --- a/02.sh +++ b/02.sh @@ -15,9 +15,9 @@ if [ ! -d ${SD02_DIR}/webui ]; then git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git ${SD02_DIR}/webui fi -cd ${SD02_DIR}/webui # check if remote is ahead of local +cd ${SD02_DIR}/webui check_remote #clean conda env diff --git a/04.sh b/04.sh index 8d4d5b0..e0fdbb1 100755 --- a/04.sh +++ b/04.sh @@ -14,9 +14,9 @@ if [ ! -d ${SD04_DIR}/webui ]; then git clone https://github.com/vladmandic/automatic ${SD04_DIR}/webui fi -cd ${SD04_DIR}/webui # check if remote is ahead of local +cd ${SD04_DIR}/webui check_remote #clean virtual env diff --git a/05.sh b/05.sh index 1c7a4e1..b282209 100755 --- a/05.sh +++ b/05.sh @@ -27,6 +27,7 @@ cd ${SD05_DIR}/ComfyUI/custom_nodes/ComfyUI-Manager git pull -X ours # check if remote is ahead of local +cd ${SD05_DIR}/ComfyUI check_remote #clean conda env diff --git a/06.sh b/06.sh index b9a22f2..78d92f5 100755 --- a/06.sh +++ b/06.sh @@ -23,6 +23,7 @@ if [ ! -d ${SD06_DIR}/Fooocus ]; then fi # check if remote is ahead of local +cd ${SD06_DIR}/Fooocus check_remote #clean conda env if needed diff --git a/07.sh b/07.sh index 406c573..1e49c0d 100755 --- a/07.sh +++ b/07.sh @@ -23,6 +23,7 @@ if [ ! -d ${SD07_DIR}/StableSwarmUI ]; then fi # check if remote is ahead of local +cd ${SD07_DIR}/StableSwarmUI check_remote #clean conda env if needed diff --git a/70.sh b/70.sh index 1ee8fd4..cf8b70b 100755 --- a/70.sh +++ b/70.sh @@ -16,6 +16,7 @@ if [ ! -d ${SD70_DIR}/kohya_ss ]; then fi # check if remote is ahead of local +cd ${SD70_DIR}/kohya_ss check_remote #clean conda env if needed From f6decd37520382c5036db26549d9c1184836979e Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 25 Mar 2024 23:24:31 +0100 Subject: [PATCH 4/4] Fix 02 output --- 02.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02.sh b/02.sh index c16ee3e..58d11cb 100755 --- a/02.sh +++ b/02.sh @@ -62,7 +62,7 @@ sl_folder ${SD02_DIR}/webui/models GFPGAN ${BASE_DIR}/models gfpgan sl_folder ${SD02_DIR}/webui/models LDSR ${BASE_DIR}/models ldsr sl_folder ${SD02_DIR}/webui/models ControlNet ${BASE_DIR}/models controlnet -sl_folder ${SD02_DIR}/webui outputs ${BASE_DIR}/outputs 02-sd-webui +sl_folder ${SD02_DIR}/webui output ${BASE_DIR}/outputs 02-sd-webui # run webUI echo "Run Stable-Diffusion-WebUI"