-
Notifications
You must be signed in to change notification settings - Fork 0
/
someone.sh
executable file
·77 lines (75 loc) · 2.2 KB
/
someone.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
#!/bin/bash
sudo useradd -m admin
sudo mkdir -p /home/admin/mentors /home/admin/mentees
sudo chmod 755 /home/admin/mentors
sudo chmod 755 /home/admin/mentees
sudo mkdir /home/admin/mentors/web /home/admin/mentors/app /home/admin/mentors/sysad
create(){
sudo useradd -m -d /home/admin/mentors/$1/"$men" "$men"
sudo chown "$men":"$men" /home/admin/mentors/$1/"$men"
sudo chmod 755 /home/admin/mentors/$1/"$men"
echo "$men:deltaforce@2024" | sudo chpasswd
sudo touch /home/admin/mentors/$1/"$men"/allocatedMentees.txt
sudo touch /home/admin/mentors/$1/"$men"/cap.txt
sudo chmod 777 /home/admin/mentors/$1/"$men"/cap.txt
echo "$cap" | sudo tee /home/admin/mentors/$1/"$men"/cap.txt > /dev/null
sudo mkdir -p /home/admin/mentors/$1/"$men"/submittedTasks/task{1..3}
}
while IFS= read -r line
do
line=($line)
name=${line[0]}
sudo useradd -m -d /home/admin/mentees/"$name" "$name"
sudo chown "$name":"$name" /home/admin/mentees/"$name"
sudo chmod 755 /home/admin/mentees/"$name"
echo "$name:deltaforce@2024" | sudo chpasswd
sudo touch /home/admin/mentees/"$name"/{domain_pref.txt,task_completed.txt,task_submitted.txt}
sudo chmod 777 /home/admin/mentees/"$name"/.bashrc
sudo chmod 777 /home/admin/mentees/"$name"/{domain_pref.txt,task_completed.txt,task_submitted.txt}
sudo tee /home/admin/mentees/"$name"/task_submitted.txt > /dev/null <<EOF
sysAd:
Task1: n
Task2: n
Task3: n
web:
Task1: n
Task2: n
Task3: n
app:
Task1: n
Task2: n
Task3: n
EOF
sudo tee /home/admin/mentees/"$name"/task_completed.txt > /dev/null <<EOF
sysAd:
Task1: n
Task2: n
Task3: n
web:
Task1: n
Task2: n
Task3: n
app:
Task1: n
Task2: n
Task3: n
EOF
done < menteeDetails.txt
while IFS= read -r line1
do
line1=($line1)
domain=${line1[1]}
cap=${line1[2]}
men=${line1[0]}
if [ "$domain" = "web" ]; then
create "web"
elif [ "$domain" = "app" ]; then
create "app"
elif [ "$domain" = "sysad" ]; then
create "sysad"
fi
done < mentorDetails.txt
sudo touch /home/admin/mentees_domain.txt
sudo chmod 766 /home/admin/mentees_domain.txt
sudo chown -R admin:admin /home/admin
sudo chmod -R 755 /home/admin