#!/bin/bash
source .env
docker-compose down
clean_up(){
	docker volume rm nextcloud_files
	docker volume rm nextcloud_db
	docker volume rm nextcloud_redis

	cd $DATA_VOLUME_ROOT
	pwd
	sudo rm -Rf ./data
	mkdir ./data
	mkdir ./data/files
	cd $DB_VOLUME_ROOT
	pwd
	sudo rm -Rf ./db
	mkdir ./db
	cd $REDIS_VOLUME_ROOT
	pwd
	sudo rm -Rf ./redis
	mkdir ./redis
 	docker ps
 	docker volume ls
}

while true; do
    read -p "Do you wish to proceed. This will ERASE all the data on $DATA_VOLUME_ROOT?" yn
    case $yn in
        [Yy]* ) clean_up; break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done

