0

我正在使用 ubuntu 16.04 OS 作为 VM。

在创建容器时,我在 entrpoint.sh 中有一些命令无法正常工作或行为不符合预期,但是当我在容器内手动运行时,相同的命令正在工作,准确地说,下面是我的简单 linux cp命令,它从源代码递归复制到目的地并解压缩命令。

在我的 entrypoint.sh 中,我有三个命令:

  cd /tmp/localization/Tpae7610
  unzip \*.zip
  cp -r /tmp/localization/Tpae7610/*  /home/db2inst1/maximo/

最后两个命令在容器启动时不起作用,当我说它不起作用时,这意味着它没有给出任何错误,但没有按预期将源内容复制到目的地,也没有解压缩 .zip 文件

注意:但是当我在容器内手动运行时,相同的命令会按预期工作。

入口点.sh

#!/bin/bash
sysctl -w kernel.shmmni=1024
sysctl -w kernel.shmall=2097152
sysctl -w kernel.msgmnb=65536
sysctl -w kernel.msgmax=65536
sysctl -w kernel.msgmni=4096
sysctl -w kernel.shmmax=4294967296

#set -e
#
#   Initialize DB2 instance in a Docker container
#
# # Authors:
#   * 
#
# 
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
mkdir -p /db2fs
chown db2inst1:db2iadm1 /db2fs
chmod -R 755 /db2fs

#cp /tmp/maxinst.sh /home/db2inst1/maximo/Maximo-7.6-CD/tools/maximo/maxinst.sh

if [ -z "$DB2INST1_PASSWORD" ]; then
  echo ""
  echo >&2 'error: DB2INST1_PASSWORD not set'
  echo >&2 'Did you forget to add -e DB2INST1_PASSWORD=... ?'
  exit 1
else
  echo "db2inst1:$DB2INST1_PASSWORD" | chpasswd
fi

if [ -z "$LICENSE" ];then
   echo ""
   echo >&2 'error: LICENSE not set'
   echo >&2 "Did you forget to add '-e LICENSE=accept' ?"
   exit 1
fi

if [ "${LICENSE}" != "accept" ];then
   echo ""
   echo >&2 "error: LICENSE not set to 'accept'"
   echo >&2 "Please set '-e LICENSE=accept' to accept License before use the DB2 software contained in this image."
   exit 1
fi

if [[ $1 = "db2start" ]]; then
    echo "Performing botc database start"
    if [ ! -d /db2fs/db2inst1 ]; then
      echo "Database location does not exist, creating database"
      chown -R db2inst1:db2iadm1 /maxdb7605
      chown -R db2inst1:db2iadm1 /home/db2inst1/maximo 
      find /maxdb7605 -type d -exec chmod 755 \{\} \;
      find /maxdb7605 -type f -exec chmod 644 \{\} \;
      cd /home/db2inst1/maximo
      #unzip -o tools.zip && rm tools.zip
      #unzip -o applications.zip && rm applications.zip 
      set -x 
      cd /home/db2inst1/maximo/tools
      if [ ! -f java ]; then
         ln -s /home/db2inst1/sqllib/java  java
      fi
      su - db2inst1 <<EOH
      db2start
      db2 create database maxdb76 on /db2fs dbpath on /db2fs using codeset UTF-8 territory us pagesize 32 K
      db2 connect to maxdb76
      db2 create bufferpool MAXBUFFPOOL pagesize 32K
      db2 grant connect on database to user maximo
      db2 GRANT DBADM,SECADM, CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,IMPLICIT_SCHEMA,LOAD,CREATE_EXTERNAL_ROUTINE,QUIESCE_CONNECT ON DATABASE TO USER maximo
      db2 GRANT USAGE on WORKLOAD SYSDEFAULTUSERWORKLOAD TO USER maximo;
      db2 create schema maximo authorization maximo
      db2 create regular tablespace MAXDATA pagesize 32k managed by automatic storage extentsize 16 overhead 12.67 prefetchsize 16 transferrate 0.18 bufferpool MAXBUFFPOOL dropped table recovery on NO FILE SYSTEM CACHING
      db2 grant use of tablespace MAXDATA to user maximo
      db2 update db cfg using LOGFILSIZ 5000
      db2 update db cfg using LOGPRIMARY 50
      db2 update db cfg using LOGSECOND 50

      db2 connect reset
      db2stop force
      db2start

      cd /maxdb7605
      db2set DB2CODEPAGE=1208
      db2 connect to maxdb76
      db2 -t -f /maxdb7605/dbschema.sql
      db2 -t -f /maxdb7605/dev_grants.sql
      db2move maxdb76 LOAD -u maximo -p maximo -l lobs
      db2 connect to maxdb76 user maximo using maximo
      db2 -x "select 'values nextval for MAXIMO.',sequencename,';' from maxsequence" > /maxdb7605/sequence_update.sql
      db2 -t -f /maxdb7605/sequence_update.sql
      db2 connect reset
EOH
      rm -rf /maxdb7605

      set +x
      nohup /usr/sbin/sshd -D 2>&1 > /dev/null &
      cd /home/db2inst1/maximo/tools/maximo
      chmod +x TDToolkit.sh
      chmod +x updatedb.sh
      dos2unix TDToolkit.sh
      dos2unix updatedb.sh
      ./updatedb.sh
      export JAVA_HOME=/opt/ibm/java-x86_64-70
      export JRE_HOME=/opt//home/db2inst1/maximoibm/java-x86_64-70/jre
      export PATH=${JAVA_HOME}/bin:$PATH

      cd /
      cd /tmp/localization/Tpae7610
      unzip \*.zip
      cp -a /tmp/localization/Tpae7610/*  /home/db2inst1/maximo/

      cd /tmp/localization/Lightning7604
      unzip \*.zip
      cp -a /tmp/localization/Lightning7604/*  /home/db2inst1/maximo/

      cd /tmp/localization/BOTC7610
      unzip \*.zip
      cp -a /tmp/localization/BOTC7610/* /home/db2inst1/maximo/

      cd /tmp
      #remove localization folder from tmp folder
      rm -rf localization

      cd /home/db2inst1/maximo/tools/maximo
      #./TDToolkit.sh -addlangPT -useexpander
      #./TDToolkit.sh -addlangJA -useexpander
      #./TDToolkit.sh -addlangDE -useexpander
      #./TDToolkit.sh -addlangIT -useexpander
      #./TDToolkit.sh -addlangFR -useexpander
      #./TDToolkit.sh -addlangES -useexpander

      #./TDToolkit.sh -pmpupdatenxtgenui -useexpander 
      # ./TDToolkit.sh -pmpupdatez_botc -useexpander

      chmod -R 777 /home/db2inst1/maximo/tools/maximo/log
      #healthcheck looks for this file to indicate the container is initialized
      touch /tmp/container_started
      while true; do sleep 1000; done
      exec "/bin/bash"
    #statements
  else
    su - db2inst1 <<EOH
    db2start
    db2 catalog db maxdb76 on /db2fs
    db2 terminate
    db2 connect to maxdb76
EOH
    touch /tmp/container_started
    while true; do sleep 1000; done
    exec "/bin/bash"
  fi

  sleep 10
fi
4

1 回答 1

0

/tmp/localization/Tpae7610/ 目录下的文件没有权限。

尝试命令 cp -v (详细将显示复制的文件)rm -rf localization在脚本中注释。然后调试脚本。

于 2018-03-29T10:28:12.227 回答