Changeset 792
- Timestamp:
- 02/22/06 03:46:00 (7 years ago)
- File:
-
- 1 edited
-
install/alternc.install (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
install/alternc.install
r782 r792 265 265 fi 266 266 267 v 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 313 if ($conf{bind_internal}) { 314 $conf{bind_internal} .= ";"; 315 } 316 if (!$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); 328 mkdir("$TMP/etc",0777); 329 mkdir("$TMP/usr",0777); 330 mkdir("$TMP/usr/lib",0777); 331 332 for ($i=0;$i<scalar @etcdir;$i++) { 333 print "creating directory /".$etcdir[$i]."\n"; 334 mkdir("$TMP/".$etcdir[$i]."",0777); 335 } 336 337 while (($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) 358 system("find $TMP/ -name \"*.sh\" -exec chmod a+x '{}' \\;"); 359 360 361 ######################################################################### 362 # 8. Backup current conf files 363 ######################################################################### 364 365 print "backup current system files (/etc)\n"; 366 367 # Creation des dossiers dans /tmp/system.DATEDUJOUR 368 chop($TS=`date +%Y%m%d-%H%M`); 369 mkdir("/usr/lib/alternc/backups"); 370 # XXX: this should change name instead of just overwriting 371 unlink("/usr/lib/alternc/backups/system.$TS.tgz"); 372 # prepend a slash before each etcdir: TODO : is it still necessary ? 373 map { $_ =~ s/^/\//; } @etcdir; 374 $cmd = "tar -czf /usr/lib/alternc/backups/system.$TS.tgz /etc >/dev/null 2>&1"; 375 system($cmd) == 0 || die ("error tar $cmd: $!"); 376 system("/usr/share/alternc/install/dopo.sh") == 0 || die ("error dodpo"); 377 378 ######################################################################### 379 # 9. Stop services 380 ######################################################################### 381 382 system("/etc/init.d/apache stop >&2"); 383 system("/etc/init.d/apache-ssl stop >&2"); 384 system("/etc/init.d/postfix stop >&2"); 385 system("/etc/init.d/bind9 stop >&2"); 386 system("/etc/init.d/courier-authdaemon stop >&2"); 387 system("/etc/init.d/courier-imap stop >&2"); 388 system("/etc/init.d/courier-imap-ssl stop >&2"); 389 system("/etc/init.d/courier-pop stop >&2"); 390 system("/etc/init.d/courier-pop-ssl stop >&2"); 391 system("/etc/init.d/cron stop >&2"); 392 system("/etc/init.d/proftpd stop >&2"); 393 system("/etc/init.d/mysql stop >&2"); 394 395 396 ######################################################################### 397 # 10. Create dir structure and copy panel files 398 ######################################################################### 399 400 print "Creating directory structure in /var/alternc\n"; 401 system("/usr/share/alternc/install/initrep.sh"); 402 403 404 ######################################################################### 405 # 11. Send etc files to /etc :) 406 ######################################################################### 407 408 print "Copying files to /etc\n"; 409 # 11.1 copy all the files setup in 7 in /etc, plus other places 410 system("rsync -a $TMP/etc/* /etc/"); 411 # 11.2 setup part of the webmail 412 system("cp $TMP/redir.htaccess /var/alternc/bureau/admin/webmail/.htaccess"); 413 # 11.3 setup part of bind 414 system("cp $TMP/domaines.template /usr/lib/alternc/system/bind2/"); 415 # 11.4 setup part of the panel 416 system("cp $TMP/local.php /var/alternc/bureau/class"); 417 # 11.5 setup permissions for scripts and configs 418 system("chown -R www-data.www-data /var/alternc/bureau/admin/webmail/.htaccess /var/alternc/dns /var/run/alternc /var/log/alternc"); 419 system("chown -R root.www-data /var/alternc/bureau"); 420 system("chmod -R 0640 /var/alternc/bureau"); 421 system("chmod -R ug+X /var/alternc/bureau"); 422 system("chown www-data.www-data /var/alternc/html/* /var/alternc/mail/* /var/alternc/html/ /var/alternc/mail/ "); 423 system("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); 428 symlink("/var/alternc/bureau","/var/alternc/dns/$fl/$conf{fqdn}"); 429 430 # 11.7 Copy 'one time' files IF REQUIRED 431 while (($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 458 print "Creating MySQL db, restarting mysql.\n"; 459 system("/usr/share/alternc/install/mysql.sh '".$conf{dbuser}."' '".$conf{dbpwd}."' '".$conf{dbname}."' >&2"); 460 461 462 ######################################################################### 463 # 15. Start services 464 ######################################################################### 465 466 system("/etc/init.d/apache start >&2"); 467 system("/etc/init.d/apache-ssl start >&2"); 468 system("/etc/init.d/postfix start >&2"); 469 system("/etc/init.d/bind9 start >&2"); 470 system("/etc/init.d/courier-authdaemon start >&2"); 471 system("/etc/init.d/courier-imap start >&2"); 472 system("/etc/init.d/courier-imap-ssl start >&2"); 473 system("/etc/init.d/courier-pop start >&2"); 474 system("/etc/init.d/courier-pop-ssl start >&2"); 475 system("/etc/init.d/cron start >&2"); 476 system("/etc/init.d/proftpd start >&2"); 477 478 ######################################################################### 479 # 16. Create the first user 480 ######################################################################### 481 482 print "Creating user root, with password root (change it as soon as possible)\n"; 483 484 system("su - www-data -c /usr/share/alternc/install/newone.php"); 485 system("/usr/lib/alternc/basedir_prot.sh"); 486 487 system("rm -rf $TMP"); 488 489 ######################################################################### 490 # 17. Job's done ! Ready to serve... 491 ######################################################################### 492 493 print " 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 502 exit(0); 503 ************* 267 504 # vim: et sw=4 505 ^ ^ ^ ^ ^ ^ ^
Note: See TracChangeset
for help on using the changeset viewer.
