diff --git a/.gitattributes b/.gitattributes index c6d75d73..370d7003 100644 --- a/.gitattributes +++ b/.gitattributes @@ -475,9 +475,7 @@ src/mem_add -text src/mem_del -text src/quota_delete -text src/quota_edit -text -src/quota_edit.sh -text src/quota_get -text -src/quota_get.sh -text src/quota_init -text src/rawstat.daily -text src/sendmail -text diff --git a/etc/alternc/templates/bind/slaveip.conf b/etc/alternc/templates/bind/slaveip.conf index 16b8ba5f..7212d291 100644 --- a/etc/alternc/templates/bind/slaveip.conf +++ b/etc/alternc/templates/bind/slaveip.conf @@ -1,8 +1,10 @@ // DO NOT EDIT THIS FILE, IT WILL BE OVERWRITTEN // Use the AlternC managment console instead. +// Do NOT remove any comment of this template acl "allslaves" { - { - 127.0.0.1; - }; + { + 127.0.0.1; +//AUTO-SLAVES// + }; }; diff --git a/src/fixperms.sh b/src/fixperms.sh index dfe6bc35..6932c2d7 100755 --- a/src/fixperms.sh +++ b/src/fixperms.sh @@ -105,4 +105,5 @@ doone() { done } -mysql --defaults-file=/etc/alternc/my.cnf -B -e "$query" |grep -v ^uid|doone +mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |doone + diff --git a/src/functions.sh b/src/functions.sh index 929dda28..e9b9da00 100755 --- a/src/functions.sh +++ b/src/functions.sh @@ -23,7 +23,7 @@ print_domain_letter() { print_user_letter() { local user="$1" - echo "$user" | awk '{print substr($1, 1, 1)}' + echo ${user:0:1} } get_uid_by_name() { diff --git a/src/quota_edit b/src/quota_edit index a186c780..d0a39a52 100755 --- a/src/quota_edit +++ b/src/quota_edit @@ -1,33 +1,17 @@ -#!/usr/bin/perl +#!/bin/bash +. /etc/alternc/local.sh -use strict; +# Set disk quota to an user +# Won't work over NFS -my ($uid,$size) = @ARGV; +MID=$1 +SIZE=$2 -if (!$size || !$uid) { - print "Usage: quota_edit \n"; - print " Edit the quota of the AlternC account having uid the the available space to \n"; - exit(1); -} +if [ $# -ne 2 ] || [[ ! "$MID" =~ ^[0-9]+$ ]] || [[ ! "$SIZE" =~ ^[0-9]+$ ]]; then + echo "Usage: quota_edit " + echo "Edit the quota of the AlternC account having uid the the available space to " + exit 1 +fi -$ENV{PATH} = ""; -delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; - -if (!($uid =~ /^([0-9]+)$/)) { - die "uid is incorrect."; -} -$uid=$1; - -if (!($size =~ /^([0-9]+)$/)) { - die "size is incorrect."; -} -$size=$1; - -$< = $>; -$( = $); - -my $PTH="/usr/lib/alternc/quota_edit.sh '$uid' '$size'"; - -system($PTH); - -0; +DATA_PART=`$DF "${ALTERNC_LOC}/html" 2>/dev/null | $AWK 'NR==2 { print $1 }'` +/usr/sbin/setquota -r -g $MID $SIZE $SIZE 0 0 $DATA_PART 2>/dev/null || echo "Group quota are not enabled on /var/alternc." >&2 diff --git a/src/quota_edit.sh b/src/quota_edit.sh deleted file mode 100755 index efcd42c8..00000000 --- a/src/quota_edit.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -. /etc/alternc/local.sh -DATA_PART=`/bin/df ${ALTERNC_LOC} 2>/dev/null | /usr/bin/awk '/^\// { print $1 }'` -/usr/sbin/setquota -r -g $1 $2 $2 0 0 $DATA_PART 2>/dev/null || echo "Group quota are not enabled on /var/alternc." >&2 diff --git a/src/quota_get b/src/quota_get index ba816eb3..50e3fac8 100755 --- a/src/quota_get +++ b/src/quota_get @@ -1,28 +1,43 @@ -#!/usr/bin/perl +#!/bin/bash +. /etc/alternc/local.sh -use strict; +AWK=/usr/bin/awk +DF=/bin/df +SED=/bin/sed +MOUNT=/bin/mount +QUOTA=/usr/bin/quota +GREP=/bin/grep +WC=/usr/bin/wc -my ($uid) = @ARGV; +MID=$1 -if (!$uid) { - print "Usage: quota_get \n"; - print " Get the quota of the AlternC account having uid \n"; - exit(1); -} +if [ "x$MID" == "x" ] ; then + echo "Usage: quota_get " + echo "Get the quota of the AlternC account having uid " + exit 1 +fi -$ENV{PATH} = ""; -delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; +# The second line is the one interesting +# We look precisely on the HTML directory. Why ? because it's surely +# the bigger one, and if someone separate it we need to look this one +# particulary. It should be interesting to cumulate quota of all mounted directory. +DATA_PART=`$DF "${ALTERNC_LOC}/html" 2>/dev/null | $AWK 'NR==2 { print $1 }'` -if (!($uid =~ /^([0-9]+)$/)) { - die "uid is incorrect."; -} -$uid=$1; +# quota will give over NFS will print the partition using the full NFS name +# (e.g. 10.0.0.1:/var/alternc) so we need to lookup first with mount +# to convert DATA_PART if needed. +QUOTA_PART=`$MOUNT | $SED -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"` +if [ -z "$QUOTA_PART" ]; then + QUOTA_PART="$DATA_PART" +fi -$< = $>; -$( = $); +# Now we get the quota +val=$(quota -A -wg "$MID" |grep "$QUOTA_PART" | awk '{ print $2 "\n" $3; }') -my $PTH="/usr/lib/alternc/quota_get.sh '$uid'"; +# If the quota aren't activated, I return something anyway +if [ -z "$val" ] ; then + echo -e "0\n0" +else + echo -e "$val" +fi -system($PTH); - -0; diff --git a/src/quota_get.sh b/src/quota_get.sh deleted file mode 100755 index 263c1249..00000000 --- a/src/quota_get.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -. /etc/alternc/local.sh - -AWK=/usr/bin/awk -DF=/bin/df -SED=/bin/sed -MOUNT=/bin/mount -QUOTA=/usr/bin/quota -GREP=/bin/grep -WC=/usr/bin/wc - -DATA_PART=`$DF ${ALTERNC_LOC} 2>/dev/null | $AWK '/^\// { print $1 }'` - -# quota will give over NFS will print the partition using the full NFS name -# (e.g. 10.0.0.1:/var/alternc) so we need to lookup first with mount -# to convert DATA_PART if needed. -QUOTA_PART=`$MOUNT | $SED -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"` -if [ -z "$QUOTA_PART" ]; then - QUOTA_PART="$DATA_PART" -fi - -# quota will split its display on two lines if QUOTA_PART is bigger than 15 -# characters. *sigh* -PART_LEN=`echo -n "$QUOTA_PART" | $WC -c` -val=$( -if [ "$PART_LEN" -gt 15 ]; then - $QUOTA -g "$1" | - $SED -n -e "\\;${QUOTA_PART};,+1s/ *\([0-9]*\) .*/\1/p" | - $GREP -v '^$' - $QUOTA -g "$1" | - $SED -n -e "\\;${QUOTA_PART};,+1s/ *[0-9]* *\([0-9]*\) .*/\1/p" | - $GREP -v '^$' -else - $QUOTA -g "$1" | $AWK /${QUOTA_PART//\//\\\/}/\ {print\ '$2'} - $QUOTA -g "$1" | $AWK /${QUOTA_PART//\//\\\/}/\ {print\ '$3'} -fi -) - -# If the quota aren't activated, I return something anyway -if [ -z "$val" ] ; then - echo 0 - echo 0 -else - echo -e "$val" -fi - diff --git a/src/slave_dns b/src/slave_dns index 3b7a1739..1f02dcbe 100644 --- a/src/slave_dns +++ b/src/slave_dns @@ -1,57 +1,30 @@ -#!/usr/bin/php -q - "$TMP" -if (file_exists($FLAGFILE)) { - unlink($FLAGFILE); - include("/var/alternc/bureau/class/local.php"); - mysql_connect($L_MYSQL_HOST,$L_MYSQL_LOGIN,$L_MYSQL_PWD); - mysql_select_db($L_MYSQL_DATABASE); - $r=mysql_query("SELECT * FROM slaveip"); - $f=fopen("/var/alternc/bind/slaveip.conf","wb"); - fputs($f," - // DO NOT EDIT THIS FILE, IT WILL BE OVERWRITTEN - // Use the AlternC managment console instead. - acl \"allslaves\" { -{ -127.0.0.1; // myself, just to be sure -"); - while ($c=mysql_fetch_array($r)) { - fputs($f,$c['ip']."/".$c['class'].";\n"); - } - fputs($f,"};\n};\n"); - fclose($f); - exec("invoke-rc.d bind9 reload"); -} +# Activate the new configuration +mv "$TMP" "$TARGET" +chown root:bind "$TARGET" +chmod 640 "$TARGET" +invoke-rc.d bind9 reload