diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /setup/redhat | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'setup/redhat')
| -rw-r--r-- | setup/redhat/install.sh | 4 | ||||
| -rw-r--r-- | setup/redhat/postinstall.sh | 62 |
2 files changed, 66 insertions, 0 deletions
diff --git a/setup/redhat/install.sh b/setup/redhat/install.sh new file mode 100644 index 00000000..d02f6f28 --- /dev/null +++ b/setup/redhat/install.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -e +ABI=$(rpm -q --provides python3 | awk '/abi/ {print $NF}') +python3 setup.py install --prefix=/usr --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES --install-lib usr/lib/python${ABI}/site-packages/ diff --git a/setup/redhat/postinstall.sh b/setup/redhat/postinstall.sh new file mode 100644 index 00000000..82d31f09 --- /dev/null +++ b/setup/redhat/postinstall.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +set -e + +ODOO_CONFIGURATION_DIR=/etc/odoo +ODOO_CONFIGURATION_FILE=$ODOO_CONFIGURATION_DIR/odoo.conf +ODOO_DATA_DIR=/var/lib/odoo +ODOO_GROUP="odoo" +ODOO_LOG_DIR=/var/log/odoo +ODOO_LOG_FILE=$ODOO_LOG_DIR/odoo-server.log +ODOO_USER="odoo" +ABI=$(rpm -q --provides python3 | awk '/abi/ {print $NF}') + +if ! getent passwd | grep -q "^odoo:"; then + groupadd $ODOO_GROUP + adduser --system --no-create-home $ODOO_USER -g $ODOO_GROUP +fi +# Register "$ODOO_USER" as a postgres user with "Create DB" role attribute +su - postgres -c "createuser -d -R -S $ODOO_USER" 2> /dev/null || true +# Configuration file +mkdir -p $ODOO_CONFIGURATION_DIR +# can't copy debian config-file as addons_path is not the same +if [ ! -f $ODOO_CONFIGURATION_FILE ] +then + echo "[options] +; This is the password that allows database operations: +; admin_passwd = admin +db_host = False +db_port = False +db_user = $ODOO_USER +db_password = False +addons_path = /usr/lib/python${ABI}/site-packages/odoo/addons +" > $ODOO_CONFIGURATION_FILE + chown $ODOO_USER:$ODOO_GROUP $ODOO_CONFIGURATION_FILE + chmod 0640 $ODOO_CONFIGURATION_FILE +fi +# Log +mkdir -p $ODOO_LOG_DIR +chown $ODOO_USER:$ODOO_GROUP $ODOO_LOG_DIR +chmod 0750 $ODOO_LOG_DIR +# Data dir +mkdir -p $ODOO_DATA_DIR +chown $ODOO_USER:$ODOO_GROUP $ODOO_DATA_DIR + +INIT_FILE=/lib/systemd/system/odoo.service +touch $INIT_FILE +chmod 0700 $INIT_FILE +cat << EOF > $INIT_FILE +[Unit] +Description=Odoo Open Source ERP and CRM +After=network.target + +[Service] +Type=simple +User=odoo +Group=odoo +ExecStart=/usr/bin/odoo --config $ODOO_CONFIGURATION_FILE --logfile $ODOO_LOG_FILE +KillMode=mixed + +[Install] +WantedBy=multi-user.target +EOF |
