Files
zigbee-stack/scripts/clear_data.sh
John Lancaster e7a6a5ab1f script updates
2024-09-29 21:50:12 +00:00

35 lines
855 B
Bash
Executable File

#!/usr/bin/env bash
set -e
cleanup_except() {
local directory=$1
local except_file=$2
# Check if the directory exists
if [[ ! -d "$directory" ]]; then
echo "Directory does not exist: $directory"
return 1
fi
# Loop over each file in the directory
for file in "$directory"/*
do
if [[ "$(basename "$file")" != "$except_file" ]]; then
# Delete the file
rm -rf "$file"
echo "Removed $file"
fi
done
}
readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd)
docker compose down
cleanup_except "$REPO_DIR/mosquitto/config" mosquitto.conf
cleanup_except "$REPO_DIR/mosquitto/data" .gitkeep
cleanup_except "$REPO_DIR/mosquitto/log"
cleanup_except "$REPO_DIR/zigbee2mqtt" configuration.yaml