From 79bedc4e7fb78659f650900c0ddb4a016e20268e Mon Sep 17 00:00:00 2001 From: Elico Corp Date: Fri, 17 Nov 2017 00:00:37 +0800 Subject: [PATCH 1/6] Update OCB 8.0 commit ID: d8ef27ded9a0400cdb25fd2d9919f0e46c774a0d --- OCB_COMMIT_ID | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OCB_COMMIT_ID b/OCB_COMMIT_ID index 0537ebb7..198a0326 100644 --- a/OCB_COMMIT_ID +++ b/OCB_COMMIT_ID @@ -1 +1 @@ -70e35cb40c578e0a4c0879495e932da6fd2a9829 +d8ef27ded9a0400cdb25fd2d9919f0e46c774a0d From b8508fd2d441ecc3e295b911e6f1310b2c8a1ddc Mon Sep 17 00:00:00 2001 From: Elico Corp Date: Sat, 18 Nov 2017 00:00:32 +0800 Subject: [PATCH 2/6] Update OCB 8.0 commit ID: 21408fc9e2a91f24df05209e99deef993449b312 --- OCB_COMMIT_ID | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OCB_COMMIT_ID b/OCB_COMMIT_ID index 198a0326..0c26dc99 100644 --- a/OCB_COMMIT_ID +++ b/OCB_COMMIT_ID @@ -1 +1 @@ -d8ef27ded9a0400cdb25fd2d9919f0e46c774a0d +21408fc9e2a91f24df05209e99deef993449b312 From 7e59fe358254d31e6761866cffea778837454f83 Mon Sep 17 00:00:00 2001 From: Elico Corp Date: Wed, 22 Nov 2017 11:11:23 +0800 Subject: [PATCH 3/6] Update odoo/odoo 8.0 commit ID: 837bd786729123ac8def9d42ca657398e8688196 --- ODOO_COMMIT_ID | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ODOO_COMMIT_ID b/ODOO_COMMIT_ID index 51a47696..2c3fd34d 100644 --- a/ODOO_COMMIT_ID +++ b/ODOO_COMMIT_ID @@ -1 +1 @@ -cf8577b9d0bbe6f02ed4e88e47ab3097683d519d +837bd786729123ac8def9d42ca657398e8688196 From b1b8da0132026acda40bd79bd8dd757a8c392a60 Mon Sep 17 00:00:00 2001 From: Elico Corp Date: Tue, 12 Dec 2017 00:02:15 +0800 Subject: [PATCH 4/6] Update odoo/odoo 8.0 commit ID: 515a5ed900194050930d27d06f237a7c2e627354 --- ODOO_COMMIT_ID | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ODOO_COMMIT_ID b/ODOO_COMMIT_ID index 2c3fd34d..f5805689 100644 --- a/ODOO_COMMIT_ID +++ b/ODOO_COMMIT_ID @@ -1 +1 @@ -837bd786729123ac8def9d42ca657398e8688196 +515a5ed900194050930d27d06f237a7c2e627354 From bed5e133c2485dfa8144a5baf4fb01b14704e7d5 Mon Sep 17 00:00:00 2001 From: Elico Corp Date: Thu, 31 May 2018 00:01:40 +0800 Subject: [PATCH 5/6] Update odoo/odoo 8.0 commit ID: 4045e4fe66fc18f3e223a99c781a08a17ee49f60 --- ODOO_COMMIT_ID | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ODOO_COMMIT_ID b/ODOO_COMMIT_ID index f5805689..f8caa8c5 100644 --- a/ODOO_COMMIT_ID +++ b/ODOO_COMMIT_ID @@ -1 +1 @@ -515a5ed900194050930d27d06f237a7c2e627354 +4045e4fe66fc18f3e223a99c781a08a17ee49f60 From 15f3f3b6ae63540b129e7a1ade91d1f97c9c3ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Maillard?= Date: Fri, 22 Jun 2018 12:32:25 +0800 Subject: [PATCH 6/6] Fix Linux user mapping issue on container restart When restarting the Odoo container, the target user created for user mapping already exists. The code to handle this case was not working. There was some side-effects as well for the private SSH key setup used for fetching private GitHub repos which are also fixed in this commit. --- bin/boot | 77 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 33 deletions(-) mode change 100755 => 100644 bin/boot diff --git a/bin/boot b/bin/boot old mode 100755 new mode 100644 index 2fc9ca6d..c7d9a673 --- a/bin/boot +++ b/bin/boot @@ -73,44 +73,49 @@ function _update_odoo_conf_params { } function _setup_ssh_key { - # Create SSH config folder in $HOME folder of Odoo target user + # SSH config folder in $HOME folder of target user ssh_folder=$( getent passwd "$odoo_user" | cut -d: -f6 )/.ssh - sudo -i -u "$odoo_user" mkdir "$ssh_folder" - # Copy SSH private key from /opt/odoo/ssh - sudo -i -u "$odoo_user" cp /opt/odoo/ssh/id_rsa "$ssh_folder" + # SSH config folder already exists when container has been restarted + if [ ! -d "$ssh_folder" ]; then + # Create SSH config folder + sudo -i -u "$odoo_user" mkdir "$ssh_folder" - echo $log_src[`date +%F.%H:%M:%S`]' Scanning GitHub key...' - # Hide ssh-keyscan stderr output since it's actually log message - ssh-keyscan github.com 2> /dev/null | \ - sudo -i -u "$odoo_user" tee "$ssh_folder/known_hosts" > /dev/null + # Copy SSH private key from /opt/odoo/ssh + sudo -i -u "$odoo_user" cp /opt/odoo/ssh/id_rsa "$ssh_folder" - # Bind SSH key to GitHub host - echo "host github.com - HostName github.com - User git - IdentityFile $ssh_folder/id_rsa" | \ - sudo -i -u "$odoo_user" tee "$ssh_folder/config" > /dev/null + echo $log_src[`date +%F.%H:%M:%S`]' Scanning GitHub key...' + # Hide ssh-keyscan stderr output since it's actually log message + ssh-keyscan github.com 2> /dev/null | \ + sudo -i -u "$odoo_user" tee "$ssh_folder/known_hosts" > /dev/null - # Secure SSH key - chmod 400 "$ssh_folder/id_rsa" + # Bind SSH key to GitHub host + echo "host github.com + HostName github.com + User git + IdentityFile $ssh_folder/id_rsa" | \ + sudo -i -u "$odoo_user" tee "$ssh_folder/config" > /dev/null + + # Secure SSH key + chmod 400 "$ssh_folder/id_rsa" + fi } function _download_addons { # 2 reasons to download extra addons: # 1) ENV variable ADDONS_REPO is defined # 2) There's a file called `oca_dependencies.txt` at the root of extra addons folder - if [ "$ADDONS_REPO" -o -a /opt/odoo/additional_addons/oca_dependencies.txt ]; then + if [ "$ADDONS_REPO" -o -f /opt/odoo/additional_addons/oca_dependencies.txt ]; then # Git config for target user sudo -i -u "$odoo_user" git config --global user.email "webmaster@elico-corp.com" sudo -i -u "$odoo_user" git config --global user.name "Elico Corp - Odoo Docker" # Setup SSH key - if [ -a /opt/odoo/ssh/id_rsa ]; then + if [ -f /opt/odoo/ssh/id_rsa ]; then _setup_ssh_key fi - # Always fetch dependencies unless specified + # Fetch dependencies by default if [[ -z "$FETCH_OCA_DEPENDENCIES" ]]; then FETCH_OCA_DEPENDENCIES=True fi @@ -140,8 +145,10 @@ function _host_user_mapping { # Create target user if [ "$exists" == "0" ]; then - echo $log_src[`date +%F.%H:%M:%S`]' Creating target Odoo user...' + # Odoo user is now the target Odoo user odoo_user="$TARGET_USER_NAME" + + echo $log_src[`date +%F.%H:%M:%S`]' Creating target Odoo user...' adduser --uid "$TARGET_UID" --disabled-login --gecos "" --quiet \ "$odoo_user" @@ -149,19 +156,23 @@ function _host_user_mapping { # of /opt/odoo usermod -a -G odoo "$odoo_user" else - # Target user already exists in the following cases: - # 1) Mapping with the same UID as odoo, OK - # 2) Target user has already been created (e.g. container has been - # restarted), OK - # 3) Mapping with another existing user (e.g. root, etc.), not OK + # Check whether trying to map with the same UID as `odoo` user odoo_user_id=$( id -u "$odoo_user" ) - target_uid_name=$( getent passwd "$TARGET_UID" | cut -d: -f1 ) - if [ "$TARGET_UID" -ne "$odoo_user_id" ] && \ - [ "$TARGET_USER_NAME" != "$target_uid_name" ]; then - echo $log_src[`date +%F.%H:%M:%S`]' ERROR: Cannot create target' \ - 'user as target UID already exists.' - exit 1 + if [ "$TARGET_UID" -ne "$odoo_user_id" ]; then + + # Check whether trying to map with an existing user other than the + # target user + target_uid_name=$( getent passwd "$TARGET_UID" | cut -d: -f1 ) + + if [ "$TARGET_USER_NAME" != "$target_uid_name" ]; then + echo $log_src[`date +%F.%H:%M:%S`]' ERROR: Cannot create' \ + 'target user as target UID already exists.' + else + # Target user has already been created (e.g. container has + # been restarted) + odoo_user="$TARGET_USER_NAME" + fi fi fi } @@ -174,8 +185,8 @@ function start { fi # If the folders mapped to the volumes didn't exist, Docker has created - # them with root instead of the target Odoo user. Making sure to give back - # the ownership to the corresponding host user. + # them with root instead of the target user. Making sure to give back the + # ownership to the corresponding host user. _ensure_odoo_user_owns_volumes echo $log_src[`date +%F.%H:%M:%S`]' Checking special requirements...'