Changeset 243


Ignore:
Timestamp:
02/21/06 23:54:02 (7 years ago)
Author:
anarcat
Message:

[project @ alternc: changeset 2004-05-20 13:57:11 by anarcat]
annuler une partie du commit précédent: utiliser le path absolu pour
get_account_by_domain, l'autre méthode bouclait faire une fonction
avec le code vérifiant si une modif est déjà présente dans un fichier
de config

Original author: anarcat
Date: 2004-05-20 13:57:11

File:
1 edited

Legend:

Unmodified
Added
Removed
  • install/scripts/upgrades/0.9.1.sh

    r241 r243  
    1515override_f=${override_d}.conf 
    1616 
    17 pathfind() { 
    18   OLDIFS="$IFS" 
    19   IFS=: 
    20   for p in $PATH; do 
    21     if [ -x "$p/$*" ]; then 
    22       IFS="$OLDIFS" 
    23       return 0 
    24     fi 
    25   done 
    26   IFS="$OLDIFS" 
    27   return 1 
    28 } 
    29  
    3017# imprime le nom d'usager associé au domaine 
    3118get_account_by_domain() { 
    3219        # les admintools ne sont peut-être pas là 
    33         if pathfind "get_account_by_domain" 
     20        if [ -x "/usr/bin/get_account_by_domain" ] 
    3421        then 
    35                 get_account_by_domain $1 | cut -d\  -f1 
     22                /usr/bin/get_account_by_domain $1 | cut -d\  -f1 
    3623        else 
    3724                # implantons localement ce que nous avons besoin, puisque admintools 
     
    4229                concat(if(sub="", "", concat(sub, ".")), domaine) = "'$1'";' 
    4330        fi 
     31} 
     32 
     33# add the standard input to a given file, only if not already present 
     34append_no_dupe() { 
     35        realfile=$1 
     36        tmpfile=`mktemp` 
     37        trap "rm -f $tmpfile; exit 1" 1 2 15 
     38        cat > $tmpfile 
     39        if [ -r $realfile ] && 
     40                diff -q $tmpfile $realfile > /dev/null || \ 
     41                        diff -u $tmpfile $realfile  | grep '^ ' | sed 's/^ //' | diff -q - $tmpfile > /dev/null 
     42        then 
     43                status=0 
     44        else 
     45                status=1 
     46                cat $tmpfile >> $realfile 
     47        fi 
     48        rm -f $tmpfile 
     49        return $status 
    4450} 
    4551 
     
    6470 
    6571        mkdir -p $override_d/$initial_domain 
    66         tmpfile=`mktemp -p $override_d/$initial_domain` 
    67         realfile="$override_d/$initial_domain/$domain" 
    68         trap "rm -f $tmpfile; exit 1" 1 2 15 
    69         cat - >> $tmpfile <<EOF 
     72        append_no_dupe "$override_d/$initial_domain/$domain" <<EOF 
    7073<Directory ${path1}> 
    7174  php_admin_value open_basedir ${path2}/ 
    7275</Directory> 
    7376EOF 
    74         if [ -r $realfile ] && 
    75                 diff -q $tmpfile $realfile > /dev/null || \ 
    76                         diff -u $tmpfile $realfile  | grep '^ ' | sed 's/^ //' | diff -q - $tmpfile > /dev/null 
    77         then 
    78                 # no change 
    79         else 
    80                 cat $tmpfile >> $realfile 
    81         fi 
    82         rm -f $tmpfile 
    8377done 
    8478 
Note: See TracChangeset for help on using the changeset viewer.