add update function to stablediff

This commit is contained in:
Mathieu Broillet 2024-08-10 21:27:45 +02:00
parent 2471c3de53
commit 5b8cd23b85
Signed by: mathieu
GPG Key ID: A08E484FE95074C1
4 changed files with 35 additions and 9 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

View File

@ -1,2 +1,4 @@
venv/ venv/
webui/ webui/
models/
outputs/

View File

@ -2,16 +2,26 @@
source ../utils.sh source ../utils.sh
python_exec=venv/bin/python3.10 python_exec=venv/bin/python3.10
# Function to install StableDiffusion # Function to install/update StableDiffusion
install_stablediffusion() { install_stablediffusion() {
if [ -d "webui" ]; then if [ -d "webui" ]; then
echo "StableDiffusion repository already exists. Skipping clone." echo "StableDiffusion repository already exists."
yes_or_no "Do you want to update StableDiffusion WebUI (dev branch) ?" && {
cd webui
git pull
echo "StableDiffusion WebUI successfully updated."
}
else else
echo "Cloning StableDiffusion repository..." echo "Cloning StableDiffusion repository..."
git clone -b dev https://github.com/AUTOMATIC1111/stable-diffusion-webui webui git clone -b dev https://github.com/AUTOMATIC1111/stable-diffusion-webui webui
echo "Running StableDiffusion setup..."
$python_exec webui/launch.py --skip-torch-cuda-test --exit
ln -s webui/models models
ln -s webui/outputs outputs
fi fi
echo "Running StableDiffusion setup..."
$python_exec webui/launch.py --skip-torch-cuda-test --exit
} }
# Main function # Main function
@ -23,7 +33,7 @@ main() {
clean clean
echo "StableDiffusion installation complete." echo "StableDiffusion installation/update complete. Use ./run.sh to start"
} }
# Run main function # Run main function

View File

@ -27,17 +27,20 @@ use_venv() {
# Function to install build-essential or equivalent # Function to install build-essential or equivalent
install_build_essentials() { install_build_essentials() {
echo "Checking for build essentials..." echo "Checking for build essentials..."
if [ -f /etc/debian_version ]; then if [ -f /etc/debian_version ]; then
sudo apt-get update sudo apt-get update
sudo apt-get install -y build-essential python3.10-dev sudo apt-get install -y build-essential python3.10-dev
elif [ -f /etc/fedora-release ]; then elif [ -f /etc/fedora-release ]; then
if dnf list installed @development-tools &>/dev/null; then if rpm -q gcc &>/dev/null && rpm -q python3.10-devel &>/dev/null; then
echo "Development Tools are already installed." echo "Development Tools and Python 3.10 development files are already installed."
else else
echo "Installing Development Tools..." echo "Installing Development Tools and Python 3.10 development files..."
sudo dnf groupinstall -y "Development Tools" sudo dnf groupinstall -y "Development Tools"
sudo dnf install python3.10-devel sudo dnf install -y python3.10-devel
fi fi
else else
echo "Unsupported operating system. Please install build-essential or equivalent manually." echo "Unsupported operating system. Please install build-essential or equivalent manually."
exit 1 exit 1
@ -68,4 +71,14 @@ prepare_env(){
clean() { clean() {
python3.10 -m pip cache purge python3.10 -m pip cache purge
}
yes_or_no() {
while true; do
read -p "$* [y/n]: " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) echo "Aborted" ; return 1 ;;
esac
done
} }