forked from NJU-ProjectN/ics-pa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
48 lines (38 loc) · 1.05 KB
/
init.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
46
47
48
#!/bin/bash
version=ics2019
log=""
function init() {
if [ -d $1 ]; then
echo "$1 is already initialized, exiting..."
return
fi
while [ ! -d $1 ]; do
git clone -b $version https://github.com/NJU-ProjectN/$1.git
done
log="$log$1 `cd $1 && git log --oneline --no-abbrev-commit -n1`"$'\n'
rm -rf $1/.git
if [ $2 ] ; then
sed -i -e "/^export $2=.*/d" ~/.bashrc
echo "export $2=`readlink -e $1`" >> ~/.bashrc
fi
}
read -r -p "Are you sure to initialize everything? [y/n] " input
case $input in
[yY])
init nemu NEMU_HOME
init nexus-am AM_HOME
init nanos-lite
init navy-apps NAVY_HOME
git add -A
git commit -am "$version initialized"$'\n\n'"$log"
echo "Initialization finishes!"
echo "By default this script will add environment variables into ~/.bashrc."
echo "After that, please run 'source ~/.bashrc' to let these variables take effect."
echo "If you use shell other than bash, please add these environment variables manually."
;;
[nN])
;;
*)
echo "Invalid input..."
;;
esac