-
Notifications
You must be signed in to change notification settings - Fork 0
/
correction.sh
executable file
·177 lines (160 loc) · 2.97 KB
/
correction.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/bin/bash
set -e
do_init() {
do_clone
do_gitignore
}
do_clone() {
input="./git_repos.txt"
while IFS= read -r line
do
echo Cloning $line
sleep 5
targetdir=`echo $line | cut -c32- | awk -F'/' '{print $1}'`
echo "$targetdir"
git clone $line $targetdir || true
done < "$input"
}
do_gitignore() {
for D in `find . -maxdepth 1 -type d ! -path .`
do
echo "
# MacOS
.DS_Store
# Latex
*.aux
*.bbl
*.blg
*.log
*.nav
*.out
*.snm
*.toc
*.vrb
*.run.xml
*.bcf
*.synctex.gz
# C
*.d
*.i
*.s
*.o
*.ko
*.obj
*.elf
*.ilk
*.map
*.exp
*.gch
*.pch
*.lib
*.a
*.la
*.lo
*.dll
*.so
*.so.*
*.dylib
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
*.dSYM/
*.su
*.idb
*.pdb
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
" >> $D/.gitignore
done
do_push
}
do_pull() {
for D in `find . -maxdepth 1 -type d ! -path .`
do
echo Pulling $D
git -C "$D" pull
sleep 5
done
}
do_tag() {
do_pull
for D in `find . -maxdepth 1 -type d ! -path .`
do
echo Tagging $D
git -C $D tag $(date +%d.%m.%Y-%H%M)
git -C $D push origin --tags
sleep 5
done
}
do_push() {
for D in `find . -maxdepth 1 -type d ! -path .`
do
echo Pushing $D
git -C $D add .
git -C $D commit -m "correction"
git -C $D push
sleep 5
done
}
do_status() {
for D in `find . -maxdepth 1 -type d ! -path .`
do
echo $D
git -C "$D" status
done
}
do_ex() {
for D in `find . -maxdepth 1 -type d ! -path .`
do
echo -e "\e[32m$D\e[39m"
if [[ $(ls -I desktop.ini "$D/Abgaben/Blatt$1" 2>&1) ]]; then
if [[ $(ls -I desktop.ini "$D/Abgaben/Blatt$1" 2>&1 | grep "ls: cannot access") ]]; then
echo -e "\e[31mno directory\e[39m"
else
ls -I desktop.ini "$D/Abgaben/Blatt$1"|| true
fi
else
echo -e "\e[33mno files found\e[39m"
fi
done
}
############# Main #############
show_help() {
cat << EOF
Correction Helper Script for the Operating systems course WS20/21.
Supported commands:
pull --- Pull all repositories in this directory
push --- Adds all changes made to a directory, commits and pushes them
tag --- Creates a tag in all repositories in this directory to mark a submission deadline
status --- Show status
ex %i% --- Show Abgaben folder colored-status for exercise %i%
# Initial#
init --- Inizialize by cloning student repositories and adding different file types to the .gitignore
clone --- Clones the repositories of the students specified in students.txt
gitignore --- Sets up the .gitignore file such that latex and C temp files are excluded
EOF
}
execute() {
case "$1" in
init|clone|gitignore|tag|pull|push|status|ex)
command=$1
shift
do_${command} $@
;;
*)
printf "Unknown argument $1"
show_help
exit 1
;;
esac
}
if [[ $# == 0 ]]; then show_help; exit 0; fi
execute $@