From 065364445d4ea1ddec44c3f87d1b6b8acda592a6 Mon Sep 17 00:00:00 2001 From: EternalNooblet Date: Fri, 7 Oct 2022 15:25:01 -0400 Subject: added a flag to run as root if needed --- webui.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 05ca497d..41649b9a 100755 --- a/webui.sh +++ b/webui.sh @@ -3,6 +3,7 @@ # Please do not make any changes to this file, # # change the variables in webui-user.sh instead # ################################################# + # Read variables from webui-user.sh # shellcheck source=/dev/null if [[ -f webui-user.sh ]] @@ -46,6 +47,17 @@ then LAUNCH_SCRIPT="launch.py" fi +# this script cannot be run as root by default +can_run_as_root=0 + +# read any command line flags to the webui.sh script +while getopts "f" flag +do + case ${flag} in + f) can_run_as_root=1;; + esac +done + # Disable sentry logging export ERROR_REPORTING=FALSE @@ -61,7 +73,7 @@ printf "\e[1m\e[34mTested on Debian 11 (Bullseye)\e[0m" printf "\n%s\n" "${delimiter}" # Do not run as root -if [[ $(id -u) -eq 0 ]] +if [[ $(id -u) -eq 0 && can_run_as_root -eq 0 ]] then printf "\n%s\n" "${delimiter}" printf "\e[1m\e[31mERROR: This script must not be launched as root, aborting...\e[0m" -- cgit v1.2.3 From 6a4e84671016d38c10a55fedcdf09321dba737ae Mon Sep 17 00:00:00 2001 From: Daniel M Date: Fri, 14 Oct 2022 20:50:21 +0200 Subject: Fix prerequisites check in webui.sh - Check the actually used `$python_cmd` and `$GIT` executables instead of the hardcoded ones - Fix typo in comment --- webui.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 05ca497d..980c0aaf 100755 --- a/webui.sh +++ b/webui.sh @@ -82,8 +82,8 @@ then clone_dir="${PWD##*/}" fi -# Check prequisites -for preq in git python3 +# Check prerequisites +for preq in "${GIT}" "${python_cmd}" do if ! hash "${preq}" &>/dev/null then -- cgit v1.2.3 From 863e9efc19d2811f1db5055be8e346781df3f7ce Mon Sep 17 00:00:00 2001 From: Zeithrold <41533799+zeithrold@users.noreply.github.com> Date: Sun, 16 Oct 2022 15:13:18 +0800 Subject: Pull out some of URL to Env Variable (#2578) * moved repository url to changeable environment variable * move stable diffusion repo itself to env * added missing env * Remove default URL Co-authored-by: AUTOMATIC1111 <16777216c@gmail.com> --- webui.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 980c0aaf..88a78459 100755 --- a/webui.sh +++ b/webui.sh @@ -41,6 +41,11 @@ then venv_dir="venv" fi +if [[ -z "${STABLE_DIFFUSION_WEBUI_REPO}" ]] +then + STABLE_DIFFUSION_WEBUI_REPO="https://github.com/AUTOMATIC1111/stable-diffusion-webui.git" +fi + if [[ -z "${LAUNCH_SCRIPT}" ]] then LAUNCH_SCRIPT="launch.py" @@ -111,7 +116,7 @@ then cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } "${GIT}" pull else - "${GIT}" clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "${clone_dir}" + "${GIT}" clone "${STABLE_DIFFUSION_WEBUI_REPO}" "${clone_dir}" cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } fi -- cgit v1.2.3 From bd4f0fb9d9df72899c2c3a1c2bc3580bf26bb685 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sun, 16 Oct 2022 10:14:27 +0300 Subject: revert changes to two bat files I asked to revert but the author couldn't in 863e9efc19d2811f1db5055be8e346781df3f7ce. --- webui.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 88a78459..980c0aaf 100755 --- a/webui.sh +++ b/webui.sh @@ -41,11 +41,6 @@ then venv_dir="venv" fi -if [[ -z "${STABLE_DIFFUSION_WEBUI_REPO}" ]] -then - STABLE_DIFFUSION_WEBUI_REPO="https://github.com/AUTOMATIC1111/stable-diffusion-webui.git" -fi - if [[ -z "${LAUNCH_SCRIPT}" ]] then LAUNCH_SCRIPT="launch.py" @@ -116,7 +111,7 @@ then cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } "${GIT}" pull else - "${GIT}" clone "${STABLE_DIFFUSION_WEBUI_REPO}" "${clone_dir}" + "${GIT}" clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "${clone_dir}" cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } fi -- cgit v1.2.3 From bdf1a8903a38e6c29afdbfb6370c40976cdfd99a Mon Sep 17 00:00:00 2001 From: Matthew Clark Date: Tue, 4 Oct 2022 13:44:21 -0400 Subject: Pass arguments from bash to python --- webui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 980c0aaf..a9f85d89 100755 --- a/webui.sh +++ b/webui.sh @@ -138,4 +138,4 @@ fi printf "\n%s\n" "${delimiter}" printf "Launching launch.py..." printf "\n%s\n" "${delimiter}" -"${python_cmd}" "${LAUNCH_SCRIPT}" +"${python_cmd}" "${LAUNCH_SCRIPT}" "$@" -- cgit v1.2.3 From 6515dedf57db6a46c7a85b0b7a1eee0daad90123 Mon Sep 17 00:00:00 2001 From: Mackerel Date: Mon, 24 Oct 2022 10:13:25 -0400 Subject: webui.sh: no automatic git pull --- webui.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index a9f85d89..cc06f344 100755 --- a/webui.sh +++ b/webui.sh @@ -102,15 +102,14 @@ then exit 1 fi -printf "\n%s\n" "${delimiter}" -printf "Clone or update stable-diffusion-webui" -printf "\n%s\n" "${delimiter}" cd "${install_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m" "${install_dir}"; exit 1; } if [[ -d "${clone_dir}" ]] then cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } - "${GIT}" pull else + printf "\n%s\n" "${delimiter}" + printf "Clone stable-diffusion-webui" + printf "\n%s\n" "${delimiter}" "${GIT}" clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "${clone_dir}" cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } fi -- cgit v1.2.3 From 0a54bd3395e30bf7772ad6f11d69c5c437a1ab73 Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Wed, 9 Nov 2022 11:15:17 -0600 Subject: Optional Accelerate Launch --- webui.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index cc06f344..d89b344b 100755 --- a/webui.sh +++ b/webui.sh @@ -134,7 +134,15 @@ else exit 1 fi -printf "\n%s\n" "${delimiter}" -printf "Launching launch.py..." -printf "\n%s\n" "${delimiter}" -"${python_cmd}" "${LAUNCH_SCRIPT}" "$@" +if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v accelerate)" ] +then + printf "\n%s\n" "${delimiter}" + printf "Accelerating launch.py..." + printf "\n%s\n" "${delimiter}" + accelerate launch --num_cpu_threads_per_process=6 "${LAUNCH_SCRIPT}" "$@" +else + printf "\n%s\n" "${delimiter}" + printf "Launching launch.py..." + printf "\n%s\n" "${delimiter}" + "${python_cmd}" "${LAUNCH_SCRIPT}" "$@" +fi -- cgit v1.2.3 From bef36597cc46671eeb2041b0343bd5e183883eb7 Mon Sep 17 00:00:00 2001 From: brkirch Date: Thu, 1 Dec 2022 04:04:14 -0500 Subject: Fix run as root flag Even though -f enables running webui.sh as root, the -f flag will also be passed to launch.py, causing it to exit with a usage message. This adds a line to launch.py to remove the -f flag if present. In addition to the above, all the letters in the command line arguments after each '-' were being processed for 'f' and "illegal option" was displayed for each letter that didn't match. Instead, this commit silences those errors and stops processing if the first flag doesn't start with '-f'. --- webui.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 6d4f0992..5f48741f 100755 --- a/webui.sh +++ b/webui.sh @@ -51,10 +51,11 @@ fi can_run_as_root=0 # read any command line flags to the webui.sh script -while getopts "f" flag +while getopts "f" flag > /dev/null 2>&1 do case ${flag} in f) can_run_as_root=1;; + *) break;; esac done -- cgit v1.2.3 From 5ec8981df46ff6e678c09dd2c1bf4d873ac22a46 Mon Sep 17 00:00:00 2001 From: brkirch Date: Sat, 3 Dec 2022 02:28:53 -0500 Subject: Revert most launch.py changes, add mac user script Adds an addition file to read environment variables from when the webui.sh is run from macOS. --- webui.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 5f48741f..683c97d3 100755 --- a/webui.sh +++ b/webui.sh @@ -4,6 +4,14 @@ # change the variables in webui-user.sh instead # ################################################# +# If run from macOS, load defaults from webui-macos-env.sh +if [[ "$OSTYPE" == "darwin"* ]]; then + if [[ -f webui-macos-env.sh ]] + then + source ./webui-macos-env.sh + fi +fi + # Read variables from webui-user.sh # shellcheck source=/dev/null if [[ -f webui-user.sh ]] -- cgit v1.2.3 From cb64439f41bfaec168704751609d4afa47d6f2e9 Mon Sep 17 00:00:00 2001 From: Fionn Langhans Date: Mon, 12 Dec 2022 21:18:25 +0100 Subject: Bugfix: Use /usr/bin/env bash instead of just /bin/bash The problem: Some Linux distrubutions, like NixOS, use a non-standard filesystem. This causes the bash program to not be at /bin/bash (though /usr/bin/env is always there). --- webui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 683c97d3..04ecbf76 100755 --- a/webui.sh +++ b/webui.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ################################################# # Please do not make any changes to this file, # # change the variables in webui-user.sh instead # -- cgit v1.2.3