Upload files to "/"
This commit is contained in:
+31
-13
@@ -1,36 +1,54 @@
|
||||
#!/bin/bash
|
||||
# Create a systemd service for AUTOMATIC1111 so it starts on boot
|
||||
# Run this AFTER setup-sd.sh has completed successfully
|
||||
# Create a systemd service for Stable Diffusion WebUI Forge
|
||||
# Run this AFTER setup-sd.sh has completed and you've verified the WebUI starts correctly
|
||||
#
|
||||
# IMPORTANT: Run this script with sudo, but from your regular user account:
|
||||
# sudo ./setup-sd-service.sh
|
||||
|
||||
set -e
|
||||
|
||||
SD_DIR="$HOME/stable-diffusion-webui"
|
||||
# Detect the actual user (not root) when run with sudo
|
||||
if [ -n "$SUDO_USER" ]; then
|
||||
ACTUAL_USER="$SUDO_USER"
|
||||
ACTUAL_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6)
|
||||
else
|
||||
ACTUAL_USER=$(whoami)
|
||||
ACTUAL_HOME="$HOME"
|
||||
fi
|
||||
|
||||
SD_DIR="$ACTUAL_HOME/stable-diffusion-webui"
|
||||
SERVICE_FILE="/etc/systemd/system/stable-diffusion.service"
|
||||
CURRENT_USER=$(whoami)
|
||||
|
||||
echo "Creating systemd service for Stable Diffusion WebUI..."
|
||||
if [ ! -d "$SD_DIR" ]; then
|
||||
echo "ERROR: $SD_DIR not found. Run setup-sd.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
||||
echo "Creating systemd service for Stable Diffusion WebUI Forge..."
|
||||
echo " User: $ACTUAL_USER"
|
||||
echo " Directory: $SD_DIR"
|
||||
|
||||
tee "$SERVICE_FILE" > /dev/null <<EOF
|
||||
[Unit]
|
||||
Description=AUTOMATIC1111 Stable Diffusion WebUI
|
||||
Description=Stable Diffusion WebUI Forge
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$CURRENT_USER
|
||||
User=$ACTUAL_USER
|
||||
WorkingDirectory=$SD_DIR
|
||||
ExecStart=$SD_DIR/webui.sh --api --listen --xformers --no-half-vae
|
||||
ExecStart=$SD_DIR/webui.sh --api --listen --xformers --no-half-vae --medvram-sdxl
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
Environment=HOME=$HOME
|
||||
Environment=HOME=$ACTUAL_HOME
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable stable-diffusion
|
||||
sudo systemctl start stable-diffusion
|
||||
systemctl daemon-reload
|
||||
systemctl enable stable-diffusion
|
||||
systemctl start stable-diffusion
|
||||
|
||||
echo ""
|
||||
echo "Service created and started!"
|
||||
|
||||
Reference in New Issue
Block a user