-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-group.sh
executable file
·53 lines (34 loc) · 1.04 KB
/
create-group.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
#!/usr/bin/env bash
set -e
if [[ "$1" == "-h" ]] || [[ "$2" == "-h" ]] || [[ "$1" == "" ]] || [[ "$2" == "" ]]; then
echo "Error: missing arguments."
echo "$0 term group_name"
fi
term=$1
if [ ! -d /django/$term ]; then
echo "The given term ($term) folder doesn't exist yet. Please create this manually."
exit 1
fi;
# this isn't the safest code out there, but it's probably fine.
eval "groups=($2)"
source_folder=/django/source
files_to_link=(docker-compose.site.yml instructions.md)
owner_user='trishduce'
owner_group='classadmin'
for group_name in "${groups[@]}"; do
group_folder=/django/$term/$group_name
if [ -d $group_folder ]; then
echo "The $group_name group already has a group folder in /django/$term."
exit 1
fi
echo "Creating folder for $group_name"
mkdir $group_folder
for file in "${files_to_link[@]}"; do
echo "Linking and setting permissions on $file"
ln -s $source_folder/$file $group_folder/$file
done
sudo chown -R $owner_user:$owner_group $group_folder
# rwx to all
sudo chmod -R 777 $group_folder
echo
done