From 0c7526313fc4cd0bf653983d2a5cc4e98d1c088c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 19:48:51 +0530 Subject: [PATCH] Redownload micromamba if the download failed midway; Start the script in the script's directory, not where it was run from --- installer/install.bat | 8 ++++++-- installer/install.sh | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index cf650da..973c6c8 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -15,11 +15,12 @@ echo. set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_DOWNLOAD_URL=https://github.com/cmdr2/stable-diffusion-ui/releases/download/v1.1/micromamba.exe -set REPO_URL=https://github.com/cmdr2/hlky-webui.git +set REPO_URL=https://github.com/Sygil-Dev/sygil-webui.git @rem Change the download URL to Sygil repo's release URL @rem We need to mirror micromamba.exe, because the official download URL uses tar.bz2 compression @rem which Windows can't unzip natively. @rem https://mamba.readthedocs.io/en/latest/installation.html#windows +set umamba_exists=F @rem figure out whether git and conda needs to be installed if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH% @@ -32,10 +33,13 @@ if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% conda call git --version >.tmp1 2>.tmp2 if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git +call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version >.tmp1 2>.tmp2 +if "%ERRORLEVEL%" EQU "0" set umamba_exists=T + @rem (if necessary) install git and conda into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( @rem download micromamba - if not exist "%MAMBA_ROOT_PREFIX%\micromamba.exe" ( + if "%umamba_exists%" == "F" ( echo "Downloading micromamba from %MICROMAMBA_DOWNLOAD_URL% to %MAMBA_ROOT_PREFIX%\micromamba.exe" mkdir "%MAMBA_ROOT_PREFIX%" diff --git a/installer/install.sh b/installer/install.sh index 6fd24ef..432cd0c 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -8,6 +8,8 @@ # This enables a user to install this project without manually installing conda and git. +cd "$(dirname "${BASH_SOURCE[0]}")" + echo "Installing Sygil WebUI.." echo "" @@ -22,6 +24,7 @@ esac export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/linux-${OS_ARCH}/latest" +umamba_exists="F" # figure out whether git and conda needs to be installed if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi @@ -31,10 +34,12 @@ PACKAGES_TO_INSTALL="" if ! hash "conda" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda"; fi if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi +if "$MAMBA_ROOT_PREFIX/micromamba" --version &>/dev/null; then umamba_exists="T"; fi + # (if necessary) install git and conda into a contained environment if [ "$PACKAGES_TO_INSTALL" != "" ]; then # download micromamba - if [ ! -e "$MAMBA_ROOT_PREFIX/micromamba" ]; then + if [ "$umamba_exists" == "F" ]; then echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba" mkdir -p "$MAMBA_ROOT_PREFIX"