This repository was archived by the owner on Jul 24, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathstart.sh
More file actions
134 lines (103 loc) · 3.87 KB
/
Copy pathstart.sh
File metadata and controls
134 lines (103 loc) · 3.87 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
#!/bin/bash
helpInfo(){
echo \
'
Usage: '$0' <Level> [-f|--force] [-m|--mirror [Gitee|Github]] [-b|--branch [main|dev|<branch>]]
Options:
<Level> Level Code. See at /scripts/ in repo
-f|--force Change judge system kernel to pass if avaliable
-m|--mirrior [Gitee|Github] Repo mirror to download resource [default: Gitee]
-b|--branch [main|dev|<branch>] Repo branch where download resouce from [default: main]
用法: '$0' <Level> [-f|--force] [-m|--mirror [Gitee|Github]] [-b|--branch [main|dev|<branch>]]
选项:
<Level> 关卡代码。详见仓库的/scripts/目录。
-f|--force 如可用,修改评测系统内核通关。
-m|--mirrior [Gitee|Github] 下载资源文件时使用的仓库镜像。 [默认: Gitee]
-b|--branch [main|dev|<branch>] 下载资源文件时的分支。 [默认: main]
============================================
EduCoder_ComputerSysDesign
Copyright (c) GaoShibo, 2024
See more at: github.com/gaobobo/EduCoder_ComputerSysDesign
'
}
error_check() {
if [ $1 -eq 1 ]; then
echo -e "\e[38;5;9;7m 意料内错误: \e[0m脚本运行失败。请重试。"
exit 1
elif [ $1 -eq 2 ]; then
echo -e "\e[38;5;9;7m 未知的内部错误: \e[0m脚本运行时报告了内部命令错误。如果反复出现可能是脚本问题。" \
"请至\e[4mgithub.com/gaobobo/EduCoder_ComputerSysDesign\e[0m反馈问题。"
exit 2
elif [ $1 != 0 ]; then
echo -e "\e[38;5;9;7m 意料外错误: \e[0m脚本运行失败。请重试。"
exit $1
fi
}
# exit if no params
if [ -z "$1" ]; then
helpInfo
exit 0
fi
echo -e "\e[38;5;6;7m $(date): \e[0m脚本已启动。"
LevelCode=${1}
DownloadSite="Gitee"
Branch="main"
Force=""
# save params
for i in "$@"; do
params_num=${#params[*]}
((params_num++))
params[$params_num]=$i
done
# recongnize params
i=2
while [ ${i} -le "${#params[*]}" ]
do
if [ "${params[$i]}" = "-f" ] || [ "${params[$i]}" = "--force" ]
then
((i++))
Force="--force"
elif [ "${params[$i]}" = "-m" ] || [ "${params[$i]}" = "--mirror" ]
then
((i++))
case "${params[$i]}" in
"Gitee") DownloadSite="Gitee" ;;
"Github") DownloadSite="Github" ;;
*)
echo -e "\e[38;5;9;7m Error: \e[0mUnknow download mirror."
echo -e "\e[38;5;9;7m 错误: \e[0m未知的镜像下载点。"
;;
esac
elif [ "${params[$i]}" = "-b" ] || [ "${params[$i]}" = "--branch" ]
then
((i++))
Branch="${params[$i]}"
else
echo -e "\e[38;5;9;7m Error: \e[0mUnknow option: ${params[$i]}"
echo -e "\e[38;5;9;7m 错误: \e[0m未知的选项:${params[$i]}"
exit 1
fi
((i++))
done
echo -e "\e[38;5;51;7m 提示: \e[0m下载点是${DownloadSite},下载分支是${Branch}。"
case $DownloadSite in
Gitee)
wget -O /tmp/download.sh https://gitee.com/coconut_floss/EduCoder_ComputerSysDesign/raw/${Branch}/scripts/download.sh
;;
Github)
wget -O /tmp/download.sh https://raw.githubusercontent.com/gaobobo/EduCoder_ComputerSysDesign/${Branch}/scripts/download.sh
;;
esac
if [ $? -ne 0 ]; then
echo -e "\e[38;5;9;7m Error: \e[0mDownload download.sh failed. Is the network disconnected?"
echo -e "\e[38;5;9;7m 错误: \e[0m下载 download.sh 失败。是否网络不通?"
exit 1
fi
source /tmp/download.sh scripts/${LevelCode}.sh ${LevelCode}.sh ${DownloadSite} ${Branch}
error_check $?
source /tmp/${LevelCode}.sh ${DownloadSite} ${Branch} ${Force}
if [ $? -eq 0 ]; then
echo -e "\e[38;5;10;7m 完成: \e[0m脚本运行完成。可直接评测。"
else
error_check $?
fi