#!/usr/bin/env bash function reset() { if [[ ! -d "$(getValueByKey 'PODMAN_DIRECTORY')/${1}" ]]; then log e "Directory '${1}' does not exist!" exit 1 fi local dir="$(getValueByKey 'PODMAN_DIRECTORY')/${1}" local datapack_dir="${dir}/data/world/datapacks" while [[ ! ${deleteDataDir} =~ [YyNn] ]]; do read -p "Do you want to reset the complete data dir located in ${dir}/data ? (This is an unrecoverable process): " deleteDataDir case "${deleteDataDir}" in "N"|"n") log e "Aborted by user!" exit 1 ;; esac done local backedup=false if [[ -n $(find "${datapack_dir}" -maxdepth 1 -type f) ]]; then while [[ ! ${backupDatapacksAns} =~ [YyNn] ]]; do read -p "Do you want to backup the datapack .zip found in ${datapack_dir} ?: " backupDatapacksAns case "${backupDatapacksAns}" in "Y"|"y") local backedup=true local tempdir=$(mktemp -d /tmp/pms-cli.XXXXXX) mv ${datapack_dir}/*.zip ${tempdir}/ ;; esac done fi rm -rf "${dir}/data" mkdir -p "${dir}/data/world/datapacks" if [[ "${backedup}" == true ]]; then while [[ ! ${restoreDatapacksAns} =~ [YyNn] ]]; do read -p "You have some backed up datapack .zip in ${tempdir}. Do you want to restore them now?: " restoreDatapacksAns case "${restoreDatapacksAns}" in "Y"|"y") mv ${tempdir}/*.zip "${dir}/data/world/datapacks/" rm -rf "${tempdir}" ;; esac done fi log s "Server '${1}' resetted!" }