-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2
More file actions
executable file
·24 lines (21 loc) · 1.1 KB
/
2
File metadata and controls
executable file
·24 lines (21 loc) · 1.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
#!/bin/sh
export OSLAB_PATH=$(dirname `which $0`) #$0就是执行run脚本时,run脚本以及所在目录的参数值
#比如./run, $0=./run
#dirname可以获取给定参数的目录部分
if [ "$1" ] && [ "$1" = "init" ] ; then #如果第一个参数非空且为init,即执行./run init
if [ -f $OSLAB_PATH/linux-0.11.tar.gz ]; then #文件存在且为文件类型
[ -d $OSLAB_PATH/linux-0.11 ] && rm -rf $OSLAB_PATH/linux-0.11 #linux-0.11目录若存在则删除
mkdir $OSLAB_PATH/linux-0.11 #新建目录linux-0.11
tar zxf $OSLAB_PATH/linux-0.11.tar.gz -C $OSLAB_PATH/linux-0.11 #解压文件到目录linux-0.11
echo "Successfully recover linux-0.11."
exit 0
else
echo "Error: oslab cant't find a backup file named linux-0.11.tar.gz!"
exit 1
fi
fi
if [ ! -e "$OSLAB_PATH/hdc/umounted" ]; then #在0.11运行前检查hdc镜像是否挂在
echo umount hdc first #如果挂在了hdc,首先卸载
sudo umount $OSLAB_PATH/hdc
fi
$OSLAB_PATH/bochs/bochs-gdb -q -f $OSLAB_PATH/bochs/bochsrc.bxrc