-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
237 lines (191 loc) · 7.25 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
################################################################################
# Author : shadow
################################################################################
#!/bin/bash
# declaration of variables for location storage
conf_file="/etc/odoo.conf"
service_file="/etc/systemd/system/odoo.service"
config_content="[options]
admin_passwd=odoo
db_host=False
db_port=False
db_user=odoo
db_password=False
addons_path=/opt/odoo16/odoo/addons,/opt/odoo/odoo-custom-addons
xmlrpc_port=8069"
service_content="[Unit]
Description=Odoo
Requires=postgresql.service
After=network.target postgresql.service
[Service]
Type=simple
SyslogIdentifier=odoo
PermissionsStartOnly=true
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo-venv/bin/python3 /opt/odoo16/odoo/odoo-bin -c /etc/odoo.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target"
echo "################################################################################"
echo "# Author : vignesh_pandian"
echo "################################################################################"
# updating server
echo "---- UPDATING SERVER ----"
if sudo apt update && sudo apt upgrade -y ; then
echo "---- updation completed !!! ----"
else
echo "---- server updation failed ----"
fi
# creating service and config files for odoo
echo "---- CREATING CONFIG AND SERVICE FILES FOR ODOO ----"
# service file
if sudo touch /etc/systemd/system/odoo.service ; then
echo "---- odoo.service file has been created !!! ----"
else
echo "---- failed to create the odoo.service file !!! ----"
fi
# conf file
if sudo touch /etc/odoo.conf ; then
echo "---- odoo.conf file has been created !!! ----"
else
echo "---- failed to create the odoo.conf file ----"
fi
# creating and giving permission directories
echo "---- GIVING PERMISSIONS ----"
# creating dir
if sudo mkdir -p /opt/odoo16/odoo ; then
echo "---- odoo directory has been created ----"
else
echo "---- Failed to create the odoo directory / directory already exists !!! ----"
fi
# giving permission to dir
if sudo chmod u+w /opt/odoo16 ; then
echo "---- successfully given permission to odoo directory ----"
else
echo "---- Failed to create the odoo directory !!! ----"
fi
# installing pre-requisites packages
echo "---- INSTALLING PRE-REQUISITES ----"
sudo apt install -y build ssential wget python3-dev python3-venv python3-wheel libfreetype6-dev libxml2-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less libjpeg-dev zlib1g-dev libpq-dev libxslt1-dev libldap2-dev libtiff5-dev libjpeg8-dev libopenjp2-7-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev libxcb1-dev postgresql
echo "---- completed installing pre-requisites !!! ----"
# creating odoo user
echo "---- Creating Odoo user ----"
if sudo useradd -m -d /opt/odoo -U -r -s /bin/bash odoo ; then
echo "---- completed creating odoo user !!! ----"
else
echo "odoo user creation failed / the user already exists"
fi
# giving permission to odoo user
if sudo chown -R odoo /opt/odoo16 ; then
echo "---- giving permission to odoo user ----"
else
echo "---- Failed to give permission to odoo user ----"
fi
# creating postgres sql user for odoo
echo "---- Creating Postgresql user for user ----"
if sudo su - postgres -c 'createuser -s odoo'; then
echo "---- completed creating postgresql user !!! ----"
else
echo "postgersql user creation failed !!!"
fi
# installation of wkhtmltopdf
echo "---- Downloading wkhtmltopdf ----"
# installing wkhtmltopdf
if sudo apt install wkhtmltopdf -y ; then
echo "---- completed installing wkhtmltopdf !!! ----"
else
echo "---- failed installing wkhtmltopdf !!! ----"
fi
# installation and configuration of odoo
echo "---- SWITCHING TO ODOO USER ----"
sudo su - odoo <<EOF
echo "---- cloning from github ----"
if git clone https://www.github.com/odoo/odoo --depth 1 --branch 16.0 /opt/odoo16/odoo ; then
echo "---- successfully cloned from github !!! ----"
else
echo "---- failed cloning from github / cloned files already present !!! ----"
fi
# configuring odoo
cd /opt/odoo
python3 -m venv odoo-venv
echo "---- activating virtual environment "
if source /opt/odoo/odoo-venv/bin/activate ; then
echo "---- virtual environment activated successfully !!!"
else
echo "---- virtual environment failed !!!"
echo "---- exiting from script !!! ----"
exit
fi
# installing requirements for odoo
pip3 install wheel
# installing odoo-requirements.txt file
if pip3 install -r /opt/odoo16/odoo/requirements.txt ; then
echo "---- requirements installed successfully !!!"
else
echo "---- requirements installation failed !!!"
echo "---- exiting from script !!! ----"
exit
fi
# deactivating the environment
if deactivate ; then
echo "---- virtual environment deactivated and proceeding to next.... ----"
else
echo "---- virtual environment not deactivated !!! ----"
fi
# creating custom-addons
echo "---- creating custom-addons directory----"
if mkdir /opt/odoo/odoo-custom-addons ; then
echo "---- custom-addons directory has been created successfully !!! ----"
else
echo "---- directory creation failed / directory already available !!!"
fi
# exiting from odoo user
echo "---- exiting from odoo user ----"
if exit ; then
echo "---- exited from odoo user !!! ----"
else
echo "---- exiting from odoo user failed !!! ----"
fi
EOF
# adding contents to the config file
echo "---- WRITING CONFIG AND SERVICE FILES ----"
if echo "$config_content" | sudo tee "$conf_file" > /dev/null ; then
echo "---- config file created successfully ----"
else
echo "---- failed to create odoo.conf file ----"
fi
# adding contents to the service file
if echo "$service_content" | sudo tee "$service_file" > /dev/null ; then
echo "---- service file created successfully ----"
else
echo "---- failed to create service file ----"
fi
echo "---- writing completed !!!! ----"
# starting odoo
echo "---- STARTING ODOO SERVICE ----"
if sudo systemctl enable --now odoo ; then
echo "---- Odoo service has been added in startup----"
else
echo "---- odoo service failed in adding in startup----"
fi
if sudo systemctl daemon-reload ; then
echo "--- Daemon Reloaded successfully !!! ---"
else
echo "--- failed to reload daemon !!! ---"
fi
if sudo systemctl start odoo.service ; then
echo "--- odoo service started successfully !!! ---"
else
echo "--- failed to start odoo service !!! ---"
fi
echo "################################################################################"
echo "################################################################################"
echo " ODOO16 has been installed successfully !!! "
echo "################################################################################"
echo "################################################################################"
if sudo systemctl status odoo.service ; then
echo "--- odoo status !!! ---"
else
echo "--- there is no service named odoo !!! ---"
fi