From a000acbeadb538463de18ba136c2ac7fe7fb0f04 Mon Sep 17 00:00:00 2001 From: filesite Date: Sun, 24 Nov 2024 21:26:33 +0800 Subject: [PATCH] runtime/ dir permission improve --- docker-entrypoint.sh | 8 ++++++++ plugins/Common.php | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 287aa0b..c1d494a 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,8 +3,16 @@ theme=$1 if [ -d "/var/www/machete/themes/${theme}/" ]; then echo "Theme chosed [${theme}]." + ## 权限重新设置 + chown -R www-data:www-data /var/www/machete/runtime/ + ## 复制对应皮肤的配置文件 cd /var/www/machete/runtime/ + if [ ! -d cache ]; then + mkdir cache/ + chown -R www-data:www-data cache/ + fi + ## 避免容器重启后重新生成配置文件 if [ ! -f custom_config.json ]; then diff --git a/plugins/Common.php b/plugins/Common.php index 6738cc8..60c9398 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -541,9 +541,6 @@ Class Common { ); $jsonData = json_encode($cacheData, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $cacheDir = __DIR__ . '/../runtime/cache/'; - if (!is_dir($cacheDir)) { - mkdir($cacheDir, 0777, true); - } //子目录支持 if (!empty($cacheSubDir)) { @@ -551,7 +548,7 @@ Class Common { } if (!is_dir($cacheDir)) { - mkdir($cacheDir, 0755); + mkdir($cacheDir, 0755, true); } $cache_filename = "{$cacheDir}{$key}.json";