forked from dbca-wa/licensing-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_project.sh
More file actions
executable file
·56 lines (45 loc) · 1.37 KB
/
create_project.sh
File metadata and controls
executable file
·56 lines (45 loc) · 1.37 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
#!/bin/bash
set -e
#if [[ $# -lt 1 ]]; then
# echo "Missing script parameter: you must supply the system name to replace 'licensing_template'"
# echo "$0 1"
# exit 1
#fi
# Gather required user input
read -p 'Github username: ' gituser
read -p 'Github repo name: ' gitrepo
gituser=${gituser,,}
gitdir=${gitrepo/"-"/"_"}
# clone gitrepo
{
cd ../
git clone git@github.com:$gituser/$gitrepo.git $gitrepo
} ||
{
echo "Error: $gitrepo repo/fork does not exist on your Github account $gituser"
echo "$0 1"
exit 1
}
# return to licensing-template folder
cd licensing-template &&
# rename dirs
mv ./licensing_template/ ./$gitdir/ &&
DIR_LIST=$(find . -type d -name "*licensing_template*")
for f in $DIR_LIST
do
mv $f $(echo $f | sed "s/licensing_template/$gitdir/g")
done &&
# rename files
FILE_LIST=$(find . -type f -name "*licensing_template*")
for f in $FILE_LIST
do
mv $f $(echo $f | sed "s/licensing_template/$gitdir/g")
done &&
# replace all occurrences of "licensing_system" with new system name
find . -type f -exec sed -i "s/licensing_template/$gitdir/g" {} \;
# clean licensing-template, copy files to new project then delete licensing-template
rm -rf .git && rm create_project.sh &&
cd ../ && cp -r licensing-template/. $gitrepo/ &&
echo "Files have been copied to your new repo" &&
rm -rf licensing-template/
echo "Licensing template has been removed"