-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvironment.sh
More file actions
162 lines (114 loc) · 3.75 KB
/
environment.sh
File metadata and controls
162 lines (114 loc) · 3.75 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh
set -e
#--------------------------------------------------------------------------------------------------
# Settings
#--------------------------------------------------------------------------------------------------
# environment
project="C:/dev/workspace/indy"
assets="/c/users/bunjee/OneDrive/assets/indy"
kdenlive="/c/dev/tools/kdenlive/bin"
#--------------------------------------------------------------------------------------------------
# defaults
project_default="C:/dev/workspace/indy"
assets_default="/c/users/bunjee/OneDrive/assets/indy"
kdenlive_default="/c/dev/tools/kdenlive/bin"
#--------------------------------------------------------------------------------------------------
# Functions
#--------------------------------------------------------------------------------------------------
replace()
{
expression='s:'"$1"'=\"'"$2"'":'"$1"'=\"'"$3"'":g'
apply $expression environment.sh
apply $expression configure.sh
apply $expression push.sh
apply $expression render.sh
}
replaceProjects()
{
local pathA=$(printf "%s" "$1" | sed 's/[\/&]/\\&/g')
local pathB=$(printf "%s" "$2" | sed 's/[\/&]/\\&/g')
expression="s|$pathA|$pathB|g"
applyBase "movie" "movieIntro"
applyBase "movie" "movieAttic"
applyBase "movie" "movieChase"
applyBase "movie" "movieOutro"
applyBase "trailer" "trailer6"
applyRoom "intro"
applyRoom "attic"
applyRoom "attic" "attic2"
applyRoom "attic2"
applyRoom "chase"
}
apply()
{
if [ $host = "macOS" ]; then
sed -i "" "$1" "$2"
else
sed -i "$1" "$2"
fi
}
applyBase()
{
local path="dist/$1/data/${2:-$1}.kdenlive"
# NOTE: When the parameter is 'default' we checkout the original project file.
if [ "$parameter" = "default" ]; then
git checkout "$path"
else
apply "$expression" "$path"
fi
}
applyRoom()
{
applyBase "room/$1" "${2:-$1}"
}
#--------------------------------------------------------------------------------------------------
getOs()
{
case `uname` in
Darwin*) echo "macOS";;
*) echo "other";;
esac
}
#--------------------------------------------------------------------------------------------------
# Syntax
#--------------------------------------------------------------------------------------------------
if [ $# -lt 1 -o $# -gt 3 ]; then
echo "Usage: environment <project path | default | reset>"
echo " [assets path | default]"
echo " [kdenlive path | default]"
exit 1
fi
#--------------------------------------------------------------------------------------------------
# Reset
#--------------------------------------------------------------------------------------------------
if [ "$1" = "reset" ]; then
sh environment.sh default default default
exit 0
fi
#--------------------------------------------------------------------------------------------------
# Configuration
#--------------------------------------------------------------------------------------------------
host=$(getOs)
#--------------------------------------------------------------------------------------------------
# Replacements
#--------------------------------------------------------------------------------------------------
parameter="$1"
if [ "$1" = "default" ]; then
replaceProjects "$project" "$project_default"
else
replaceProjects "$project_default" "$1"
fi
if [ $# -gt 1 ]; then
if [ "$2" = "default" ]; then
replace assets "$assets" "$assets_default"
else
replace assets "$assets" "$2"
fi
fi
if [ $# -gt 2 ]; then
if [ "$3" = "default" ]; then
replace kdenlive "$kdenlive" "$kdenlive_default"
else
replace kdenlive "$kdenlive" "$3"
fi
fi