2015-07-20 00:09:47 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
|
|
if [[ ${EUID} -ne 0 ]]; then
|
|
|
|
|
echo "This script should be run as root." > /dev/stderr
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
|
echo "No arguments supplied"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ "$1" == "--check" ]]; then
|
|
|
|
|
echo "OK"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2019-01-13 19:18:06 -08:00
|
|
|
volume_dir="$1"
|
2017-09-07 15:43:57 -07:00
|
|
|
|
2019-01-13 19:18:06 -08:00
|
|
|
if [[ "${BOX_ENV}" == "test" ]]; then
|
|
|
|
|
# be careful not to nuke some random directory when testing
|
|
|
|
|
[[ "${volume_dir}" != *"./cloudron_test/"* ]] && exit 1
|
2017-09-07 15:43:57 -07:00
|
|
|
fi
|
|
|
|
|
|
2019-01-17 14:55:27 -08:00
|
|
|
rm -rf "${volume_dir}"/*
|
|
|
|
|
# mount points cannot be deleted
|
|
|
|
|
rmdir "${volume_dir}" || true
|