diff --git a/installer/Dockerfile b/installer/Dockerfile index 31fc8f7ae..5f50e8325 100644 --- a/installer/Dockerfile +++ b/installer/Dockerfile @@ -43,7 +43,7 @@ ENV CRM_VERSION=${CRM_VERSION} RUN echo "CRM_VERSION value during build: ${CRM_VERSION}" RUN echo -n "${CRM_VERSION}" > /tmp/CRM_VERSION -VOLUME [ "/opt/cordys/data", "/opt/cordys/logs", "/opt/cordys/conf" ] +VOLUME [ "/opt/cordys" ] RUN chmod 777 /shells/*.sh RUN chmod -R 777 /opt/cordys diff --git a/installer/shells/init-directories.sh b/installer/shells/init-directories.sh new file mode 100644 index 000000000..43d7f1eca --- /dev/null +++ b/installer/shells/init-directories.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +# 日志函数 +log() { + echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1" +} + +# 需要确保存在的目录 +DIRS=( + "/opt/cordys/data/mysql" + "/opt/cordys/conf/mysql" + "/opt/cordys/logs/cordys-crm" + "/opt/cordys/data/files" + "/opt/cordys/data/redis" + "/opt/cordys/conf/redis" +) + +log "开始检查并创建必要目录..." +for d in "${DIRS[@]}"; do + if [ ! -d "$d" ]; then + log "创建目录: $d" + mkdir -p "$d" + else + log "目录已存在: $d" + fi +done + +# 仅在目录存在时再设置权限 +if [ -d "/opt/cordys" ]; then + log "设置目录权限: /opt/cordys" + chmod -R 777 /opt/cordys +fi + +log "目录初始化完成。" \ No newline at end of file diff --git a/installer/shells/start-all.sh b/installer/shells/start-all.sh index dbfa6fab9..8aa257ef5 100644 --- a/installer/shells/start-all.sh +++ b/installer/shells/start-all.sh @@ -43,7 +43,7 @@ get_property() { # 主函数 main() { log_info "开始启动 Cordys CRM 环境..." - chmod -R 777 /opt/cordys + sh /shells/init-directories.sh # 检查MySQL配置并启动 mysqlEmbeddedEnabled=$(get_property "mysql.embedded.enabled") diff --git a/installer/shells/start-cordys.sh b/installer/shells/start-cordys.sh index aff6c59c9..f0733b8da 100644 --- a/installer/shells/start-cordys.sh +++ b/installer/shells/start-cordys.sh @@ -1,9 +1,6 @@ #!/bin/sh -mkdir -p /opt/cordys/logs/cordys-crm -mkdir -p /opt/cordys/data/files - -chmod -R 777 /opt/cordys +sh /shells/init-directories.sh export JAVA_CLASSPATH=/app:/app/lib/* export JAVA_MAIN_CLASS=cn.cordys.Application diff --git a/installer/shells/start-mysql.sh b/installer/shells/start-mysql.sh index ec64b2af9..9518b7530 100755 --- a/installer/shells/start-mysql.sh +++ b/installer/shells/start-mysql.sh @@ -1,9 +1,7 @@ #!/bin/sh +sh /shells/init-directories.sh cp -rf /opt/cordys/conf/mysql/my.cnf /etc/my.cnf.d/mariadb-server.cnf -mkdir -p /opt/cordys/data/mysql -mkdir -p /opt/cordys/conf/mysql -chmod -R 777 /opt/cordys chmod 644 /etc/mysql/conf.d/my.cnf diff --git a/installer/shells/start-redis.sh b/installer/shells/start-redis.sh index 62a9d446f..d607ae91a 100755 --- a/installer/shells/start-redis.sh +++ b/installer/shells/start-redis.sh @@ -6,11 +6,7 @@ log() { echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1" } -# 创建必要目录 -log "创建 Redis 数据目录..." -mkdir -p /opt/cordys/data/redis -mkdir -p /opt/cordys/conf/redis -chmod -R 777 /opt/cordys +sh /shells/init-directories.sh # 检查 Redis 密码 if [ -z "${REDIS_PASSWORD}" ]; then