diff --git a/debian/alternc.config b/debian/alternc.config index c9bd9e27..328bd7cf 100644 --- a/debian/alternc.config +++ b/debian/alternc.config @@ -27,6 +27,24 @@ function valid_ip() } +function get_first_existing_dir() { + # Prend en premier parametre un chemin + # Retourne le répertoire parent existant le plus "proche" + # Exemple: on lui donne /var/www/alternc/gerard/dupont/ mais + # seul /var/www/alternc existe, ca répond /var/www/alternc + dir="$1" + if [ -z "$dir" ] ; then + return 0 + fi + if ! test -d "$dir" ; then + get_first_existing_dir "$(dirname "$dir")" + else + echo "$dir" + fi +} + + + #checking mysql connectivity and updating local.sh variables accordingly check_mysql(){ @@ -183,24 +201,28 @@ while [ "$QUEST_STATE" != 0 -a "$QUEST_STATE" != 11 ]; do db_get alternc/alternc_location LOCATION="$RET" - #checking acl and quota activation, does't work with NFS yet. should now work with lxc - MOUNT_POINT=$(df -P ${LOCATION%/*} | tail -n 1 | awk '{print $6}') + #checking acl and quota activation. + basedir=`get_first_existing_dir "$LOCATION"`; + MOUNT_POINT=$(df -P ${basedir} | tail -n 1 | awk '{print $6}') + #we get the first existing dir + aclcheckfile="$basedir/test-acl" + touch "$aclcheckfile" + setfacl -m u:root:rwx "$aclcheckfile" 2>/dev/null - # Get the mount options for the path: (warning, / may have multiple declarations, take the last one only : - MOUNT_OPTS=$(awk '$2=="'$MOUNT_POINT'" { print $4 }' /proc/mounts | tail -1) - - # Check to see if acl is one of the mount points: - ACL="$(echo "$MOUNT_OPTS" | tr "," "\\n" | egrep '^acl|attr2|user_xattr$')" || true - if [ -z "$ACL" ]; then + if [ $? -ne 0 ]; then + test -e "$aclcheckfile" && rm -f "$aclcheckfile" || true db_input critical alternc/acluninstalled || true db_go db_reset alternc/acluninstalled || true db_fset alternc/acluninstalled "seen" "false" || true exit 2 fi - quota_activation=$(quotaon -pa 2>/dev/null |grep '^group.*on$' | /usr/bin/awk '$4 ~ /^\'$MOUNT_POINT'$/ {print $4}') - - if [ -z "$quota_activation" -o "$quota_activation" != "$MOUNT_POINT" ]; then + test -e "$aclcheckfile" && rm -f "$aclcheckfile" || true + + quota -gA -f $MOUNT_POINT 2>/dev/null + + + if [ $? -ne 0 ]; then db_get alternc/quotauninstalled if [ -z "$RET" ]; then db_input critical alternc/quotauninstalled || true