-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmitTask.sh
More file actions
221 lines (210 loc) · 7.85 KB
/
submitTask.sh
File metadata and controls
221 lines (210 loc) · 7.85 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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
if groups ${USER} | grep -q '\bmentee\b'; then
if [ "$#" -lt 1 ]; then
echo "Usage: $0 projectfile"
exit 1
fi
read -p 'domain(sysad/web/app): ' domain
read -p 'taskno(1/2/3): ' taskno
submission_time=$(date + "%Y %m %d %H %M %S")
case $domain in
sysad)
case $taskno in
1)
sed -i "2s/n/y $submission_time/" task_submitted.txt
mkdir sysad/"${USER}task1"
mv $1 sysad/"${USER}task1"
;;
2)
sed -i "3s/n/y $submission_time/" task_submitted.txt
mkdir sysad/"${USER}task2"
mv $1 sysad/"${USER}task2"
;;
3)
sed -i "4s/n/y $submission_time/" task_submitted.txt
mkdir sysad/"${USER}task3"
mv $1 sysad/"${USER}task3"
;;
esac
;;
web)
case $taskno in
1)
sed -i "6s/n/y $submission_time/" task_submitted.txt
mkdir web/"${USER}task1"
mv $1 web/"${USER}task1"
;;
2)
sed -i "7s/n/y $submission_time/" task_submitted.txt
mkdir web/"${USER}task2"
mv $1 web/"${USER}task2"
;;
3)
sed -i "8s/n/y $submission_time/" task_submitted.txt
mkdir web/"${USER}task3"
mv $1 web/"${USER}task3"
;;
esac
;;
app)
case $taskno in
1)
sed -i "10s/n/y $submission_time/" task_submitted.txt
mkdir app/"${USER}task1"
mv $1 app/"${USER}task1"
;;
2)
sed -i "11s/n/y $submission_time/" task_submitted.txt
mkdir app/"${USER}task2"
mv $1 app/"${USER}task2"
;;
3)
sed -i "12s/n/y $submission_time/" task_submitted.txt
mkdir app/"${USER}task3"
mv $1 app/"${USER}task3"
;;
esac
;;
esac
elif groups ${USER} | grep -q '\bsysadmentor\b'; then
mentees=cut -f 1 -d ' ' aloc.txt
mentees=(mentees)
for mentee in "$mentees"; do
mentee_task1_dir="/home/core2/mentees/$mentee/sysad/${USER}task1"
mentee_task2_dir="/home/core2/mentees/$mentee/sysad/${USER}task2"
mentee_task3_dir="/home/core2/mentees/$mentee/sysad/${USER}task3"
symlink_path1="/home/core2/mentors/sysad/$USER/submittedTasks/task1"
symlink_path2="/home/core2/mentors/sysad/$USER/submittedTasks/task2"
symlink_path3="/home/core2/mentors/sysad/$USER/submittedTasks/task3"
if [ -d "$mentee_task1_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path1" ]; then
ln -s "$mentee_task1_dir" "$symlink_path1"
echo "Created symlink: $symlink_path1 -> $mentee_task1_dir"
else
echo "Symlink already exists: $symlink_path1"
fi
sed -i '1s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task1_dir"
fi
if [ -d "$mentee_task2_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path2" ]; then
ln -s "$mentee_task2_dir" "$symlink_path2"
echo "Created symlink: $symlink_path2 -> $mentee_task2_dir"
else
echo "Symlink already exists: $symlink_path2"
fi
sed -i '2s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task2_dir"
fi
if [ -d "$mentee_task3_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path3" ]; then
ln -s "$mentee_task3_dir" "$symlink_path3"
echo "Created symlink: $symlink_path3 -> $mentee_task3_dir"
else
echo "Symlink already exists: $symlink_path3"
fi
sed -i '3s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task3_dir"
fi
done
elif groups ${USER} | grep -q '\bwebmentor\b'; then
mentees=cut -f 1 -d ' ' aloc.txt
mentees=(mentees)
for mentee in "$mentees"; do
mentee_task1_dir="/home/core2/mentees/$mentee/web/${USER}task1"
mentee_task2_dir="/home/core2/mentees/$mentee/web/${USER}task2"
mentee_task3_dir="/home/core2/mentees/$mentee/web/${USER}task3"
symlink_path1="/home/core2/mentors/webdev/$USER/submittedTasks/task1"
symlink_path2="/home/core2/mentors/webdev/$USER/submittedTasks/task2"
symlink_path3="/home/core2/mentors/webdev/$USER/submittedTasks/task3"
if [ -d "$mentee_task1_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path1" ]; then
ln -s "$mentee_task1_dir" "$symlink_path1"
echo "Created symlink: $symlink_path1 -> $mentee_task1_dir"
else
echo "Symlink already exists: $symlink_path1"
fi
sed -i '4s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task1_dir"
fi
if [ -d "$mentee_task2_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path2" ]; then
ln -s "$mentee_task2_dir" "$symlink_path2"
echo "Created symlink: $symlink_path2 -> $mentee_task2_dir"
else
echo "Symlink already exists: $symlink_path2"
fi
sed -i '5s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task2_dir"
fi
if [ -d "$mentee_task3_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path3" ]; then
ln -s "$mentee_task3_dir" "$symlink_path3"
echo "Created symlink: $symlink_path3 -> $mentee_task3_dir"
else
echo "Symlink already exists: $symlink_path3"
fi
sed -i '6s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task3_dir"
fi
done
elif groups ${USER} | grep -q '\bappmentor\b'; then
mentees=cut -f 1 -d ' ' aloc.txt
mentees=(mentees)
for mentee in "$mentees"; do
mentee_task1_dir="/home/core2/mentees/$mentee/app/${USER}task1"
mentee_task2_dir="/home/core2/mentees/$mentee/app/${USER}task2"
mentee_task3_dir="/home/core2/mentees/$mentee/app/${USER}task3"
symlink_path1="/home/core2/mentors/appdev/$USER/submittedTasks/task1"
symlink_path2="/home/core2/mentors/appdev/$USER/submittedTasks/task2"
symlink_path3="/home/core2/mentors/appdev/$USER/submittedTasks/task3"
if [ -d "$mentee_task1_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path1" ]; then
ln -s "$mentee_task1_dir" "$symlink_path1"
echo "Created symlink: $symlink_path1 -> $mentee_task1_dir"
else
echo "Symlink already exists: $symlink_path1"
fi
sed -i '7s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task1_dir"
fi
if [ -d "$mentee_task2_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path2" ]; then
ln -s "$mentee_task2_dir" "$symlink_path2"
echo "Created symlink: $symlink_path2 -> $mentee_task2_dir"
else
echo "Symlink already exists: $symlink_path2"
fi
sed -i '8s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task2_dir"
fi
if [ -d "$mentee_task3_dir" ]; then
# Create the symlink if it does not already exist
if [ ! -L "$symlink_path3" ]; then
ln -s "$mentee_task3_dir" "$symlink_path3"
echo "Created symlink: $symlink_path3 -> $mentee_task3_dir"
else
echo "Symlink already exists: $symlink_path3"
fi
sed -i '9s/n/y/' /home/core2/mentees/$mentee/task_completed.txt
else
echo "Mentee task directory does not exist: $mentee_task3_dir"
fi
done
echo over