-
Notifications
You must be signed in to change notification settings - Fork 0
/
SCRIPT-0a-make-folders
executable file
·90 lines (76 loc) · 2.72 KB
/
SCRIPT-0a-make-folders
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
#!/bin/bash
# ---------------------------------------------------------------------
# Make the relevant folders for the DATA and cloned REPOS,
# if they do not already exist. Add default files.
#
# Author: David Mutchler.
# ---------------------------------------------------------------------
# ---------------------------------------------------------------------
# Get the values of the variables:
# data_folder e.g. DATA/DATA-csse120-202030
# data_subfolders e.g. ( DATA DATA-csse120-202030 )
# repos_folder e.g. REPOS/REPOS-csse120-202030
# repos_subfolders e.g. ( REPOS REPOS-csse120-202030 )
# username_data_files e.g.
# (students-01 students instructors assistants others temp)
#
# from the relevant file.
# ---------------------------------------------------------------------
if [ ! "${SET_CONSTANTS_HAS_RUN}" == "1" ]; then
source SET_CONSTANTS
fi
# ---------------------------------------------------------------------
# Make the folders, if they do not already exist.
# ---------------------------------------------------------------------
for folder in ${data_subfolders[@]}; do
if [ ! -d "${folder}" ]; then
mkdir "${folder}"
fi
cd ${folder}
done
for folder in ${data_subfolders[@]}; do
cd ..
done
for folder in ${repos_subfolders[@]}; do
if [ ! -d "${folder}" ]; then
mkdir "${folder}"
fi
cd ${folder}
done
for folder in ${repos_subfolders[@]}; do
cd ..
done
# ---------------------------------------------------------------------
# Put empty default files for usernames in the DATA subfolder.
# ---------------------------------------------------------------------
cd ${data_folder}
for file in ${username_data_files[@]}; do
if [ ! -f "${file}" ]; then
touch $file
fi
done
for folder in ${data_subfolders[@]}; do
cd ..
done
# ---------------------------------------------------------------------
# Put default LICENSE, README.md, and GITIGNORE files into the DATA
# subfolder. GITIGNORE will later become the repos' .gitignore file.
# ---------------------------------------------------------------------
files=(DEFAULT-LICENSE DEFAULT-README.md DEFAULT-GITIGNORE)
for file in ${files[@]}; do
if [ ! -f "${data_folder}/${file}" ]; then
echo "Copying file ${file} to folder ${data_folder}"
cp $file ${data_folder}/${file}
else
echo ""
echo "NOT copying file ${file} to folder ${data_folder}"
echo " because a file by that name already exists in that folder."
echo ""
fi
done
echo ""
echo "*** REMINDER:"
echo " Change the DEFAULT-BLAH files"
echo " in folder: ${data_folder}"
echo " to be suitable for YOUR course."
echo ""