41 lines
1.0 KiB
Bash
41 lines
1.0 KiB
Bash
#!/bin/bash
|
|
# Create a systemd service for AUTOMATIC1111 so it starts on boot
|
|
# Run this AFTER setup-sd.sh has completed successfully
|
|
|
|
set -e
|
|
|
|
SD_DIR="$HOME/stable-diffusion-webui"
|
|
SERVICE_FILE="/etc/systemd/system/stable-diffusion.service"
|
|
CURRENT_USER=$(whoami)
|
|
|
|
echo "Creating systemd service for Stable Diffusion WebUI..."
|
|
|
|
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
|
[Unit]
|
|
Description=AUTOMATIC1111 Stable Diffusion WebUI
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=$CURRENT_USER
|
|
WorkingDirectory=$SD_DIR
|
|
ExecStart=$SD_DIR/webui.sh --api --listen --xformers --no-half-vae
|
|
Restart=on-failure
|
|
RestartSec=10
|
|
Environment=HOME=$HOME
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable stable-diffusion
|
|
sudo systemctl start stable-diffusion
|
|
|
|
echo ""
|
|
echo "Service created and started!"
|
|
echo " Status: sudo systemctl status stable-diffusion"
|
|
echo " Logs: journalctl -u stable-diffusion -f"
|
|
echo " Stop: sudo systemctl stop stable-diffusion"
|
|
echo " Restart: sudo systemctl restart stable-diffusion"
|