Skip to content

Commit b757d14

Browse files
authored
feat: auto-init default config to ~/.openderisk/configs/ during installation (#183)
1 parent 44224ac commit b757d14

5 files changed

Lines changed: 64 additions & 12 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ thirdparty
191191
configs/my
192192
configs/local
193193
.specstory
194+
.deriskdb
194195

195196
.cursorignore
196197
.cursor

README.ja.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,13 @@ curl -fsSL https://raw.githubusercontent.com/derisk-ai/OpenDerisk/main/install.s
7171
```
7272

7373
#### 設定ファイル
74-
インストール後、システムを設定する必要があります。設定ファイルを作成してください:
75-
`~/.openderisk/derisk-proxy-aliyun.toml` を編集し、API キーを設定してください。
74+
インストール後、デフォルトの設定ファイルは自動的に以下のパスに初期化されます:
75+
`~/.openderisk/configs/derisk-proxy-aliyun.toml`
76+
77+
このファイルを編集し、API キーを設定してください:
78+
```shell
79+
vi ~/.openderisk/configs/derisk-proxy-aliyun.toml
80+
```
7681

7782
#### 起動
7883
```

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ Digital Employees (Agents) in OpenDeRisk
6969
curl -fsSL https://raw.githubusercontent.com/derisk-ai/OpenDerisk/main/install.sh | bash
7070
```
7171
#### Configuration File
72-
After installation, you need to configure the system. Create a configuration file:
73-
Edit `~/.openderisk/derisk-proxy-aliyun.toml` and set your API keys.
72+
After installation, the default configuration file is automatically initialized at:
73+
`~/.openderisk/configs/derisk-proxy-aliyun.toml`
74+
75+
Edit this file and set your API keys:
76+
```shell
77+
vi ~/.openderisk/configs/derisk-proxy-aliyun.toml
78+
```
7479

7580
#### Start
7681
```

README.zh.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ curl -fsSL https://raw.githubusercontent.com/derisk-ai/OpenDerisk/main/install.s
6969
```
7070

7171
#### 配置文件
72-
安装完成后,需要配置系统。创建配置文件:
73-
编辑 `~/.openderisk/derisk-proxy-aliyun.toml` 并设置您的 API 密钥。
72+
安装完成后,默认配置文件已自动初始化到:
73+
`~/.openderisk/configs/derisk-proxy-aliyun.toml`
74+
75+
编辑该文件并设置您的 API 密钥:
76+
```shell
77+
vi ~/.openderisk/configs/derisk-proxy-aliyun.toml
78+
```
7479

7580
#### 启动
7681
```

install.sh

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ set -u
99

1010
INSTALL_DIR="${INSTALL_DIR:-$HOME/.openderisk}"
1111
BIN_DIR="${BIN_DIR:-$HOME/.local/bin}"
12+
CONFIG_DIR="${CONFIG_DIR:-$HOME/.openderisk/configs}"
1213
REPO_URL="https://github.com/derisk-ai/OpenDerisk.git"
1314
VERSION="${VERSION:-latest}"
15+
DEFAULT_CONFIG="derisk-proxy-aliyun.toml"
1416

1517
# Colors
1618
RED='\033[0;31m'
@@ -149,6 +151,27 @@ install_dependencies() {
149151
success "Dependencies installed successfully"
150152
}
151153

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+
152175
# Create wrapper scripts
153176
create_wrappers() {
154177
log "Creating wrapper scripts..."
@@ -171,8 +194,16 @@ EOF
171194
#!/bin/bash
172195
# OpenDerisk Server Launcher
173196
INSTALL_DIR="${INSTALL_DIR:-$HOME/.openderisk}"
197+
DEFAULT_CONFIG="$HOME/.openderisk/configs/derisk-proxy-aliyun.toml"
198+
174199
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
176207
EOF
177208

178209
chmod +x "$BIN_DIR/openderisk-server"
@@ -217,15 +248,17 @@ Usage:
217248
Environment Variables:
218249
INSTALL_DIR Installation directory (default: $HOME/.openderisk)
219250
BIN_DIR Binary directory (default: $HOME/.local/bin)
251+
CONFIG_DIR Configuration directory (default: $HOME/.openderisk/configs)
220252
VERSION Version to install (default: latest)
221253
222254
Options:
223255
--help Show this help message
224256
--version Show version information
225257
226258
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
229262
230263
For more information, visit: https://github.com/derisk-ai/OpenDerisk
231264
EOF
@@ -255,22 +288,25 @@ main() {
255288
log "Starting OpenDerisk installation..."
256289
log "Platform: $(detect_platform)"
257290
log "Install directory: $INSTALL_DIR"
291+
log "Config directory: $CONFIG_DIR"
258292
log "Binary directory: $BIN_DIR"
259293

260294
# Installation steps
261295
install_uv
262296
ensure_python
263297
clone_repo
264298
install_dependencies
299+
init_config
265300
create_wrappers
266301
add_to_path
267302

268303
success "OpenDerisk installed successfully!"
269304
echo ""
270305
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"
274310
echo ""
275311
echo "Documentation: https://github.com/derisk-ai/OpenDerisk"
276312
}

0 commit comments

Comments
 (0)