-
Notifications
You must be signed in to change notification settings - Fork 0
/
submitTask.sh
56 lines (47 loc) · 2.11 KB
/
submitTask.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
#!/bin/bash
function submitTask(){
echo "Enter Name"
read name
#user authentication
if [[ $name == $(whoami) ]]; then
#if mentee uses
if groups "$name" | grep -qw "mentees"; then
read -p "which domain task to submit: (Webdev, Appdev, Sysad)" domain
read -p "which task: (task_01, task_02, task_03)" task
if [[ -z "$(ls -A /home/core/mentees/$name/$domain/$task)" ]];then
sudo mkdir /home/core/mentees/$name/$domain/$task
else
echo "File already exist"
fi
#Erasing the file so that it can be updated in the same format given
truncate -s 0 task_submitted.txt
for i in Sysad Appdev Webdev;do
echo -e "\n$i" >> /home/core/mentees/$name/task_submitted.txt
for j in task_01 task_02 task_03;do
if [[ -d /home/core/mentees/$name/$i/$j/ ]];then
echo -e "\n\t$j: y" >> /home/core/mentees/$name/task_submitted.txt
else
echo -e "\n\t$j: n" >> /home/core/mentees/$name/task_submitted.txt
fi
done
done
fi
#if mentor uses
if groups "$name" | grep -qw "mentors"; then
read -p "which domain (Webdev, Appdev, Sysad): " domain
while read line1
do
menteeName=$(echo "$line1" | cut -d " " -f 1)
for i in task_01 task_02 task_03;do
if [[ -d /home/core/mentees/$menteeName/$domain/$i/ ]];then
ln -s /home/core/mentees/$menteeName/$domain/$i /home/core/mentors/$domain/$name/submittedTasks/$i/$menteeName
fi
if [[ -n "$(ls -A /home/core/mentees/$menteeName/$domain/$i)" ]];then
echo -e "$domain $i: completed\n" >> /home/core/mentees/$menteeName/task_completed.txt
fi
done
done < /home/core/mentors/$domain/$name/allocatedMentees.txt
fi
fi
}
alias submitTask='submitTask'