From 08dc707b94e631ce642269ba60457bd8248e1992 Mon Sep 17 00:00:00 2001 From: Yenthe Van Ginneken Date: Sun, 29 Dec 2019 13:51:32 +0100 Subject: [PATCH] [ADD] odoo_install: generate random password --- odoo_install.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/odoo_install.sh b/odoo_install.sh index 86c7967..7e519a4 100644 --- a/odoo_install.sh +++ b/odoo_install.sh @@ -27,8 +27,10 @@ OE_PORT="8069" OE_VERSION="13.0" # Set this to True if you want to install the Odoo enterprise version! IS_ENTERPRISE="False" -# set the superadmin password +# Set the superadmin password - if GENERATE_RANDOM_PASSWORD is set to "True" we will automatically generate a random password, otherwise we use this one OE_SUPERADMIN="admin" +# Set to "True" to generate a random password, "False" to use the variable in OE_SUPERADMIN +GENERATE_RANDOM_PASSWORD="True" OE_CONFIG="${OE_USER}-server" ## @@ -143,6 +145,10 @@ echo -e "* Create server config file" sudo touch /etc/${OE_CONFIG}.conf echo -e "* Creating server config file" sudo su root -c "printf '[options] \n; This is the password that allows database operations:\n' >> /etc/${OE_CONFIG}.conf" +if [ $GENERATE_RANDOM_PASSWORD = "True" ]; then + echo -e "* Generating random admin password" + OE_SUPERADMIN=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) +fi sudo su root -c "printf 'admin_passwd = ${OE_SUPERADMIN}\n' >> /etc/${OE_CONFIG}.conf" sudo su root -c "printf 'xmlrpc_port = ${OE_PORT}\n' >> /etc/${OE_CONFIG}.conf" sudo su root -c "printf 'logfile = /var/log/${OE_USER}/${OE_CONFIG}.log\n' >> /etc/${OE_CONFIG}.conf" @@ -247,6 +253,7 @@ echo "User service: $OE_USER" echo "User PostgreSQL: $OE_USER" echo "Code location: $OE_USER" echo "Addons folder: $OE_USER/$OE_CONFIG/addons/" +echo "Password superadmin (database): $OE_SUPERADMIN" echo "Start Odoo service: sudo service $OE_CONFIG start" echo "Stop Odoo service: sudo service $OE_CONFIG stop" echo "Restart Odoo service: sudo service $OE_CONFIG restart"