Skip to content

Commit

Permalink
feat: prepare paths (#2726)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored May 31, 2024
1 parent b974984 commit 38d8927
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/usr/local/containerbase/utils/filesystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/bash/filesystem.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 38d8927

Please sign in to comment.