-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·304 lines (271 loc) · 10.1 KB
/
install.sh
File metadata and controls
executable file
·304 lines (271 loc) · 10.1 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#!/bin/bash
# FunGen Universal Bootstrap Installer for Linux/macOS
# Version: 1.0.2
# This script requires ZERO dependencies - only uses POSIX shell built-ins
# Downloads and runs the full Python installer
set -e # Exit on any error
BOOTSTRAP_VERSION="1.0.2"
# Check for help or common invalid flags
for arg in "$@"; do
case $arg in
-h|--help)
echo "FunGen Bootstrap Installer"
echo "Usage: $0 [options]"
echo ""
echo "This script downloads and installs FunGen automatically."
echo "All options are passed to the universal installer."
echo ""
echo "Common options:"
echo " --force Force reinstallation"
echo " --uninstall Run uninstaller instead"
echo " --help Show this help"
echo ""
exit 0
;;
-u)
echo "ERROR: '-u' is not a valid option."
echo "Did you mean '--uninstall' or '--force'?"
echo "Run '$0 --help' for available options."
exit 1
;;
esac
done
echo "=========================================="
echo " FunGen Bootstrap Installer"
echo " v${BOOTSTRAP_VERSION}"
echo "=========================================="
echo ""
echo "This installer will download and install everything needed:"
echo " - Python 3.11 (Miniconda)"
echo " - Git"
echo " - FFmpeg/FFprobe"
echo " - FunGen AI and all dependencies"
echo ""
echo "Note: You may be prompted for your password to install system packages"
echo " (Git, FFmpeg) via your system's package manager."
echo ""
# Detect OS and architecture
OS=$(uname -s)
ARCH=$(uname -m)
# On macOS, detect ACTUAL hardware (not just the running process architecture)
# This is important because the script might be running under Rosetta on Apple Silicon
if [ "$OS" = "Darwin" ]; then
if sysctl -n hw.optional.arm64 2>/dev/null | grep -q 1; then
HARDWARE_ARCH="arm64"
if [ "$ARCH" = "x86_64" ]; then
echo "NOTE: Detected Apple Silicon hardware, but running under Rosetta (x86_64)"
echo " Will install ARM64 native Miniconda for best performance"
echo ""
fi
ARCH="arm64" # Override to install native ARM64 version
else
HARDWARE_ARCH="x86_64"
fi
fi
case $OS in
Linux*)
PLATFORM="Linux"
PYTHON_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
PYTHON_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh"
fi
;;
Darwin*)
PLATFORM="macOS"
PYTHON_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh"
if [ "$ARCH" = "arm64" ]; then
PYTHON_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh"
echo "NOTE: Installing ARM64 native Miniconda for Apple Silicon"
echo ""
fi
;;
*)
echo "ERROR: Unsupported operating system: $OS"
exit 1
;;
esac
echo "Detected: $PLATFORM ($ARCH)"
echo ""
# Create temp directory
TEMP_DIR=$(mktemp -d)
trap "rm -rf $TEMP_DIR" EXIT
# Configuration
INSTALLER_URL="https://raw.githubusercontent.com/ack00gar/FunGen-AI-Powered-Funscript-Generator/main/install.py"
PYTHON_INSTALLER="$TEMP_DIR/miniconda-installer.sh"
UNIVERSAL_INSTALLER="$TEMP_DIR/install.py"
MINICONDA_PATH="$HOME/miniconda3"
# Function to download files (tries multiple methods)
download_file() {
local url=$1
local output=$2
local description=$3
echo " Downloading $description..."
# Try curl first (most common)
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$output"
return $?
fi
# Try wget as fallback
if command -v wget >/dev/null 2>&1; then
wget -q "$url" -O "$output"
return $?
fi
# Try python if available (unlikely but possible)
if command -v python3 >/dev/null 2>&1; then
python3 -c "
import urllib.request
urllib.request.urlretrieve('$url', '$output')
"
return $?
fi
echo "ERROR: No download tool available (curl, wget, or python3)"
return 1
}
# Function to handle interactive package installations
handle_interactive_install() {
local cmd=("$@")
echo " Note: This installation may require your interaction (password, agreement acceptance)"
echo " Running: ${cmd[*]}"
if ! "${cmd[@]}"; then
echo " Installation failed. You may need to run this command manually:"
echo " sudo ${cmd[*]}"
return 1
fi
return 0
}
echo "[1/6] Checking Python installation..."
# Check if existing miniconda is the wrong architecture
WRONG_ARCH=0
if [ -d "$MINICONDA_PATH" ] && [ -f "$MINICONDA_PATH/bin/python" ]; then
INSTALLED_ARCH=$(file "$MINICONDA_PATH/bin/python" | grep -o "x86_64\|arm64" | head -1)
if [ "$ARCH" = "arm64" ] && [ "$INSTALLED_ARCH" = "x86_64" ]; then
echo " WARNING: Found x86_64 (Intel) Miniconda on Apple Silicon Mac!"
echo " This will cause performance issues and prevent CoreML model conversion."
echo " Would you like to reinstall with ARM64 (native) Miniconda? [y/N]"
read -r response
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
echo " Backing up old Miniconda to $HOME/miniconda3.x86_64.backup..."
mv "$MINICONDA_PATH" "$HOME/miniconda3.x86_64.backup"
WRONG_ARCH=1
else
echo " Continuing with x86_64 Miniconda (running under Rosetta 2)..."
echo " Note: CoreML model conversion will not work."
fi
fi
fi
if [ -d "$MINICONDA_PATH" ] && [ "$WRONG_ARCH" -eq 0 ]; then
echo " Miniconda already installed, skipping download..."
else
echo " Downloading Miniconda installer..."
if ! download_file "$PYTHON_URL" "$PYTHON_INSTALLER" "Miniconda"; then
echo "ERROR: Failed to download Miniconda installer"
exit 1
fi
echo " Miniconda installer downloaded successfully"
fi
echo ""
echo "[2/6] Installing Miniconda..."
if [ -d "$MINICONDA_PATH" ] && [ "$WRONG_ARCH" -eq 0 ]; then
echo " Miniconda already installed at $MINICONDA_PATH"
echo " Using existing installation..."
else
echo " This may take a few minutes..."
chmod +x "$PYTHON_INSTALLER"
"$PYTHON_INSTALLER" -b -p "$MINICONDA_PATH"
if [ $? -ne 0 ]; then
echo "ERROR: Miniconda installation failed"
exit 1
fi
echo " Miniconda installed successfully"
fi
# Add conda to PATH for this session
export PATH="$MINICONDA_PATH/bin:$PATH"
CONDA_EXE="$MINICONDA_PATH/bin/conda"
ENV_NAME="FunGen"
echo ""
echo "[3/6] Creating FunGen conda environment..."
if "$CONDA_EXE" env list 2>/dev/null | grep -q "$ENV_NAME"; then
echo " Conda environment '$ENV_NAME' already exists, skipping..."
else
echo " Creating environment '$ENV_NAME' with Python 3.11..."
if ! "$CONDA_EXE" create -n "$ENV_NAME" python=3.11 -c conda-forge -y; then
echo " conda-forge channel failed, trying default channels..."
if ! "$CONDA_EXE" create -n "$ENV_NAME" python=3.11 -y; then
echo "ERROR: Failed to create conda environment"
echo " Try manually: conda create -n $ENV_NAME python=3.11 -y"
exit 1
fi
fi
echo " Conda environment created successfully"
fi
echo ""
echo "[4/6] Installing Git and FFmpeg via conda..."
if command -v git >/dev/null 2>&1; then
echo " Git already available, skipping..."
else
echo " Installing Git..."
"$CONDA_EXE" install -n "$ENV_NAME" git -c conda-forge -y >/dev/null 2>&1 \
&& echo " Git installed" \
|| echo " Git install skipped — universal installer will handle it"
fi
if command -v ffmpeg >/dev/null 2>&1; then
echo " FFmpeg already available, skipping..."
else
echo " Installing FFmpeg..."
"$CONDA_EXE" install -n "$ENV_NAME" ffmpeg -c conda-forge -y >/dev/null 2>&1 \
&& echo " FFmpeg installed" \
|| echo " FFmpeg install skipped — universal installer will handle it"
fi
echo ""
echo "[5/6] Downloading FunGen universal installer..."
if ! download_file "$INSTALLER_URL" "$UNIVERSAL_INSTALLER" "FunGen universal installer"; then
echo "ERROR: Failed to download universal installer"
exit 1
fi
echo " Universal installer downloaded successfully"
echo ""
echo "[6/6] Running FunGen universal installer..."
echo " The universal installer will now handle the remaining setup..."
echo ""
# Use the conda env python (not base) to run the installer
CONDA_PYTHON="$MINICONDA_PATH/envs/$ENV_NAME/bin/python"
if [ ! -f "$CONDA_PYTHON" ]; then
echo "WARNING: Conda env python not found at $CONDA_PYTHON"
echo " Falling back to base conda python"
CONDA_PYTHON="$MINICONDA_PATH/bin/python"
if [ ! -f "$CONDA_PYTHON" ]; then
echo "WARNING: Base conda python not found either, using PATH python"
CONDA_PYTHON="python"
fi
fi
if [ $# -gt 0 ]; then
echo " Passing arguments: $@"
"$CONDA_PYTHON" "$UNIVERSAL_INSTALLER" --dir "$(pwd)" --bootstrap-version "$BOOTSTRAP_VERSION" "$@"
else
"$CONDA_PYTHON" "$UNIVERSAL_INSTALLER" --dir "$(pwd)" --bootstrap-version "$BOOTSTRAP_VERSION"
fi
INSTALL_RESULT=$?
if [ $INSTALL_RESULT -eq 0 ]; then
echo ""
echo "=========================================="
echo " Bootstrap Installation Complete!"
echo "=========================================="
echo ""
echo "FunGen has been successfully installed."
echo "Check above for launcher instructions."
else
echo ""
echo "=========================================="
echo " Installation Failed"
echo "=========================================="
echo ""
echo "Please check the error messages above."
if [ "$PLATFORM" = "macOS" ]; then
echo "You may need to install Xcode Command Line Tools:"
echo " xcode-select --install"
echo ""
echo "For Apple Silicon systems, you may need Rosetta 2:"
echo " softwareupdate --install-rosetta"
fi
fi
exit $INSTALL_RESULT