-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.sh
75 lines (55 loc) · 1.99 KB
/
environment.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
#!/bin/sh
set -e
#--------------------------------------------------------------------------------------------------
# Settings
#--------------------------------------------------------------------------------------------------
# environment
assets="/c/users/bunjee/OneDrive/assets/indy"
#--------------------------------------------------------------------------------------------------
# defaults
assets_default="/c/users/bunjee/OneDrive/assets/indy"
#--------------------------------------------------------------------------------------------------
# Functions
#--------------------------------------------------------------------------------------------------
replace()
{
expression='s:'"$1"'=\"'"$2"'":'"$1"'=\"'"$3"'":g'
apply $expression environment.sh
apply $expression configure.sh
apply $expression push.sh
}
apply()
{
if [ $host = "macOS" ]; then
sed -i "" $1 $2
else
sed -i $1 $2
fi
}
#--------------------------------------------------------------------------------------------------
getOs()
{
case `uname` in
Darwin*) echo "macOS";;
*) echo "other";;
esac
}
#--------------------------------------------------------------------------------------------------
# Syntax
#--------------------------------------------------------------------------------------------------
if [ $# != 2 ] || [ $1 != "assets" ]; then
echo "Usage: environment <assets> <path>"
exit 1
fi
#--------------------------------------------------------------------------------------------------
# Configuration
#--------------------------------------------------------------------------------------------------
host=$(getOs)
#--------------------------------------------------------------------------------------------------
# Replacements
#--------------------------------------------------------------------------------------------------
if [ "$2" = "default" ]; then
replace assets "$assets" "$assets_default"
else
replace assets "$assets" "$2"
fi