-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetenv.sh
executable file
·45 lines (39 loc) · 1.47 KB
/
setenv.sh
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
#!/bin/bash
# 用于设置环境变量RAFT_HOME_PATH到当前工作目录的绝对路径
# 获取脚本所在的绝对路径
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
STATE_MODEL_DIR="$SCRIPT_DIR"/state-model/src/train/model/state_critic_cxx_model_scripted.pt
echo "STATE_MODEL_DIR: $STATE_MODEL_DIR"
# 用于设置环境变量RAFT_HOME_PATH到脚本所在的目录
export RAFT_HOME_PATH="$SCRIPT_DIR"
export STATE_MODEL_PATH="$STATE_MODEL_DIR"
# 检查参数,并根据参数执行相应操作
if [[ "$1" == "--clean" ]]; then
# 如果第一个参数是--clean,则清除环境变量
unset RAFT_HOME_PATH
unset RAFT_TEST_ID
echo "Environment variables RAFT_HOME_PATH and RAFT_TEST_ID have been cleared."
return
fi
if [[ "$1" == "--local" ]]; then
if [[ -n "$2" ]]; then
if [[ "$2" =~ ^[0-9]+$ ]]; then
export RAFT_TEST_ID="$2"
else
echo "Error: The ID specified for --local option must be a number."
return
fi
else
echo "Error: No ID specified for --local option."
return
fi
fi
# 如果有参数,但不是--clean和--local,则报错
if [[ -n "$1" && "$1" != "--clean" && "$1" != "--local" ]]; then
echo "Error: Invalid option. Valid options are '--clean' to clear environment variables or '--local [id]' to set the RAFT_TEST_ID."
return
fi
echo "RAFT_HOME_PATH: $RAFT_HOME_PATH"
if [[ -n "$RAFT_TEST_ID" ]]; then
echo "RAFT_TEST_ID: $RAFT_TEST_ID"
fi