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.1 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.1 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.1 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.1 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.1 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.1 From 066390eb5683945a6e094a817584ada6b1f7118e Mon Sep 17 00:00:00 2001 From: Wes Roberts Date: Wed, 4 Jan 2023 17:58:16 -0500 Subject: Fixes webui.sh to exec LAUNCH_SCRIPT --- webui.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webui.sh') diff --git a/webui.sh b/webui.sh index 04ecbf76..c4d6521d 100755 --- a/webui.sh +++ b/webui.sh @@ -160,10 +160,10 @@ 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}" "$@" + exec 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}" "$@" + exec "${python_cmd}" "${LAUNCH_SCRIPT}" "$@" fi -- cgit v1.2.1