-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_odoo.sh
177 lines (161 loc) · 5.98 KB
/
install_odoo.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
#!/bin/bash
###########################INFORATIONS##############################
# -Project A: Deployment of Odoo V16 on CentOS7 #
# -Script INFO : This script will Deploy the application Odoo V16 #
# on CentOS7 and run it on venv of python3.7.13. #
# Odoo V16 will use pg-14 as db and haproxy as a loadbalancer. #
# -Developer: DevOps Team - B - [email protected] #
# -Date: 04/06/2023 #
# -Version: 3.2.0 #
####################################################################
GREEN='\033[1;32m'
RED='\033[1;31m'
CYAN='\033[1;36m'
BBlue='\033[1;34m'
NC='\033[0m'
password="vagrant"
printf "${GREEN}Please be patient, the installation will takes a few minutes...${NC}\n"
printf "${CYAN}This Script Contains 10 STEPS To Deploy The Application Odoo Ver.16.${NC}\n"
printf "${BBlue}STEP 1: Updating and Upgrading The System...${NC}\n"
if sudo yum -y update && sudo yum -y upgrade
then
printf "${GREEN}STEP 1: The System Has Been Updated successfully.${NC}\n"
else
printf "${RED}Error: During The STEP 1...${NC}\n"
exit 1
fi
printf "${BBlue}STEP 2: Installing Python3.7 Packages And Libraries...${NC}\n"
if
yum install -y nano bzip2-devel openssl openssl-devel wget tar gcc git libpq-devel python-devel openldap-devel libffi-devel xz-devel zlib-devel
sudo yum -y groupinstall "Development Tools"
wget https://www.python.org/ftp/python/3.7.13/Python-3.7.13.tgz
tar xvf Python-3.7.13.tgz
cd Python-3.7.13
./configure --enable-optimizations
sudo make altinstall
then
printf "${GREEN}STEP 2: Python3.7 Packages And Libraries Installation Done Successfully...${NC}\n"
else
printf "${RED}Error: During The STEP 2...${NC}\n"
exit 1
fi
printf "${BBlue}STEP 3: Installing Postgresql-14 & Back-up Script...${NC}\n"
if
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum -y update
sudo yum install -y postgresql14-server postgresql14
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
systemctl enable postgresql-14.service
systemctl start postgresql-14.service
su - postgres -c "createuser -s odoo"
su - postgres -c "createdb $1"
sed -i 's/peer/trust/g' /var/lib/pgsql/14/data/pg_hba.conf
systemctl restart postgresql-14.service
if [[ "$1" == "app2" ]];then
mkdir /var/lib/pgsql/14/backups/remote_backup
elif [[ "$1" == "app1" ]];then
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
sshpass -p "${password}" ssh-copy-id -o StrictHostKeyChecking=no [email protected]
cp /vagrant/backup-script.sh /var/lib/pgsql/14/backups/backup-script.sh
sed -i -e 's/\r$//' /var/lib/pgsql/14/backups/backup-script.sh
chmod +x /var/lib/pgsql/14/backups/backup-script.sh
mkdir -p /var/lib/pgsql/14/backups/odoo_backup
cp /vagrant/lvm.sh /home/lvm.sh
sed -i -e 's/\r$//' /home/lvm.sh
echo "* * * * * /var/lib/pgsql/14/backups/backup-script.sh" >> pg-back-up
crontab pg-back-up
rm -f pg-back-up
fi
then
printf "${GREEN}STEP 3: Postgresql-14 & Back-up Script Have Been Installed& Configured Successfully.${NC}\n"
else
printf "${RED}Error: During The STEP 3...${NC}\n"
exit 1
fi
printf "${BBlue}STEP 4: Installing WKHTMLTOX...${NC}\n"
if
cd /tmp
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox-0.12.6.1-2.almalinux9.x86_64.rpm
yum localinstall -y wkhtmltox-0.12.6.1-2.almalinux9.x86_64.rpm
then
printf "${GREEN}STEP 4: WKHTMLTOX Has Been Installed Successfully.${NC}\n"
else
printf "${RED}Error: During The STEP 4...${NC}\n"
exit 1
fi
printf "${BBlue}STEP 5: Installing Odoo ERP...${NC}\n"
if
sudo useradd -r -m -U -s /bin/bash -d /opt/odoo odoo
cd /opt/odoo/
git clone https://www.github.com/odoo/odoo --depth 1 --branch 16.0 --single-branch
chown -R odoo: /opt/odoo/
then
printf "${GREEN}STEP 5: Odoo-V.16 ERP Has Been Installed Successfully.${NC}\n"
else
printf "${RED}Error: During The STEP 5...${NC}\n"
exit 1
fi
printf "${BBlue}STEP 6: Create And Activate A Python Virtual Environment For Odoo Software...${NC}\n"
if
cd /opt/odoo
/usr/local/bin/python3.7 -m venv Odoo-venv
chown -R odoo: Odoo-venv/
source Odoo-venv/bin/activate
pip install --upgrade pip
pip install -r /opt/odoo/odoo/requirements.txt
deactivate
then
printf "${GREEN}STEP 6: The Python Virtual Environment Has Been Installed Successfully.${NC}\n"
else
printf "${RED}Error: During The STEP 6...${NC}\n"
exit 1
fi
printf "${BBlue}STEP 7: Post Installation Configuration...${NC}\n"
if
mkdir /opt/odoo/odoo-custom-addons
mkdir /var/log/odoo
touch /var/log/odoo/odoo.log
chown -R odoo: /var/log/odoo/
then
printf "${GREEN}STEP 7: Post Installation Configuration Has Successfully Done.${NC}\n"
else
printf "${RED}Error: During The STEP 7...${NC}\n"
exit 1
fi
printf "${BBlue}STEP 8: Create a Systemd Service Unit And The Odoo.Config File...${NC}\n"
if
cp /vagrant/odoo.service /etc/systemd/system/odoo.service
cp /vagrant/odoo.conf /etc/odoo.conf
then
printf "${GREEN}STEP 8: The Systemd Service Unit and The Odoo.Config Have Been Created Successfully.${NC}\n"
else
printf "${RED}Error: During The STEP 8...${NC}\n"
exit 1
fi
printf "${BBlue}STEP 9: Start Odoo.Service And Enable It...${NC}\n"
if
systemctl enable odoo.service
systemctl start odoo.service
then
systemctl status odoo.service
else
printf "${RED}Error: During The STEP 9...${NC}\n"
exit 1
fi
if [[ "$1" == "app2" ]];then
printf "${GREEN} STEP 10: We dont need to configure the LVM Configuration ...${NC}\n"
printf "${GREEN} App2 Is ready to be used...${NC}\n"
elif [[ "$1" == "app1" ]];then
if
printf "${BBlue} STEP 10: LVM Configuration...${NC}\n"
cp /vagrant/lvm.sh /home/lvm.sh
sed -i -e 's/\r$//' /home/lvm.sh
chmod +x /home/lvm.sh
bash /home/lvm.sh
then
printf "${GREEN} STEP 10: LVM Configuration Done Successfully...${NC}\n"
else
printf "${RED}Error: During The STEP 10...${NC}\n"
exit 1
fi
fi