forked from bibbox/app-liferay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·164 lines (139 loc) · 4.01 KB
/
install.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
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
#!/bin/bash
tool="liferay"
instance="instance"
folderprefix="/opt/bibbox/"
folder="${folderprefix}liferay-instance"
url="demo.bibbox.org"
ip="127.0.0.1"
subdomain="notset"
addproxy="/opt/bibbox/bibbox-scripts/addproxy.sh"
PROGNAME=$(basename $0)
echo "Starting $tool Containers"
usage()
{
echo "Usage: start [OPTIONS]"
echo " start [ --help | -v | --version ]"
echo ""
echo "Creates Instance of the compose docker file"
echo ""
echo "OPTIONS:"
echo " -I, --instance Set Instance Name"
echo " -s, --subdomain Set Subdomain for Proxy"
echo " -p, --port Set Port for Proxy"
echo " -i, --ip Set IP for Proxy if different from standard"
echo " -u, --url Set URL for Proxy if different from standard"
echo ""
echo "Example:"
echo " sudo ./start.sh -i instance1"
}
version()
{
echo "Version: 1.1"
echo "BIBBOX Version: 1.0"
echo "Build: 2016-07-14"
echo "Tool: $tool"
}
clean_up() {
# Perform program exit housekeeping
# Optionally accepts an exit status
exit $1
}
error_exit()
{
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
clean_up 1
}
checkParametersUpdateVariables()
{
folder="$folderprefix$tool-$instance"
if [[ "$instance" = "instance" ]]; then
echo "No seperate instance name set for $tool!"
fi
if [[ "$subdomain" = "notset" ]]; then
error_exit "$LINENO: Subdomain not set! Aborting."
fi
}
checkCreatConfig()
{
if [[ ! -d "$folder" ]]; then
echo "Create folders and config for $tool"
mkdir -p "${folder}"
mkdir -p "${folder}/liferay/data"
mkdir -p "${folder}/postgresql/data/pgdata"
cp docker-compose.yml "${folder}/docker-compose.yml"
cp config "${folder}"
sed -i "s#§§FOLDER#$folder#g" "${folder}/docker-compose.yml"
createPassword
echo "Password: $password"
sed -i "s#§§SET_PGSETUP_POSTGRES_PASSWORD#$password#g" "${folder}/docker-compose.yml"
sed -i "s#§§INSTANCE#$instance#g" "${folder}/docker-compose.yml"
sed -i "s#§§PORT#$port#g" "${folder}/docker-compose.yml"
sed -i "s#liferay-db#liferay-db-$instance#g" "${folder}/config/portal-setup-wizard.properties"
fi
}
createPassword()
{
password=$(openssl rand -base64 30)
}
addProxy()
{
if [[ -f "$addproxy" ]]; then
runcommand="$addproxy -t $tool-$instance -p $port -u $url -s $subdomain -i $ip"
else
echo "Proxy Script dose not exist in $addproxy"
fi
}
runDockerCompose()
{
cd ${folder}
docker-compose up -d
}
removeContainer()
{
cd ${folder}
docker-compose stop
cd /opt
rm -r "${folder}"
docker rm "liferay-application-$instance"
docker rm "liferay-data-$instance"
docker rm "liferay-db-$instance"
docker rmi bibbox/liferay-application
docker rmi bibbox/liferay-data
}
run()
{
checkParametersUpdateVariables
checkCreatConfig
addProxy
runDockerCompose
clean_up
}
while [ "$1" != "" ]; do
case $1 in
-I | --instance ) shift
instance=$1
;;
-p | --port ) shift
port=$1
;;
-u | --url ) shift
url=$1
;;
-s | --subdomain ) shift
subdomain=$1
;;
-i | --ip ) shift
ip=$1
;;
-h | --help ) usage
clean_up
;;
-v | --version | version ) version
clean_up
;;
* ) usage
error_exit "Parameters not matching"
esac
shift
done
run