From 38d8927a5d872ab37b70ebbea73bfd2a78c1b28f Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Fri, 31 May 2024 13:43:46 +0200 Subject: [PATCH] feat: prepare paths (#2726) --- .../local/containerbase/utils/filesystem.sh | 20 +++++++++++++++++++ test/bash/filesystem.bats | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/src/usr/local/containerbase/utils/filesystem.sh b/src/usr/local/containerbase/utils/filesystem.sh index 2e725cd5c8..35dd98f923 100644 --- a/src/usr/local/containerbase/utils/filesystem.sh +++ b/src/usr/local/containerbase/utils/filesystem.sh @@ -62,6 +62,12 @@ function setup_directories () { # contains the certificates for the tools # shellcheck disable=SC2174 mkdir -p -m 775 "$(get_ssl_path)" + # contains the caches for the tools + # shellcheck disable=SC2174 + mkdir -p -m 775 "$(get_cache_path)" + # contains the home for the tools + # shellcheck disable=SC2174 + mkdir -p -m 775 "$(get_home_path)" # if the bin path exists and does not have 775, force it if [ "$(stat --format '%a' "$(get_bin_path)")" -ne 775 ]; then @@ -126,6 +132,20 @@ function get_ssl_path () { echo "${install_dir}/ssl" } +# Gets the path to the cache folder +function get_cache_path () { + local install_dir + install_dir=$(get_install_dir) + echo "${install_dir}/cache" +} + +# Gets the path to the home folder +function get_home_path () { + local install_dir + install_dir=$(get_install_dir) + echo "${install_dir}/home" +} + # will get the correct umask based on the caller id function get_umask () { if [ "$(is_root)" -eq 0 ]; then diff --git a/test/bash/filesystem.bats b/test/bash/filesystem.bats index b09e3d3c2a..f9dd9324a0 100644 --- a/test/bash/filesystem.bats +++ b/test/bash/filesystem.bats @@ -126,6 +126,10 @@ teardown() { assert [ "$(stat --format '%a' "${BIN_DIR}")" -eq 775 ] assert [ -d "${install_dir}/env.d" ] assert [ "$(stat --format '%a' "${install_dir}/env.d")" -eq 775 ] + assert [ -d "${install_dir}/cache" ] + assert [ "$(stat --format '%a' "${install_dir}/cache")" -eq 775 ] + assert [ -d "${install_dir}/home" ] + assert [ "$(stat --format '%a' "${install_dir}/home")" -eq 775 ] } @test "creates a folder with correct permissions" {