mirror of
https://github.com/dokku/dokku.git
synced 2026-09-02 12:10:09 +02:00
`storage:create` and `storage:set` accept a `--mode` flag that sets the octal permissions of a docker-local host directory, and `storage:destroy` accepts a `--destroy-host-dir` flag that removes the directory along with its contents. A docker-local entry also honors `--reclaim-policy Delete` at destroy time now, matching how that policy governs a k3s PersistentVolume. Both are limited to the default `/var/lib/dokku/data/storage/<name>` location, the same restriction `--chown` already carries. `storage:set` applies `--chown` and `--mode` to the directory rather than only recording them.
34 lines
724 B
Bash
Executable File
34 lines
724 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eo pipefail
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
|
|
main() {
|
|
declare desc="removes a storage directory and its contents"
|
|
declare DIRECTORY="$1"
|
|
|
|
if [[ -z "$DIRECTORY" ]]; then
|
|
echo " ! Please specify a directory to destroy" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! "$DIRECTORY" =~ ^[A-Za-z0-9\\_-]+$ ]]; then
|
|
echo " ! Directory can only contain the following set of characters: [A-Za-z0-9_-]" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
local storage_path="${DOKKU_LIB_ROOT}/data/storage/$DIRECTORY"
|
|
|
|
if [[ ! -e "$storage_path" ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [[ ! -d "$storage_path" ]]; then
|
|
echo " ! $storage_path exists but is not a directory" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
rm -rf "$storage_path"
|
|
}
|
|
|
|
main "$@"
|