Changeset 792


Ignore:
Timestamp:
02/22/06 03:46:00 (7 years ago)
Author:
anarcat
Message:

skipping to patch 20060221201007-67438-b17552e3f500f086ce2198e1bc2b04622b5a773b.gz

File:
1 edited

Legend:

Unmodified
Added
Removed
  • install/alternc.install

    r782 r792  
    265265fi 
    266266 
     267v v v v v v v 
     268         # Postfix (serveur SMTP) 
     269         "etc/postfix/main.cf" => "[Postfix] Fichier de configuration principal de postfix", 
     270         "etc/postfix/sasl/smtpd.conf" => "[Postfix] Fichier de configuration SASL de postfix", 
     271         "etc/postfix/myalias.cf" => "[Postfix] Table des alias dans MySQL", 
     272         "etc/postfix/mydomain.cf" => "[Postfix] Table des mails en domaine dans MySQL", 
     273        "etc/postfix/myvirtual.cf" => "[Postfix] Table des wrappers / comptes pop dans MySQL", 
     274         "etc/postfix/mygid.cf" => "[Postfix] Table des mapping GID unix dans MySQL", 
     275 
     276         "redir.htaccess" => "[WebMail] Redirection url interne", 
     277         "etc/squirrelmail/apache.conf" => "[Squirrelmail] Fichier de conf apache", 
     278 
     279         ); 
     280 
     281# Those files are copied ONLY if they don't already exist 
     282%onetime_vars = ( 
     283         "etc/bind/slaveip.conf" => "[Bind9] Liste des esclaves", 
     284         "etc/postfix/body_checks" => "[Postfix] Regles de filtrage des mails", 
     285         "etc/postfix/header_checks" => "[Postfix] Regles de filtrage des en-tetes", 
     286         "etc/bind/automatic.conf" => "[Bind9] Fichier (vide) dynamiquement genere par PHP", 
     287         ); 
     288 
     289 
     290@etcdir = ( 
     291        "etc/alternc", "etc/bind", "etc/bind/master", "etc/mysql", "etc/courier", 
     292        "etc/php4",     "etc/php4/apache", "etc/apache-ssl", "etc/apache", 
     293        "etc/postfix", "etc/squirrelmail", "etc/php4/cgi", "etc/phpmyadmin", "usr/lib/alternc" 
     294        ); 
     295 
     296 
     297######################################################################### 
     298# 6. Compute other variables depending on the variables setup in 4. and 
     299# setup some defaults 
     300######################################################################### 
     301 
     302%varscalc = ( 
     303             "fqdn_lettre" => "Premiere lettre de l'avant dernier membre du fqdn",  
     304             "warning_message" => "Message d'avertissement insere en commentaire dans tous les fichiers de conf ...", 
     305             "random_hash" => "Chaine aléatoire utilisée par phpmyadmin ..." 
     306             ); 
     307 
     308@fq=split /\./, $conf{fqdn}; 
     309 
     310$conf{fqdn_lettre} = substr($fq[(scalar @fq)-2],0,1); 
     311$conf{warning_message} = "WARNING : Do not edit this file, edit the one in /usr/share/alternc/install/ and launch alternc.install again"; 
     312 
     313if ($conf{bind_internal}) { 
     314    $conf{bind_internal} .= ";"; 
     315} 
     316if (!$conf{monitor_ip}) { 
     317    $conf{monitor_ip} = "127.0.0.1"; 
     318} 
     319 
     320$conf{random_hash} = map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10); 
     321 
     322######################################################################### 
     323# 7. Create the temporary etc files, and parse them, replacing the 
     324# variables set in 4 and 6 
     325######################################################################### 
     326 
     327$TMP=`mktemp -d /tmp/alternc.install.XXXXXX`; chomp($TMP); 
     328mkdir("$TMP/etc",0777); 
     329mkdir("$TMP/usr",0777); 
     330mkdir("$TMP/usr/lib",0777); 
     331 
     332for ($i=0;$i<scalar @etcdir;$i++) { 
     333    print "creating directory /".$etcdir[$i]."\n"; 
     334    mkdir("$TMP/".$etcdir[$i]."",0777); 
     335} 
     336 
     337while (($key,$val) = each(%conf_vars)) { 
     338    print "parsing configuration file /$key    $val  "; 
     339    open F,"</usr/share/alternc/install/$key" || die "Erreur Ouverture R"; 
     340    open G,">$TMP/$key" || die "Erreur Ouverture W"; 
     341    while ($buffer = <F>) { 
     342        # Replace user variables : 
     343        while (($kv,$vv)=each(%vars)) { 
     344            $buffer=~ s/%%$kv%%/$conf{$kv}/; 
     345        } 
     346        # Replace computed variables :  
     347        while (($kv,$vv)=each(%varscalc)) { 
     348        # printf $kv." : ".$conf{$kv}."\n"; 
     349            $buffer=~ s/%%$kv%%/$conf{$kv}/; 
     350        } 
     351        print G $buffer; 
     352    } 
     353    close(F) || warn("cannot close F /usr/share/alternc/install/$key: $!"); 
     354    close(G) || warn("cannot close G $TMP/$key: $!"); 
     355    print "\n"; 
     356} 
     357# Chmod the shell scripts (a+x) 
     358system("find $TMP/ -name \"*.sh\" -exec chmod a+x '{}' \\;"); 
     359 
     360 
     361######################################################################### 
     362# 8. Backup current conf files 
     363######################################################################### 
     364 
     365print "backup current system files (/etc)\n"; 
     366 
     367# Creation des dossiers dans /tmp/system.DATEDUJOUR 
     368chop($TS=`date +%Y%m%d-%H%M`); 
     369mkdir("/usr/lib/alternc/backups"); 
     370# XXX: this should change name instead of just overwriting 
     371unlink("/usr/lib/alternc/backups/system.$TS.tgz"); 
     372# prepend a slash before each etcdir: TODO : is it still necessary ?  
     373map { $_ =~ s/^/\//; } @etcdir; 
     374$cmd = "tar -czf /usr/lib/alternc/backups/system.$TS.tgz /etc  >/dev/null 2>&1"; 
     375system($cmd) == 0 || die ("error tar $cmd: $!"); 
     376system("/usr/share/alternc/install/dopo.sh") == 0 || die ("error dodpo"); 
     377 
     378######################################################################### 
     379# 9. Stop services 
     380######################################################################### 
     381 
     382system("/etc/init.d/apache stop >&2"); 
     383system("/etc/init.d/apache-ssl stop >&2"); 
     384system("/etc/init.d/postfix stop >&2"); 
     385system("/etc/init.d/bind9 stop >&2"); 
     386system("/etc/init.d/courier-authdaemon stop >&2"); 
     387system("/etc/init.d/courier-imap stop >&2"); 
     388system("/etc/init.d/courier-imap-ssl stop >&2"); 
     389system("/etc/init.d/courier-pop stop >&2"); 
     390system("/etc/init.d/courier-pop-ssl stop >&2"); 
     391system("/etc/init.d/cron stop >&2"); 
     392system("/etc/init.d/proftpd stop >&2"); 
     393system("/etc/init.d/mysql stop >&2"); 
     394 
     395 
     396######################################################################### 
     397# 10. Create dir structure and copy panel files 
     398######################################################################### 
     399 
     400print "Creating directory structure in /var/alternc\n"; 
     401system("/usr/share/alternc/install/initrep.sh"); 
     402 
     403 
     404######################################################################### 
     405# 11. Send etc files to /etc :) 
     406######################################################################### 
     407 
     408print "Copying files to /etc\n"; 
     409# 11.1 copy all the files setup in 7 in /etc, plus other places 
     410system("rsync -a $TMP/etc/* /etc/"); 
     411# 11.2 setup part of the webmail 
     412system("cp $TMP/redir.htaccess /var/alternc/bureau/admin/webmail/.htaccess"); 
     413# 11.3 setup part of bind 
     414system("cp $TMP/domaines.template /usr/lib/alternc/system/bind2/"); 
     415# 11.4 setup part of the panel 
     416system("cp $TMP/local.php /var/alternc/bureau/class"); 
     417# 11.5 setup permissions for scripts and configs 
     418system("chown -R www-data.www-data /var/alternc/bureau/admin/webmail/.htaccess /var/alternc/dns /var/run/alternc /var/log/alternc"); 
     419system("chown -R root.www-data /var/alternc/bureau"); 
     420system("chmod -R 0640 /var/alternc/bureau"); 
     421system("chmod -R ug+X /var/alternc/bureau"); 
     422system("chown www-data.www-data /var/alternc/html/* /var/alternc/mail/* /var/alternc/html/ /var/alternc/mail/ "); 
     423system("install -o root -g www-data -m0750 $TMP/usr/lib/alternc/sendmail /usr/lib/alternc/sendmail"); 
     424 
     425# 11.6 symlink the bureau in dns/ 
     426@fq=split /\./, $conf{fqdn}; 
     427$fl=substr($fq[(scalar @fq)-2],0,1); 
     428symlink("/var/alternc/bureau","/var/alternc/dns/$fl/$conf{fqdn}"); 
     429 
     430# 11.7 Copy 'one time' files IF REQUIRED 
     431while (($key,$val) = each(%onetime_vars)) { 
     432    if (! (-e "/$key") ) { 
     433      print "Copying one time file /$key    $val  "; 
     434      open F,"</usr/share/alternc/install/$key" || die "Erreur Ouverture R"; 
     435      open G,">/$key" || die "Erreur Ouverture W"; 
     436      while ($buffer = <F>) { 
     437          # Replace user variables : 
     438          while (($kv,$vv)=each(%vars)) { 
     439              $buffer=~ s/%%$kv%%/$conf{$kv}/; 
     440          } 
     441          # Replace computed variables :  
     442          while (($kv,$vv)=each(%varscalc)) { 
     443          # printf $kv." : ".$conf{$kv}."\n"; 
     444              $buffer=~ s/%%$kv%%/$conf{$kv}/; 
     445          } 
     446          print G $buffer; 
     447      } 
     448      close(F); 
     449      close(G); 
     450      print "\n"; 
     451    } 
     452} 
     453 
     454######################################################################### 
     455# 14. Create MySQL database, restart mysql and add default users 
     456######################################################################### 
     457 
     458print "Creating MySQL db, restarting mysql.\n"; 
     459system("/usr/share/alternc/install/mysql.sh '".$conf{dbuser}."' '".$conf{dbpwd}."' '".$conf{dbname}."' >&2"); 
     460 
     461 
     462######################################################################### 
     463# 15. Start services 
     464######################################################################### 
     465 
     466system("/etc/init.d/apache start >&2"); 
     467system("/etc/init.d/apache-ssl start >&2"); 
     468system("/etc/init.d/postfix start >&2"); 
     469system("/etc/init.d/bind9 start >&2"); 
     470system("/etc/init.d/courier-authdaemon start >&2"); 
     471system("/etc/init.d/courier-imap start >&2"); 
     472system("/etc/init.d/courier-imap-ssl start >&2"); 
     473system("/etc/init.d/courier-pop start >&2"); 
     474system("/etc/init.d/courier-pop-ssl start >&2"); 
     475system("/etc/init.d/cron start >&2"); 
     476system("/etc/init.d/proftpd start >&2"); 
     477 
     478######################################################################### 
     479# 16. Create the first user 
     480######################################################################### 
     481 
     482print "Creating user root, with password root (change it as soon as possible)\n"; 
     483 
     484system("su - www-data -c /usr/share/alternc/install/newone.php"); 
     485system("/usr/lib/alternc/basedir_prot.sh"); 
     486 
     487system("rm -rf $TMP"); 
     488 
     489######################################################################### 
     490# 17. Job's done ! Ready to serve... 
     491######################################################################### 
     492 
     493print " 
     494  AlternC Install complete. 
     495  You may use you server now. Don't forget to change your root password  
     496  as soon as possible. 
     497  If you use this software, please send a mail to tech\@alternc.org 
     498  so that we know who use it :) and build some kind of statistics. Thanks. 
     499 
     500"; 
     501 
     502exit(0); 
     503************* 
    267504# vim: et sw=4 
     505^ ^ ^ ^ ^ ^ ^ 
Note: See TracChangeset for help on using the changeset viewer.