Changeset 3129


Ignore:
Timestamp:
02/06/12 09:28:40 (16 months ago)
Author:
fufroma
Message:

Patch/simplifications d'une serie d'alternc tools (quota et permissions)

Reecriture de slave-dns pour qu'il utilise le template (avant il utilisait
le template la premiere fois, et après utilisait un template en dur dans
son code)

Location:
alternc/trunk
Files:
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • alternc/trunk/etc/alternc/templates/bind/slaveip.conf

    r374 r3129  
    11// DO NOT EDIT THIS FILE, IT WILL BE OVERWRITTEN 
    22// Use the AlternC managment console instead. 
     3// Do NOT remove any comment of this template 
    34 
    45acl "allslaves" { 
    5         { 
    6         127.0.0.1; 
    7         }; 
     6  { 
     7    127.0.0.1; 
     8//AUTO-SLAVES// 
     9  }; 
    810}; 
  • alternc/trunk/src/fixperms.sh

    r3121 r3129  
    106106} 
    107107 
    108 mysql --defaults-file=/etc/alternc/my.cnf -B -e "$query" |grep -v ^uid|doone 
     108mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |doone 
     109 
  • alternc/trunk/src/functions.sh

    r2939 r3129  
    2424print_user_letter() { 
    2525    local user="$1" 
    26     echo "$user" | awk '{print substr($1, 1, 1)}' 
     26    echo ${user:0:1} 
    2727} 
    2828 
  • alternc/trunk/src/quota_edit

    r2860 r3129  
    11#!/bin/bash 
    22. /etc/alternc/local.sh 
    3 DATA_PART=`/bin/df ${ALTERNC_LOC} 2>/dev/null | /usr/bin/awk '/^\// { print $1 }'` 
    4 /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 
     3 
     4# Set disk quota to an user 
     5# Won't work over NFS 
     6 
     7MID=$1 
     8SIZE=$2 
     9 
     10if [ $# -ne 2 ] || [[ ! "$MID" =~ ^[0-9]+$ ]] || [[ ! "$SIZE" =~ ^[0-9]+$ ]]; then 
     11  echo "Usage: quota_edit <uid> <size>" 
     12  echo "Edit the quota of the AlternC account having uid <uid> the the available space to <size>" 
     13  exit 1  
     14fi 
     15 
     16DATA_PART=`$DF "${ALTERNC_LOC}/html" 2>/dev/null | $AWK 'NR==2 { print $1 }'` 
     17/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 
  • alternc/trunk/src/quota_get

    r2862 r3129  
    1010WC=/usr/bin/wc 
    1111 
    12 DATA_PART=`$DF ${ALTERNC_LOC} 2>/dev/null | $AWK '/^\// { print $1 }'` 
     12MID=$1 
     13 
     14if [ "x$MID" == "x" ] ; then 
     15  echo "Usage: quota_get <uid>" 
     16  echo "Get the quota of the AlternC account having uid <uid>" 
     17  exit 1 
     18fi 
     19 
     20# The second line is the one interesting 
     21# We look precisely on the HTML directory. Why ? because it's surely 
     22# the bigger one, and if someone separate it we need to look this one 
     23# particulary. It should be interesting to cumulate quota of all mounted directory. 
     24DATA_PART=`$DF "${ALTERNC_LOC}/html" 2>/dev/null | $AWK 'NR==2 { print $1 }'` 
    1325 
    1426# quota will give over NFS will print the partition using the full NFS name 
     
    2032fi 
    2133 
    22 # quota will split its display on two lines if QUOTA_PART is bigger than 15 
    23 # characters. *sigh* 
    24 PART_LEN=`echo -n "$QUOTA_PART" | $WC -c` 
    25 val=$( 
    26 if [ "$PART_LEN" -gt 15 ]; then 
    27     $QUOTA -g "$1" | 
    28        $SED -n -e "\\;${QUOTA_PART};,+1s/ *\([0-9]*\) .*/\1/p" | 
    29        $GREP -v '^$' 
    30     $QUOTA -g "$1" | 
    31        $SED -n -e "\\;${QUOTA_PART};,+1s/ *[0-9]* *\([0-9]*\) .*/\1/p" | 
    32        $GREP -v '^$' 
    33 else 
    34     $QUOTA -g "$1" | $AWK /${QUOTA_PART//\//\\\/}/\ {print\ '$2'} 
    35     $QUOTA -g "$1" | $AWK /${QUOTA_PART//\//\\\/}/\ {print\ '$3'} 
    36 fi 
    37 ) 
     34# Now we get the quota  
     35val=$(quota -A -wg "$MID" |grep "$QUOTA_PART" | awk '{ print $2 "\n" $3; }') 
    3836 
    3937# If the quota aren't activated, I return something anyway 
    4038if [ -z "$val" ] ; then 
    41         echo 0 
    42         echo 0 
    43 else    
     39        echo -e "0\n0" 
     40else 
    4441        echo -e "$val" 
    4542fi 
  • alternc/trunk/src/slave_dns

    r1798 r3129  
    1 #!/usr/bin/php -q 
    2 <?php 
     1#!/bin/bash 
    32 
    4 /* 
    5  $Id: slave_dns,v 1.5 2004/11/25 17:20:55 anonymous Exp $ 
    6  ---------------------------------------------------------------------- 
    7  AlternC - Web Hosting System 
    8  Copyright (C) 2002 by the AlternC Development Team. 
    9  http://alternc.org/ 
    10  ---------------------------------------------------------------------- 
    11  Based on: 
    12  Valentin Lacambre's web hosting softwares: http://altern.org/ 
    13  ---------------------------------------------------------------------- 
    14  LICENSE 
     3# Rebuild the bind configuration's file 
     4# with the IP of the slave dns 
    155 
    16  This program is free software; you can redistribute it and/or 
    17  modify it under the terms of the GNU General Public License (GPL) 
    18  as published by the Free Software Foundation; either version 2 
    19  of the License, or (at your option) any later version. 
     6FLAGFILE="/var/run/alternc/refresh_slave"; 
     7TPL="/etc/alternc/templates/bind/slaveip.conf" 
     8TARGET="/var/alternc/bind/slaveip.conf" 
     9TMP=$(mktemp /tmp/slaveip.conf.XXXX) 
    2010 
    21  This program is distributed in the hope that it will be useful, 
    22  but WITHOUT ANY WARRANTY; without even the implied warranty of 
    23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    24  GNU General Public License for more details. 
     11if [ ! -e "$FLAGFILE" ] ; then  
     12  # Nothing to do 
     13  exit 0 
     14fi 
    2515 
    26  To read the license please visit http://www.gnu.org/copyleft/gpl.html 
    27  ---------------------------------------------------------------------- 
    28  Original Author of file: Benjamin Sonntag 
    29  Purpose of file: Manage allowed slave dns ip addresses / classes 
    30  ---------------------------------------------------------------------- 
     16# Source some functions 
     17. /usr/lib/alternc/functions.sh 
    3118 
    32 */ 
     19# Get the slave IP. Remove the "newline" caracters 
     20val=$(mysql_query "SELECT concat(ip,'::',class,'; ') FROM slaveip;"|tr '\n' ' ') 
    3321 
    34 $FLAGFILE="/var/run/alternc/refresh_slave"; 
     22# Add the slaves to the templates, re-add the missing "/" separator of subnet 
     23cat "$TPL" | sed -e "s/\/\/AUTO-SLAVES\/\//$val/g" -e "s/::/\//g" > "$TMP" 
    3524 
    36 if (file_exists($FLAGFILE)) { 
    37         unlink($FLAGFILE); 
    38         include("/var/alternc/bureau/class/local.php"); 
    39         mysql_connect($L_MYSQL_HOST,$L_MYSQL_LOGIN,$L_MYSQL_PWD); 
    40         mysql_select_db($L_MYSQL_DATABASE); 
    41         $r=mysql_query("SELECT * FROM slaveip"); 
    42         $f=fopen("/var/alternc/bind/slaveip.conf","wb"); 
    43         fputs($f," 
    44         // DO NOT EDIT THIS FILE, IT WILL BE OVERWRITTEN 
    45         // Use the AlternC managment console instead. 
    46         acl \"allslaves\" { 
    47 { 
    48 127.0.0.1;     // myself, just to be sure 
    49 "); 
    50         while ($c=mysql_fetch_array($r)) { 
    51                 fputs($f,$c['ip']."/".$c['class'].";\n"); 
    52         } 
    53         fputs($f,"};\n};\n"); 
    54         fclose($f); 
    55         exec("invoke-rc.d bind9 reload"); 
    56 } 
     25# Activate the new configuration 
     26mv "$TMP" "$TARGET" 
     27chown root:bind "$TARGET" 
     28chmod 640 "$TARGET" 
    5729 
     30invoke-rc.d bind9 reload 
Note: See TracChangeset for help on using the changeset viewer.