[UPD] refactoring and new scripts
This commit is contained in:
@@ -4,14 +4,14 @@ apt_update: true
|
|||||||
|
|
||||||
# Run 'apt-get upgrade' on first boot
|
# Run 'apt-get upgrade' on first boot
|
||||||
# disabled for testing
|
# disabled for testing
|
||||||
apt_upgrade: false
|
apt_upgrade: true
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- curl
|
- curl
|
||||||
- git
|
- git
|
||||||
|
- wget
|
||||||
- python3-pip
|
- python3-pip
|
||||||
- build-essential
|
- build-essential
|
||||||
- wget
|
|
||||||
- python3-dev
|
- python3-dev
|
||||||
- python3-venv
|
- python3-venv
|
||||||
- python3-wheel
|
- python3-wheel
|
||||||
@@ -23,61 +23,19 @@ packages:
|
|||||||
- node-less
|
- node-less
|
||||||
- postgresql
|
- postgresql
|
||||||
|
|
||||||
write_files:
|
|
||||||
- content: |
|
|
||||||
[options]
|
|
||||||
db_host = False
|
|
||||||
db_port = False
|
|
||||||
db_user = ubuntu
|
|
||||||
db_password = False
|
|
||||||
addons_path = /opt/odoo/odoo12/addons,/opt/odoo/custom-addons/zdc-oca-addons,/opt/odoo/custom-addons/dev-addons
|
|
||||||
path: /etc/odoo12.conf
|
|
||||||
- content: |
|
|
||||||
[Unit]
|
|
||||||
Description=Odoo
|
|
||||||
Requires=postgresql.service
|
|
||||||
After=network.target postgresql.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
SyslogIdentifier=odoo
|
|
||||||
PermissionsStartOnly=true
|
|
||||||
User=ubuntu
|
|
||||||
Group=ubuntu
|
|
||||||
ExecStart=/opt/odoo/venv-odoo12/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf
|
|
||||||
StandardOutput=journal+console
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
path: /etc/systemd/system/odoo12.service
|
|
||||||
|
|
||||||
# boot commands
|
# boot commands
|
||||||
# These are like 'runcmd', but run very early in the boot process & run on every boot by default.
|
# These are like 'runcmd', but run very early in the boot process & run on every boot by default.
|
||||||
bootcmd:
|
bootcmd:
|
||||||
- echo $(whoami) > /root/boot.txt
|
- echo $(whoami) > /root/boot.txt
|
||||||
|
|
||||||
runcmd:
|
runcmd:
|
||||||
#- [ wget, "http://slashdot.org", -O, /run/mydir/index.html ]
|
# enable postgres
|
||||||
# install wkhtmltopdf
|
|
||||||
#- wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb -O /run/wkhtmltox_0.12.6-1.bionic_amd64.deb
|
|
||||||
#- apt install /run/wkhtmltox_0.12.6-1.bionic_amd64.deb -y
|
|
||||||
- systemctl enable --now postgresql.service
|
- systemctl enable --now postgresql.service
|
||||||
- su - postgres -c "createuser -s ubuntu"
|
- su - postgres -c "createuser -s ubuntu"
|
||||||
# setup odoo installation
|
# setup directories
|
||||||
- mkdir /opt/odoo
|
- sudo -u ubuntu mkdir /home/ubuntu/config
|
||||||
- chown ubuntu:ubuntu /opt/odoo/
|
- sudo -u ubuntu mkdir /home/ubuntu/custom
|
||||||
- sudo -u ubuntu mkdir /opt/odoo/custom-addons
|
- sudo -u ubuntu mkdir /home/ubuntu/db
|
||||||
- sudo -u ubuntu wget https://github.com/OCA/OCB/raw/12.0/requirements.txt -O /opt/odoo/requirements.txt
|
|
||||||
#- sudo -u ubuntu /usr/bin/git clone https://www.github.com/OCA/OCB --depth 1 --branch 12.0 /opt/odoo/odoo12
|
|
||||||
# setup python3 virtualenv
|
|
||||||
- sudo -u ubuntu /usr/bin/python3 -m venv /opt/odoo/venv-odoo12
|
|
||||||
- sudo -u ubuntu cat /opt/odoo/venv-odoo12/bin/activate > /opt/odoo/venv-install.sh
|
|
||||||
- sudo -u ubuntu echo "pip3 install wheel" >> /opt/odoo/venv-install.sh
|
|
||||||
- sudo -u ubuntu echo "pip3 install -r /opt/odoo/requirements.txt" >> /opt/odoo/venv-install.sh
|
|
||||||
#- sudo -u ubuntu /bin/bash /opt/odoo/venv-install.sh
|
|
||||||
|
|
||||||
- systemctl daemon-reload
|
|
||||||
- systemctl enable odoo12
|
|
||||||
|
|
||||||
# set the locale
|
# set the locale
|
||||||
locale: en_US.UTF-8
|
locale: en_US.UTF-8
|
||||||
|
6
config/odoo12.conf
Normal file
6
config/odoo12.conf
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[options]
|
||||||
|
db_host = False
|
||||||
|
db_port = False
|
||||||
|
db_user = ubuntu
|
||||||
|
db_password = False
|
||||||
|
addons_path = /home/ubuntu/odoo12/addons,/home/ubuntu/custom/zdc-oca-addons,/home/ubuntu/custom/dev-addons
|
16
config/odoo12_service.conf
Normal file
16
config/odoo12_service.conf
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Odoo
|
||||||
|
Requires=postgresql.service
|
||||||
|
After=network.target postgresql.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
SyslogIdentifier=odoo
|
||||||
|
PermissionsStartOnly=true
|
||||||
|
User=ubuntu
|
||||||
|
Group=ubuntu
|
||||||
|
ExecStart=/home/ubuntu/venv-odoo12/bin/python3 /home/ubuntu/odoo12/odoo-bin -c /etc/odoo12.conf
|
||||||
|
StandardOutput=journal+console
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
3
config/ssh_known_hosts
Normal file
3
config/ssh_known_hosts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
gitea.egroup.sk ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5onDUxe6HEgosfzqhLL0zeX83fG+lOPEISYOj5Ef6A39EV2DtX2SVDdb47QWuZqH3/IyTmLzJxfaTyqaKyTDoIEkd6gGVA0L19HczvOuyhtVP0GM+yWH8kHoppi7WnHPD02FD+jw0l+RiD/nmvmye/1kvhwDJTHud09xVBQ/vybe+JkiNIfYNvp3OM5Iq5CsFM/OlzzzwmbfUGbKo4i/AZkTJ7Qm7i3rNe6qZYFZKJbq1ywF0kHnthiYIXPfKB6vVofBAxyl/efCgUYOxfztGXHS1J57SkZg4/DR5EXPHlo6OEITikIcpYVpPeFNHSvAzEZ6X6hm7nBOBllAzCWDT
|
||||||
|
gitea.egroup.sk ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMSYwNF2Su0BUOO9yu0ww1ge9XWFJ4f4n5HMwnaHaxUevLi2KpQ1P6lD+6g40TpWFNgjD0iUR7YMnXjZYIhMbgM=
|
||||||
|
gitea.egroup.sk ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFwyHB2WI5+eHlyGkfjTsN5LM3PF2q6oeJlAdGv8CgNe
|
79
config/venv-install.sh
Normal file
79
config/venv-install.sh
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
# This file must be used with "source bin/activate" *from bash*
|
||||||
|
# you cannot run it directly
|
||||||
|
|
||||||
|
deactivate () {
|
||||||
|
# reset old environment variables
|
||||||
|
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
||||||
|
PATH="${_OLD_VIRTUAL_PATH:-}"
|
||||||
|
export PATH
|
||||||
|
unset _OLD_VIRTUAL_PATH
|
||||||
|
fi
|
||||||
|
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
||||||
|
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
||||||
|
export PYTHONHOME
|
||||||
|
unset _OLD_VIRTUAL_PYTHONHOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This should detect bash and zsh, which have a hash command that must
|
||||||
|
# be called to get it to forget past commands. Without forgetting
|
||||||
|
# past commands the $PATH changes we made may not be respected
|
||||||
|
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||||
|
hash -r
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
||||||
|
PS1="${_OLD_VIRTUAL_PS1:-}"
|
||||||
|
export PS1
|
||||||
|
unset _OLD_VIRTUAL_PS1
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset VIRTUAL_ENV
|
||||||
|
if [ ! "$1" = "nondestructive" ] ; then
|
||||||
|
# Self destruct!
|
||||||
|
unset -f deactivate
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# unset irrelevant variables
|
||||||
|
deactivate nondestructive
|
||||||
|
|
||||||
|
VIRTUAL_ENV="/home/ubuntu/venv-odoo12"
|
||||||
|
export VIRTUAL_ENV
|
||||||
|
|
||||||
|
_OLD_VIRTUAL_PATH="$PATH"
|
||||||
|
PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
# unset PYTHONHOME if set
|
||||||
|
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
||||||
|
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
||||||
|
if [ -n "${PYTHONHOME:-}" ] ; then
|
||||||
|
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
||||||
|
unset PYTHONHOME
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
||||||
|
_OLD_VIRTUAL_PS1="${PS1:-}"
|
||||||
|
if [ "x(venv-odoo12) " != x ] ; then
|
||||||
|
PS1="(venv-odoo12) ${PS1:-}"
|
||||||
|
else
|
||||||
|
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
|
||||||
|
# special case for Aspen magic directories
|
||||||
|
# see http://www.zetadev.com/software/aspen/
|
||||||
|
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
|
||||||
|
else
|
||||||
|
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
export PS1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This should detect bash and zsh, which have a hash command that must
|
||||||
|
# be called to get it to forget past commands. Without forgetting
|
||||||
|
# past commands the $PATH changes we made may not be respected
|
||||||
|
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||||
|
hash -r
|
||||||
|
fi
|
||||||
|
|
||||||
|
pip3 install wheel
|
||||||
|
pip3 install -r /home/ubuntu/odoo12/requirements.txt
|
46
vm-create.sh
Executable file
46
vm-create.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
NAME=$1
|
||||||
|
|
||||||
|
PRIVATE_KEY=~/.ssh/id_rsa
|
||||||
|
|
||||||
|
echo "### Create Ubuntu 18.04 LTS VM"
|
||||||
|
multipass launch bionic --name $NAME --cpus 2 --mem 2048M --disk 12G --cloud-init ./cloud-init/zdc-odoo-init.yaml
|
||||||
|
|
||||||
|
echo "### Install wkhtmltopdf"
|
||||||
|
multipass exec $NAME -- sudo wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb -O /tmp/wkhtmltox_0.12.6-1.bionic_amd64.deb
|
||||||
|
multipass exec $NAME -- sudo apt install /tmp/wkhtmltox_0.12.6-1.bionic_amd64.deb -y
|
||||||
|
|
||||||
|
echo "### Add ssh private key"
|
||||||
|
multipass transfer $PRIVATE_KEY $NAME:/home/ubuntu/.ssh/id_rsa
|
||||||
|
multipass transfer config/ssh_known_hosts $NAME:/home/ubuntu/.ssh/known_hosts
|
||||||
|
multipass exec $NAME -- chmod 600 /home/ubuntu/.ssh/id_rsa
|
||||||
|
|
||||||
|
echo "### Add OCB Odoo, OCA addons"
|
||||||
|
multipass exec $NAME -- /usr/bin/git clone git@gitea.egroup.sk:development/zdc-odoo --depth 1 --branch master /home/ubuntu/odoo12
|
||||||
|
multipass exec $NAME -- /usr/bin/git clone git@gitea.egroup.sk:development/zdc-oca-addons --depth 1 --branch master /home/ubuntu/custom/zdc-oca-addons
|
||||||
|
multipass exec $NAME -- /usr/bin/git clone git@gitea.egroup.sk:development/zdc-addons --depth 1 --branch master /home/ubuntu/custom/dev-addons
|
||||||
|
|
||||||
|
echo "### Install Python Environment"
|
||||||
|
multipass exec $NAME -- sudo -u ubuntu /usr/bin/python3 -m venv /home/ubuntu/venv-odoo12
|
||||||
|
multipass transfer config/venv-install.sh $NAME:/home/ubuntu/config/venv-install.sh
|
||||||
|
multipass exec $NAME -- sudo -u ubuntu /bin/bash /home/ubuntu/config/venv-install.sh
|
||||||
|
|
||||||
|
echo "### Setup OCB Odoo 12"
|
||||||
|
multipass transfer config/odoo12.conf $NAME:/home/ubuntu/config/odoo12.conf
|
||||||
|
multipass transfer config/odoo12_service.conf $NAME:/home/ubuntu/config/odoo12.service
|
||||||
|
multipass exec $NAME -- sudo cp /home/ubuntu/config/odoo12.conf /etc/odoo12.conf
|
||||||
|
multipass exec $NAME -- sudo cp /home/ubuntu/config/odoo12.service /etc/systemd/system/odoo12.service
|
||||||
|
multipass exec $NAME -- sudo systemctl restart odoo12
|
||||||
|
|
||||||
|
echo "### Create ZDC Template DB"
|
||||||
|
multipass transfer db/zdc-template-db.sql $NAME:/home/ubuntu/db/zdc-template-db.sql
|
||||||
|
multipass exec $NAME -- sudo -u postgres psql -c "CREATE DATABASE zdcbasedb10 WITH OWNER=ubuntu;"
|
||||||
|
multipass exec $NAME -- sudo -u postgres psql -d zdcbasedb10 -f /home/ubuntu/db/zdc-template-db.sql
|
||||||
|
|
||||||
|
echo "### Check VM"
|
||||||
|
multipass list | grep $NAME
|
||||||
|
URL_IP=`multipass info $NAME | grep IPv4 | sed -e 's/ //g' -e '/^$/d' | sed -e 's/IPv4://g' -e '/^$/d'`
|
||||||
|
|
||||||
|
echo "###"
|
||||||
|
echo "### Odoo database manager on $NAME server: http://$URL_IP:8069/web/database/selector"
|
8
vm-new-db.sh
Executable file
8
vm-new-db.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
NAME=$1
|
||||||
|
DB_NAME=$2
|
||||||
|
|
||||||
|
echo "### Create Db from Template"
|
||||||
|
multipass exec $NAME -- sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER=ubuntu;"
|
||||||
|
multipass exec $NAME -- sudo -u postgres psql -d $DB_NAME -f /home/ubuntu/db/zdc-template-db.sql
|
17
vm-update-git.sh
Executable file
17
vm-update-git.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
NAME=$1
|
||||||
|
|
||||||
|
echo "### Stop odoo service"
|
||||||
|
multipass exec $NAME -- sudo systemctl stop odoo12
|
||||||
|
|
||||||
|
echo "### Remove old repostitories"
|
||||||
|
multipass exec $NAME -- sudo rm -r /home/ubuntu/odoo12
|
||||||
|
multipass exec $NAME -- sudo rm -r /home/ubuntu/custom/zdc-oca-addons
|
||||||
|
|
||||||
|
echo "### Clone new repositories"
|
||||||
|
multipass exec $NAME -- /usr/bin/git clone git@gitea.egroup.sk:development/zdc-odoo --depth 1 --branch master /home/ubuntu/odoo12
|
||||||
|
multipass exec $NAME -- /usr/bin/git clone git@gitea.egroup.sk:development/zdc-oca-addons --depth 1 --branch master /home/ubuntu/custom/zdc-oca-addons
|
||||||
|
|
||||||
|
echo "### Start odoo service"
|
||||||
|
multipass exec $NAME -- sudo systemctl start odoo12
|
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
NAME=$1
|
|
||||||
|
|
||||||
echo "### Create Ubuntu 18.04 LTS VM"
|
|
||||||
multipass launch bionic --name $NAME --cpus 2 --mem 2048M --disk 12G --cloud-init ./cloud-init/zdc-odoo-init.yaml
|
|
||||||
|
|
||||||
echo "### Install wkhtmltopdf"
|
|
||||||
multipass exec $NAME -- sudo wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb -O /tmp/wkhtmltox_0.12.6-1.bionic_amd64.deb
|
|
||||||
multipass exec $NAME -- sudo apt install /tmp/wkhtmltox_0.12.6-1.bionic_amd64.deb -y
|
|
||||||
|
|
||||||
echo "### Install Python Environment"
|
|
||||||
multipass exec $NAME -- sudo -u ubuntu /bin/bash /opt/odoo/venv-install.sh
|
|
||||||
|
|
||||||
echo "### Install OCB Odoo 12"
|
|
||||||
#multipass exec $NAME -- sudo -u ubuntu /usr/bin/git clone https://www.github.com/OCA/OCB --depth 1 --branch 12.0 /opt/odoo/odoo12
|
|
||||||
multipass exec $NAME -- sudo -u ubuntu /usr/bin/git clone https://gitea.egroup.sk/development/zdc-odoo --depth 1 --branch master /opt/odoo/odoo12
|
|
||||||
multipass exec $NAME -- sudo -u ubuntu /usr/bin/git clone https://gitea.egroup.sk/development/zdc-oca-addons --depth 1 --branch master /opt/odoo/custom-addons/zdc-oca-addons
|
|
||||||
multipass exec $NAME -- sudo systemctl restart odoo12
|
|
||||||
|
|
||||||
echo "### Create ZDC Template DB"
|
|
||||||
multipass exec $NAME -- sudo -u postgres wget https://gitea.egroup.sk/development/zdc-tools/raw/branch/master/db/zdc-template-db.sql -O /var/lib/postgresql/zdc-template-db.sql
|
|
||||||
multipass exec $NAME -- sudo -u postgres psql -c "CREATE DATABASE zdcbasedb10 WITH OWNER=ubuntu;"
|
|
||||||
multipass exec $NAME -- sudo -u postgres psql -d zdcbasedb10 -f /var/lib/postgresql/zdc-template-db.sql
|
|
||||||
|
|
||||||
|
|
||||||
echo "### Check VM"
|
|
||||||
multipass list | grep $NAME
|
|
||||||
URL_IP=`multipass info $NAME | grep IPv4 | sed -e 's/ //g' -e '/^$/d' | sed -e 's/IPv4://g' -e '/^$/d'`
|
|
||||||
|
|
||||||
echo "###"
|
|
||||||
echo "### Odoo database manager on $NAME server: http://$URL_IP:8069/web/database/selector"
|
|
Reference in New Issue
Block a user