File size: 2,322 Bytes
7344bef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #!/bin/bash
cd "$(dirname "$0")/.." || exit 1
if [ ! -f "envs.json" ]; then
echo "[!] envs.json not found. Please run install.sh first or add your existing environment with manage.sh if you already have one."
read -p "Press Enter to exit..."
exit 1
fi
echo "[*] Fetching active environment..."
ENV_OUTPUT=$(python3 setup.py get_env_info 2>/dev/null | grep "^ENV_INFO|")
if [ -z "$ENV_OUTPUT" ]; then
echo "[!] No active environment found."
echo "Please run install.sh first or add your existing environment with manage.sh if you already have one."
read -p "Press Enter to exit..."
exit 1
fi
ENV_TYPE=$(echo "$ENV_OUTPUT" | cut -d'|' -f2)
ENV_PATH=$(echo "$ENV_OUTPUT" | cut -d'|' -f3)
if [ "$ENV_TYPE" = "venv" ] || [ "$ENV_TYPE" = "uv" ]; then
echo "[*] Activating $ENV_TYPE: $ENV_PATH"
source "$ENV_PATH/bin/activate"
elif [ "$ENV_TYPE" = "conda" ]; then
echo "[*] Activating conda: $ENV_PATH"
if command -v conda >/dev/null 2>&1; then
eval "$(conda shell.bash hook)"
else
for base in "$HOME/miniconda3" "$HOME/anaconda3" "/opt/miniconda3" "/opt/anaconda3"; do
if [ -f "$base/etc/profile.d/conda.sh" ]; then
source "$base/etc/profile.d/conda.sh"
break
fi
done
fi
if ! command -v conda >/dev/null 2>&1; then
echo "[!] Could not find conda. Please ensure Conda is installed."
read -p "Press Enter to exit..."
exit 1
fi
conda activate "$ENV_PATH"
elif [ "$ENV_TYPE" = "none" ]; then
echo "[*] Using system Python (No virtual environment)"
else
echo "[!] Unknown environment type: $ENV_TYPE"
read -p "Press Enter to exit..."
exit 1
fi
EXTRA_ARGS=""
if [ -f "scripts/args.txt" ]; then
while IFS= read -r line || [ -n "$line" ]; do
if [[ "$line" =~ ^[[:space:]]*[^#[:space:]] ]]; then
EXTRA_ARGS="$EXTRA_ARGS $line"
fi
done < "scripts/args.txt"
fi
if [ "$ENV_TYPE" = "none" ]; then
PY_CMD="python3"
else
PY_CMD="python"
fi
while true; do
echo "[*] Launching WAN2GP..."
eval "$PY_CMD wgp.py $EXTRA_ARGS"
EXIT_CODE=$?
if [ $EXIT_CODE -eq 42 ]; then
echo ""
echo "[*] Restarting..."
else
break
fi
done
read -p "Press Enter to exit..." |