2022-06-03 10:56:50 -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
|
|
|
|
|
|
|
|
|
|
volume_dir="$1"
|
|
|
|
|
|
|
|
|
|
readonly test_file="${volume_dir}/.chown-test"
|
|
|
|
|
|
|
|
|
|
mkdir -p "${volume_dir}"
|
|
|
|
|
rm -f "${test_file}" # clean up any from previous run
|
|
|
|
|
|
2022-06-08 11:25:20 -07:00
|
|
|
if [[ -n $(ls -A "${volume_dir}") ]]; then
|
2022-06-03 10:56:50 -07:00
|
|
|
echo "volume dir is not empty"
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
touch "${test_file}"
|
|
|
|
|
if ! chown yellowtent:yellowtent "${test_file}"; then
|
|
|
|
|
echo "chown does not work"
|
|
|
|
|
exit 3
|
|
|
|
|
fi
|
|
|
|
|
rm -f "${test_file}"
|
|
|
|
|
rm -r "${volume_dir}" # will get recreated by the local storage addon
|
|
|
|
|
|