feat: enhance volume management with support for multiple volumes and improved API endpoints
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
9b0c3aa190
commit
e7c0b56473
3 changed files with 133 additions and 41 deletions
46
panelctl.sh
46
panelctl.sh
|
|
@ -536,24 +536,6 @@ cmd_volume_clear() {
|
|||
log info "volume data cleared for app '${name}'"
|
||||
}
|
||||
|
||||
cmd_volume_clear() {
|
||||
local name="$1"
|
||||
validate_name "${name}"
|
||||
load_app "${name}"
|
||||
|
||||
log info "clearing volume data for app '${name}'"
|
||||
run_compose -f "${APP_COMPOSE_FILE}" down --remove-orphans 2>/dev/null || true
|
||||
|
||||
local data_dir="${APP_VOLUME_DIR}/data"
|
||||
if [[ -d "${data_dir}" ]]; then
|
||||
rm -rf "${data_dir:?}"/*
|
||||
rm -rf "${data_dir:?}"/.[!.]* 2>/dev/null || true
|
||||
fi
|
||||
mkdir -p "${APP_VOLUME_DIR}/data"
|
||||
|
||||
log info "volume data cleared for app '${name}'"
|
||||
}
|
||||
|
||||
cmd_restore() {
|
||||
local name="$1"
|
||||
local backup_file="$2"
|
||||
|
|
@ -590,6 +572,26 @@ cmd_restore() {
|
|||
log info "run 'panelctl deploy ${name}' to start the app'"
|
||||
}
|
||||
|
||||
cmd_inspect_volumes() {
|
||||
local name="$1"
|
||||
validate_name "${name}"
|
||||
load_app "${name}"
|
||||
|
||||
echo "default|${APP_VOLUME_DIR}/data"
|
||||
|
||||
local podman_bin=""
|
||||
if command -v podman >/dev/null 2>&1; then
|
||||
podman_bin="$(command -v podman)"
|
||||
elif [[ -x /run/current-system/sw/bin/podman ]]; then
|
||||
podman_bin="/run/current-system/sw/bin/podman"
|
||||
fi
|
||||
|
||||
if [[ -n "${podman_bin}" ]]; then
|
||||
"${podman_bin}" volume ls --filter label=com.docker.compose.project="${name}" --format '{{.Name}}|{{.Mountpoint}}' 2>/dev/null || true
|
||||
"${podman_bin}" volume ls --filter label=io.podman.compose.project="${name}" --format '{{.Name}}|{{.Mountpoint}}' 2>/dev/null || true
|
||||
fi | sort -u | grep -v '^$'
|
||||
}
|
||||
|
||||
cmd_list() {
|
||||
ensure_base_dirs
|
||||
local found=0
|
||||
|
|
@ -668,6 +670,14 @@ main() {
|
|||
[[ $# -eq 3 ]] || fail "usage: panelctl restore <name> <backup-file>"
|
||||
cmd_restore "$2" "$3"
|
||||
;;
|
||||
volume-clear)
|
||||
[[ $# -eq 2 ]] || fail "usage: panelctl volume-clear <name>"
|
||||
cmd_volume_clear "$2"
|
||||
;;
|
||||
inspect-volumes)
|
||||
[[ $# -eq 2 ]] || fail "usage: panelctl inspect-volumes <name>"
|
||||
cmd_inspect_volumes "$2"
|
||||
;;
|
||||
list)
|
||||
[[ $# -eq 1 ]] || fail "usage: panelctl list"
|
||||
cmd_list
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue