Prevent accidentally mounting home folder as DATA_DIR

This commit is contained in:
Nick Sweeting 2024-11-03 16:40:23 -08:00 committed by GitHub
parent cad1be950b
commit 99ed97836f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -58,6 +58,13 @@ groupmod -o -g "${PGID:-$DETECTED_PGID}" "$ARCHIVEBOX_USER" > /dev/null 2>&1
export PUID="$(id -u archivebox)" export PUID="$(id -u archivebox)"
export PGID="$(id -g archivebox)" export PGID="$(id -g archivebox)"
# Check if user attempted to run it in the root of their home folder or hard drive (common mistake)
if [[ -d "$DATA_DIR/Documents" || -d "$DATA_DIR/.config" || -d "$DATA_DIR/usr" ]]; then
echo -e "\n[X] ERROR: ArchiveBox was run from inside a home folder"
echo -e " Make sure you are inside an existing collection directory or a new empty directory and try again"
exit 3
fi
# Check the permissions of the data dir (or create if it doesn't exist) # Check the permissions of the data dir (or create if it doesn't exist)
if [[ -d "$DATA_DIR/archive" ]]; then if [[ -d "$DATA_DIR/archive" ]]; then
if touch "$DATA_DIR/archive/.permissions_test_safe_to_delete" 2>/dev/null; then if touch "$DATA_DIR/archive/.permissions_test_safe_to_delete" 2>/dev/null; then