Skip to content

Commit

Permalink
feat: add installation_path and tmp_path
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-luke committed Aug 26, 2023
1 parent f3e36d2 commit 3624c15
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions sd-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

set -u

# Set the root path
root_path=$HOME
# Set the installation path
installation_path=$HOME #TODO: Make it configurable

tmp_path="$HOME/.sd-installer"
mkdir -p $root_path

function clean_up {
echo "############ Clean ###################################"
rm -rf $tmp_path
}

# Define a function to handle errors
function handle_error {
Expand All @@ -12,12 +20,10 @@ function handle_error {
choice=${choice:-y}
if [[ $choice == [yY] ]]; then
# Retry the command
cd $root_path
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/wy-luke/StableDiffusion-Installer-For-Mac/main/sd-installer.sh)"
else
clean_up
# Exit the script
echo "############ Clean ###################################"
rm $root_path/install_brew.sh
exit 1
fi
}
Expand Down Expand Up @@ -51,16 +57,16 @@ echo "############ Check and install Homebrew ##############"
eval "$(/opt/homebrew/bin/brew shellenv)"

if ! command -v brew &>/dev/null; then
if curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o install_brew.sh && [ -f $root_path/install_brew.sh ]; then
if curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o "$tmp_path/install_brew.sh" && [ -f "$tmp_path/install_brew.sh" ]; then

# Grant the permission to install Homebrew
sudo dseditgroup -o edit -a $(whoami) -t user admin
sudo dseditgroup -o edit -a $(whoami) -t user wheel

# Grant the permission to execute the installation script
chmod +x "$root_path/install_brew.sh"
chmod +x "$tmp_path/install_brew.sh"

yes | /bin/bash -c "$root_path/install_brew.sh"
yes | /bin/bash -c "$tmp_path/install_brew.sh"
eval "$(/opt/homebrew/bin/brew shellenv)"
verify_installation brew
else
Expand Down Expand Up @@ -118,14 +124,15 @@ echo

echo "############ Download code ###########################"
# Check if stable-diffusion-webui's folder exits
if [ ! -d "stable-diffusion-webui" ]; then
if [ ! -d "$installation_path/stable-diffusion-webui" ]; then
cd $installation_path
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
echo_green "Code has been installed successfully"
else
echo_green "Code has already been downloaded"
fi
# Enter the SD's folder
cd stable-diffusion-webui
cd "$installation_path/stable-diffusion-webui"
echo

echo "############ Create virtual env ######################"
Expand Down Expand Up @@ -156,7 +163,6 @@ echo "############ 开始安装 Stable Diffusion ################"
echo "############ Start to install Stable Diffusion ######"
./webui.sh

echo "############ Clean ###################################"
rm $root_path/install_brew.sh
clean_up

echo "############ Install Stable Diffusion successfully ###"

0 comments on commit 3624c15

Please sign in to comment.