|
9 | 9 |
|
10 | 10 | INSTALL_DIR="${INSTALL_DIR:-$HOME/.openderisk}" |
11 | 11 | BIN_DIR="${BIN_DIR:-$HOME/.local/bin}" |
| 12 | +CONFIG_DIR="${CONFIG_DIR:-$HOME/.openderisk/configs}" |
12 | 13 | REPO_URL="https://github.com/derisk-ai/OpenDerisk.git" |
13 | 14 | VERSION="${VERSION:-latest}" |
| 15 | +DEFAULT_CONFIG="derisk-proxy-aliyun.toml" |
14 | 16 |
|
15 | 17 | # Colors |
16 | 18 | RED='\033[0;31m' |
@@ -149,6 +151,27 @@ install_dependencies() { |
149 | 151 | success "Dependencies installed successfully" |
150 | 152 | } |
151 | 153 |
|
| 154 | +# Initialize default configuration |
| 155 | +init_config() { |
| 156 | + local src_config="$INSTALL_DIR/configs/$DEFAULT_CONFIG" |
| 157 | + local dest_config="$CONFIG_DIR/$DEFAULT_CONFIG" |
| 158 | + |
| 159 | + mkdir -p "$CONFIG_DIR" |
| 160 | + |
| 161 | + if [ -f "$dest_config" ]; then |
| 162 | + log "Configuration file already exists: $dest_config (skipping)" |
| 163 | + return 0 |
| 164 | + fi |
| 165 | + |
| 166 | + if [ -f "$src_config" ]; then |
| 167 | + cp "$src_config" "$dest_config" |
| 168 | + success "Default configuration initialized: $dest_config" |
| 169 | + warn "Please edit $dest_config and set your API keys before starting the server." |
| 170 | + else |
| 171 | + warn "Template config not found at $src_config, skipping config initialization." |
| 172 | + fi |
| 173 | +} |
| 174 | + |
152 | 175 | # Create wrapper scripts |
153 | 176 | create_wrappers() { |
154 | 177 | log "Creating wrapper scripts..." |
|
171 | 194 | #!/bin/bash |
172 | 195 | # OpenDerisk Server Launcher |
173 | 196 | INSTALL_DIR="${INSTALL_DIR:-$HOME/.openderisk}" |
| 197 | +DEFAULT_CONFIG="$HOME/.openderisk/configs/derisk-proxy-aliyun.toml" |
| 198 | +
|
174 | 199 | cd "$INSTALL_DIR" || exit 1 |
175 | | -exec uv run derisk start webserver "$@" |
| 200 | +
|
| 201 | +# If no arguments provided and default config exists, use it |
| 202 | +if [ $# -eq 0 ] && [ -f "$DEFAULT_CONFIG" ]; then |
| 203 | + exec uv run derisk start webserver -c "$DEFAULT_CONFIG" |
| 204 | +else |
| 205 | + exec uv run derisk start webserver "$@" |
| 206 | +fi |
176 | 207 | EOF |
177 | 208 |
|
178 | 209 | chmod +x "$BIN_DIR/openderisk-server" |
@@ -217,15 +248,17 @@ Usage: |
217 | 248 | Environment Variables: |
218 | 249 | INSTALL_DIR Installation directory (default: $HOME/.openderisk) |
219 | 250 | BIN_DIR Binary directory (default: $HOME/.local/bin) |
| 251 | + CONFIG_DIR Configuration directory (default: $HOME/.openderisk/configs) |
220 | 252 | VERSION Version to install (default: latest) |
221 | 253 |
|
222 | 254 | Options: |
223 | 255 | --help Show this help message |
224 | 256 | --version Show version information |
225 | 257 |
|
226 | 258 | After Installation: |
227 | | - openderisk Start OpenDerisk CLI |
228 | | - openderisk-server Start OpenDerisk Server |
| 259 | + 1. Edit ~/.openderisk/configs/derisk-proxy-aliyun.toml and set your API keys |
| 260 | + 2. openderisk-server Start OpenDerisk Server (uses default config) |
| 261 | + 3. openderisk Start OpenDerisk CLI |
229 | 262 |
|
230 | 263 | For more information, visit: https://github.com/derisk-ai/OpenDerisk |
231 | 264 | EOF |
@@ -255,22 +288,25 @@ main() { |
255 | 288 | log "Starting OpenDerisk installation..." |
256 | 289 | log "Platform: $(detect_platform)" |
257 | 290 | log "Install directory: $INSTALL_DIR" |
| 291 | + log "Config directory: $CONFIG_DIR" |
258 | 292 | log "Binary directory: $BIN_DIR" |
259 | 293 |
|
260 | 294 | # Installation steps |
261 | 295 | install_uv |
262 | 296 | ensure_python |
263 | 297 | clone_repo |
264 | 298 | install_dependencies |
| 299 | + init_config |
265 | 300 | create_wrappers |
266 | 301 | add_to_path |
267 | 302 |
|
268 | 303 | success "OpenDerisk installed successfully!" |
269 | 304 | echo "" |
270 | 305 | echo "Getting Started:" |
271 | | - echo " 1. Configure API keys in: $INSTALL_DIR/configs/derisk-proxy-aliyun.toml" |
272 | | - echo " 2. Run: openderisk --help" |
273 | | - echo " 3. Start server: openderisk-server" |
| 306 | + echo " 1. Edit config file: $CONFIG_DIR/$DEFAULT_CONFIG" |
| 307 | + echo " Set your API keys (e.g., DASHSCOPE_API_KEY)" |
| 308 | + echo " 2. Start server: openderisk-server" |
| 309 | + echo " 3. Open browser: http://localhost:7777" |
274 | 310 | echo "" |
275 | 311 | echo "Documentation: https://github.com/derisk-ai/OpenDerisk" |
276 | 312 | } |
|
0 commit comments