-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmacOs-installer
executable file
·136 lines (107 loc) · 3.25 KB
/
macOs-installer
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
#!/bin/bash
isVerbose() {
if [ $verbose -eq 1 ]
then
# Print a trace of simple commands, for commands, case commands, select commands, and arithmetic for commands
# and their arguments or associated word lists after they are expanded and before they are executed.
# The value of the PS4 variable is expanded and the resultant value is printed before the command and its expanded arguments.
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# Alias set -o xtrace
set -xv
fi
}
validateRunner() {
if [ $(id -u) -eq 0 ]
then
tput setaf 1
echo "Running as root is not allowed. Exiting ..."
tput setaf 9
exit 1
else
echo "Running as $USER ..."
fi
}
showHelp() {
# `cat << EOF` This means that cat should stop reading when EOF is detected
cat << EOF
Usage: ./installer -v <espo-version> [-hV]
Install Pre-requisites for EspoCRM with docker in Development mode
-h,Display help
-v,Set and Download specific version of EspoCRM
-V,Run script in verbose mode. Will print out each step of execution.
Pre Installation:
1) Go to Docker Preferences => File Sharing
2) Add /crm path, otherwise mount will fail.
EOF
# EOF is found above and hence cat command stops reading. This is equivalent to echo but much neater when printing out.
}
validateRunner
# Command-line Option builder and parser
export verbose=0;
# Documentation on getopts:
# https://www.linkedin.com/pulse/command-line-named-parameters-bash-karthik-bhat-k/
# Removed getopt as it doesn't work well with Mac
while getopts "hv:V" FLAG
do
case $FLAG in
h)
showHelp
exit 0
;;
v)
shift
export version=$1
;;
V)
export verbose=1
;;
\?)
showHelp
exit 0
;;
esac
shift
done
# See if version is set
if [ -z $version ];
then
tput setaf 1;
echo "ERROR: Version not found";
tput init;
showHelp;
exit 1;
fi
if [ $(pwd) != "/crm" ];
then
echo "Expected path: /crm";
fi
# This is to build images
docker build -f webapp/Dockerfile -t crm-webapp:1.0.0 --build-arg VERSION=$version .
export WORKDIR=$(pwd);
export CRMDIR=$WORKDIR/espocrm;
export PROJECTS=$WORKDIR/projects;
python $WORKDIR/repo_tools/install.py
if [ ! -d $CRMDIR ];
then
cd $WORKDIR;
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";
brew install wget --with-libressl;
wget -O /tmp/espocrm.zip https://github.com/espocrm/espocrm/archive/$version.zip;
unzip -d . /tmp/espocrm.zip;
mv espocrm-$version espocrm;
else
echo "EspoCRM repository already exists";
fi
cd $CRMDIR;
docker run --rm -v $(pwd):/app composer:1.7.2 install -o --ignore-platform-reqs;
if [ ! -d $CRMDIR/build/EspoCRM-$version ];
then
docker run --rm -v $(pwd):/app node:8.12.0-alpine sh -c "cd /app; npm install; npm install -g grunt-cli; grunt"
fi
cd $WORKDIR;
# This is to add extensions after building images.
docker-compose -f dev.docker-compose.yml up -d
docker exec devCrmServer chown -R nobody:nogroup $CRMDIR
cat << EOF
Special Note: After reboot, no need to use sudo while running docker command!
EOF