From bef36597cc46671eeb2041b0343bd5e183883eb7 Mon Sep 17 00:00:00 2001 From: brkirch Date: Thu, 1 Dec 2022 04:04:14 -0500 Subject: [PATCH] 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'. --- launch.py | 1 + webui.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/launch.py b/launch.py index 48314264e..1661b569e 100644 --- a/launch.py +++ b/launch.py @@ -186,6 +186,7 @@ def prepare_enviroment(): parser.add_argument("--ui-settings-file", type=str, help="filename to use for ui settings", default='config.json') args, _ = parser.parse_known_args(sys.argv) + sys.argv, _ = extract_arg(sys.argv, '-f') sys.argv, skip_torch_cuda_test = extract_arg(sys.argv, '--skip-torch-cuda-test') sys.argv, reinstall_xformers = extract_arg(sys.argv, '--reinstall-xformers') sys.argv, update_check = extract_arg(sys.argv, '--update-check') diff --git a/webui.sh b/webui.sh index 6d4f09922..5f48741fc 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