#!/bin/bash

set -eu

source /etc/lwr/quota-configurator/quota.config
source /usr/lib/lwr-quota-configurator/quota-configurator-utils.sh

# Create user-storage-directory if not exists and set permissions
if [ ! -d $USER_STORAGE_PATH ]; then
    mkdir -p $USER_STORAGE_PATH
    chmod u=rwx,g=rwx+s,o=r $USER_STORAGE_PATH
    chown :$USER_STORAGE_GROUP $USER_STORAGE_PATH
fi

MOUNTPOINT=$(getMountPoint $USER_STORAGE_PATH)

# Reset all quotas before applying new configuration
clear_all_quotas "$MOUNTPOINT"

quotaon $MOUNTPOINT

run_quota_d
