@@ -34,9 +34,8 @@ class installer_base {
3434 var $ language = 'en ' ;
3535 var $ db ;
3636 private $ conf ;
37- /*
38-
39- */
37+
38+
4039 public function __construct ()
4140 {
4241 global $ conf ; //TODO: maybe $conf should be passed to constructor
@@ -113,7 +112,6 @@ function request_language(){
113112 } while (!$this->check_break($lang) or $this->
114113 */
115114
116-
117115 }
118116
119117 /** Create the database for ISPConfig */
@@ -159,10 +157,8 @@ public function configure_database()
159157 }
160158 }
161159
162- /*
163- Create postfix configuration files
164- */
165160
161+ //** writes postfix configuration files
166162 private function process_postfix_config ($ configfile )
167163 {
168164 $ config_dir = $ this ->conf ['dist ' ]['postfix ' ]['config_dir ' ].'/ ' ;
@@ -180,7 +176,7 @@ private function process_postfix_config($configfile)
180176 wf ($ full_file_name , $ content );
181177 }
182178
183-
179+
184180 public function configure_postfix ($ options = '' )
185181 {
186182 $ cf = $ this ->conf ['dist ' ]['postfix ' ];
@@ -344,10 +340,10 @@ function configure_saslauthd() {
344340 if (is_file ($ conf ["dist " ]["postfix " ]["config_dir " ].'/sasl/smtpd.conf ' )) copy ($ conf ["dist " ]["postfix " ]["config_dir " ].'/sasl/smtpd.conf ' ,$ conf ["dist " ]["postfix " ]["config_dir " ].'/sasl/smtpd.conf~ ' );
345341 if (is_file ($ conf ["dist " ]["postfix " ]["config_dir " ].'/sasl/smtpd.conf~ ' )) exec ('chmod 400 ' .$ conf ["dist " ]["postfix " ]["config_dir " ].'/sasl/smtpd.conf~ ' );
346342 $ content = rf ("tpl/ " .$ configfile .".master " );
347- $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ conf [" mysql " ][ " ispconfig_user " ],$ content );
348- $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ conf [" mysql " ][ " ispconfig_password " ], $ content );
349- $ content = str_replace ('{mysql_server_database} ' ,$ conf [" mysql " ][ " database " ],$ content );
350- $ content = str_replace ('{mysql_server_ip} ' ,$ conf [" mysql " ][ " ip " ],$ content );
343+ $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ this -> conf [' mysql ' ][ ' ispconfig_user ' ],$ content );
344+ $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ this -> conf [' mysql ' ][ ' ispconfig_password ' ], $ content );
345+ $ content = str_replace ('{mysql_server_database} ' ,$ this -> conf [' mysql ' ][ ' database ' ],$ content );
346+ $ content = str_replace ('{mysql_server_ip} ' ,$ this -> conf [' mysql ' ][ ' ip ' ],$ content );
351347 wf ($ conf ["dist " ]["postfix " ]["config_dir " ].'/sasl/smtpd.conf ' ,$ content );
352348
353349 // TODO: Chmod and chown on the config file
@@ -375,50 +371,55 @@ function configure_saslauthd() {
375371
376372 }
377373
378- function configure_pam () {
379- global $ conf ;
380-
381- // configure pam for SMTP authentication agains the ispconfig database
374+ public function configure_pam ()
375+ {
376+ $ pam = $ this -> conf [ ' dist ' ][ ' pam ' ];
377+ //* configure pam for SMTP authentication agains the ispconfig database
382378 $ configfile = 'pamd_smtp ' ;
383- if (is_file ($ conf ['dist ' ]['pam ' ].'/smtp ' )) copy ($ conf ['dist ' ]['pam ' ].'/smtp ' ,$ conf ['dist ' ]['pam ' ].'/smtp~ ' );
384- if (is_file ($ conf ['dist ' ]['pam ' ].'/smtp~ ' )) exec ('chmod 400 ' .$ conf ['dist ' ]['pam ' ].'/smtp~ ' );
385- $ content = rf ("tpl/ " .$ configfile .".master " );
386- $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ conf ["mysql " ]["ispconfig_user " ],$ content );
387- $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ conf ["mysql " ]["ispconfig_password " ],$ content );
388- $ content = str_replace ('{mysql_server_database} ' ,$ conf ["mysql " ]["database " ],$ content );
389- $ content = str_replace ('{mysql_server_ip} ' ,$ conf ["mysql " ]["ip " ],$ content );
390- wf ($ conf ['dist ' ]['pam ' ].'/smtp ' ,$ content );
391- exec ('chmod 660 ' .$ conf ['dist ' ]['pam ' ].'/smtp ' );
392- exec ('chown daemon:daemon ' .$ conf ['dist ' ]['pam ' ].'/smtp ' );
379+ if (is_file ("$ pam/smtp " )) copy ("$ pam/smtp " , "$ pam/smtp~ " );
380+ if (is_file ("$ pam/smtp~ " )) exec ("chmod 400 $ pam/smtp~ " );
381+
382+ $ content = rf ("tpl/ $ configfile.master " );
383+ $ content = str_replace ('{mysql_server_ispconfig_user} ' , $ this ->conf ['mysql ' ]['ispconfig_user ' ], $ content );
384+ $ content = str_replace ('{mysql_server_ispconfig_password} ' , $ this ->conf ['mysql ' ]['ispconfig_password ' ], $ content );
385+ $ content = str_replace ('{mysql_server_database} ' , $ this ->conf ['mysql ' ]['database ' ], $ content );
386+ $ content = str_replace ('{mysql_server_ip} ' , $ this ->conf ['mysql ' ]['ip ' ], $ content );
387+ wf ("$ pam/smtp " , $ content );
388+ exec ("chmod 660 $ pam/smtp " );
389+ exec ("chown daemon:daemon $ pam/smtp " );
393390
394391 }
395392
396- function configure_courier () {
397- global $ conf ;
398-
399- // authmysqlrc
393+ public function configure_courier ()
394+ {
395+ $ config_dir = $ this -> conf [ ' dist ' ][ ' courier ' ][ ' config_dir ' ];
396+ //* authmysqlrc
400397 $ configfile = 'authmysqlrc ' ;
401- if (is_file ($ conf ["dist " ]["courier " ]["config_dir " ].'/ ' .$ configfile )) copy ($ conf ["dist " ]["courier " ]["config_dir " ].'/ ' .$ configfile ,$ conf ["dist " ]["courier " ]["config_dir " ].'/ ' .$ configfile .'~ ' );
402- exec ('chmod 400 ' .$ conf ["dist " ]["courier " ]["config_dir " ].'/ ' .$ configfile .'~ ' );
403- $ content = rf ("tpl/ " .$ configfile .".master " );
404- $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ conf ["mysql " ]["ispconfig_user " ],$ content );
405- $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ conf ["mysql " ]["ispconfig_password " ],$ content );
406- $ content = str_replace ('{mysql_server_database} ' ,$ conf ["mysql " ]["database " ],$ content );
407- $ content = str_replace ('{mysql_server_host} ' ,$ conf ["mysql " ]["host " ],$ content );
408- wf ($ conf ["dist " ]["courier " ]["config_dir " ].'/ ' .$ configfile ,$ content );
398+ if (is_file ("$ config_dir/ $ configfile " )){
399+ copy ("$ config_dir/ $ configfile " , "$ config_dir/ $ configfile~ " );
400+ }
401+ exec ("chmod 400 $ config_dir/ $ configfile~ " );
402+ $ content = rf ("tpl/ $ configfile.master " );
403+ $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ this ->conf ['mysql ' ]['ispconfig_user ' ],$ content );
404+ $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ this ->conf ['mysql ' ]['ispconfig_password ' ], $ content );
405+ $ content = str_replace ('{mysql_server_database} ' ,$ this ->conf ['mysql ' ]['database ' ],$ content );
406+ $ content = str_replace ('{mysql_server_host} ' ,$ this ->conf ['mysql ' ]['host ' ],$ content );
407+ wf ("$ config_dir/ $ configfile " , $ content );
409408
410- exec (' chmod 660 ' . $ conf [ " dist " ][ " courier " ][ " config_dir " ]. ' / ' . $ configfile );
411- exec (' chown daemon:daemon ' . $ conf [ " dist " ][ " courier " ][ " config_dir " ]. ' / ' . $ configfile );
409+ exec (" chmod 660 $ config_dir/ $ configfile" );
410+ exec (" chown daemon:daemon $ config_dir/ $ configfile" );
412411
413- //authdaemonrc
414- $ configfile = $ conf ["dist " ]["courier " ]["config_dir " ].'/authdaemonrc ' ;
415- if (is_file ($ configfile )) copy ($ configfile ,$ configfile .'~ ' );
416- if (is_file ($ configfile .'~ ' )) exec ('chmod 400 ' .$ configfile .'~ ' );
412+ //* authdaemonrc
413+ $ configfile = $ this ->conf ['dist ' ]['courier ' ]['config_dir ' ].'/authdaemonrc ' ;
414+ if (is_file ($ configfile )){
415+ copy ($ configfile , $ configfile .'~ ' );
416+ }
417+ if (is_file ($ configfile .'~ ' )){
418+ exec ('chmod 400 ' .$ configfile .'~ ' );
419+ }
417420 $ content = rf ($ configfile );
418- $ content = str_replace ('authmodulelist="authpam" ' ,'authmodulelist="authmysql" ' ,$ content );
419- wf ($ configfile ,$ content );
420-
421-
421+ $ content = str_replace ('authmodulelist="authpam" ' , 'authmodulelist="authmysql" ' , $ content );
422+ wf ($ configfile , $ content );
422423 }
423424
424425 function configure_amavis () {
@@ -429,11 +430,11 @@ function configure_amavis() {
429430 if (is_file ($ conf ["dist " ]["amavis " ]["config_dir " ].'/conf.d/50-user ' )) copy ($ conf ["dist " ]["amavis " ]["config_dir " ].'/conf.d/50-user ' ,$ conf ["dist " ]["courier " ]["config_dir " ].'/50-user~ ' );
430431 if (is_file ($ conf ["dist " ]["amavis " ]["config_dir " ].'/conf.d/50-user~ ' )) exec ('chmod 400 ' .$ conf ["dist " ]["amavis " ]["config_dir " ].'/conf.d/50-user~ ' );
431432 $ content = rf ("tpl/ " .$ configfile .".master " );
432- $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ conf [" mysql " ][ " ispconfig_user " ],$ content );
433- $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ conf [" mysql " ][ " ispconfig_password " ], $ content );
434- $ content = str_replace ('{mysql_server_database} ' ,$ conf [" mysql " ][ " database " ],$ content );
433+ $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ this -> conf [' mysql ' ][ ' ispconfig_user ' ],$ content );
434+ $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ this -> conf [' mysql ' ][ ' ispconfig_password ' ], $ content );
435+ $ content = str_replace ('{mysql_server_database} ' ,$ this -> conf [' mysql ' ][ ' database ' ],$ content );
435436 $ content = str_replace ('{mysql_server_port} ' ,$ conf ["mysql " ]["port " ],$ content );
436- $ content = str_replace ('{mysql_server_ip} ' ,$ conf [" mysql " ][ " ip " ],$ content );
437+ $ content = str_replace ('{mysql_server_ip} ' ,$ this -> conf [' mysql ' ][ ' ip ' ],$ content );
437438 wf ($ conf ["dist " ]["amavis " ]["config_dir " ].'/conf.d/50-user ' ,$ content );
438439
439440 // TODO: chmod and chown on the config file
@@ -470,63 +471,69 @@ function configure_amavis() {
470471
471472 public function configure_spamassassin ()
472473 {
473- //* Enable spamasasssin in debian and ubuntu
474+ //* Enable spamasasssin on debian and ubuntu
474475 $ configfile = '/etc/default/spamassassin ' ;
475476 if (is_file ($ configfile )){
476- copy ($ configfile ,$ configfile .'~ ' );
477+ copy ($ configfile , $ configfile .'~ ' );
477478 }
478479 $ content = rf ($ configfile );
479480 $ content = str_replace ('ENABLED=0 ' , 'ENABLED=1 ' , $ content );
480481 wf ($ configfile , $ content );
481482 }
482483
483- function configure_getmail () {
484- global $ conf ;
485-
486- $ command = 'useradd -d ' .$ conf ["dist " ]["getmail " ]["config_dir " ].' getmail ' ;
487- caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
484+ public function configure_getmail ()
485+ {
486+ $ config_dir = $ this ->conf ['dist ' ]['getmail ' ]['config_dir ' ];
487+
488+ $ command = "useradd -d $ config_dir getmail " ;
489+ caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
488490
489- $ command = ' chown -R getmail ' . $ conf [ " dist " ][ " getmail " ][ " config_dir "] ;
490- caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
491+ $ command = " chown -R getmail $ config_dir " ;
492+ caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
491493
492- $ command = ' chmod -R 700 ' . $ conf [ " dist " ][ " getmail " ][ " config_dir "] ;
493- caselog ($ command ." &> /dev/null " , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
494+ $ command = " chmod -R 700 $ config_dir " ;
495+ caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
494496 }
495497
496498
497- function configure_pureftpd () {
498- global $ conf ;
499-
500- // configure pam for SMTP authentication agains the ispconfig database
499+ public function configure_pureftpd ()
500+ {
501+ $ config_dir = $ this ->conf ['dist ' ]['pureftpd ' ]['config_dir ' ];
502+
503+ //* configure pam for SMTP authentication agains the ispconfig database
501504 $ configfile = 'db/mysql.conf ' ;
502- if (is_file ($ conf ["dist " ]["pureftpd " ]["config_dir " ].'/ ' .$ configfile )) copy ($ conf ["dist " ]["pureftpd " ]["config_dir " ].'/ ' .$ configfile ,$ conf ["dist " ]["pureftpd " ]["config_dir " ].'/ ' .$ configfile .'~ ' );
503- if (is_file ($ conf ["dist " ]["pureftpd " ]["config_dir " ].'/ ' .$ configfile .'~ ' )) exec ('chmod 400 ' .$ conf ["dist " ]["pureftpd " ]["config_dir " ].'/ ' .$ configfile .'~ ' );
504- $ content = rf ("tpl/pureftpd_mysql.conf.master " );
505- $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ conf ["mysql " ]["ispconfig_user " ],$ content );
506- $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ conf ["mysql " ]["ispconfig_password " ],$ content );
507- $ content = str_replace ('{mysql_server_database} ' ,$ conf ["mysql " ]["database " ],$ content );
508- $ content = str_replace ('{mysql_server_ip} ' ,$ conf ["mysql " ]["ip " ],$ content );
509- $ content = str_replace ('{server_id} ' ,$ conf ["server_id " ],$ content );
510- wf ($ conf ["dist " ]["pureftpd " ]["config_dir " ].'/ ' .$ configfile ,$ content );
511- exec ('chmod 600 ' .$ conf ["dist " ]["pureftpd " ]["config_dir " ].'/ ' .$ configfile );
512- exec ('chown root:root ' .$ conf ["dist " ]["pureftpd " ]["config_dir " ].'/ ' .$ configfile );
513- // enable chrooting
514- exec ('mkdir -p ' .$ conf ["dist " ]["pureftpd " ]["config_dir " ].'/conf/ChrootEveryone ' );
515- exec ('echo "yes" > ' .$ conf ["dist " ]["pureftpd " ]["config_dir " ].'/conf/ChrootEveryone ' );
516-
505+ if (is_file ("$ config_dir/ $ configfile " )){
506+ copy ("$ config_dir/ $ configfile " , "$ config_dir/ $ configfile~ " );
507+ }
508+ if (is_file ("$ config_dir/ $ configfile~ " )){
509+ exec ("chmod 400 $ config_dir/ $ configfile~ " );
510+ }
511+ $ content = rf ('tpl/pureftpd_mysql.conf.master ' );
512+ $ content = str_replace ('{mysql_server_ispconfig_user} ' , $ this ->conf ["mysql " ]["ispconfig_user " ], $ content );
513+ $ content = str_replace ('{mysql_server_ispconfig_password} ' , $ this ->conf ["mysql " ]["ispconfig_password " ], $ content );
514+ $ content = str_replace ('{mysql_server_database} ' , $ this ->conf ["mysql " ]["database " ], $ content );
515+ $ content = str_replace ('{mysql_server_ip} ' , $ this ->conf ["mysql " ]["ip " ], $ content );
516+ $ content = str_replace ('{server_id} ' , $ this ->conf ["server_id " ], $ content );
517+ wf ("$ config_dir/ $ configfile " , $ content );
518+ exec ("chmod 600 $ config_dir/ $ configfile " );
519+ exec ("chown root:root $ config_dir/ $ configfile " );
520+ // **enable chrooting
521+ exec ('mkdir -p ' .$ config_dir .'/conf/ChrootEveryone ' );
522+ exec ('echo "yes" > ' .$ config_dir .'/conf/ChrootEveryone ' );
517523 }
518524
519- function configure_mydns () {
525+ public function configure_mydns ()
526+ {
520527 global $ conf ;
521528
522529 // configure pam for SMTP authentication agains the ispconfig database
523530 $ configfile = 'mydns.conf ' ;
524531 if (is_file ($ conf ["dist " ]["mydns " ]["config_dir " ].'/ ' .$ configfile )) copy ($ conf ["dist " ]["mydns " ]["config_dir " ].'/ ' .$ configfile ,$ conf ["dist " ]["mydns " ]["config_dir " ].'/ ' .$ configfile .'~ ' );
525532 if (is_file ($ conf ["dist " ]["mydns " ]["config_dir " ].'/ ' .$ configfile .'~ ' )) exec ('chmod 400 ' .$ conf ["dist " ]["mydns " ]["config_dir " ].'/ ' .$ configfile .'~ ' );
526533 $ content = rf ("tpl/ " .$ configfile .".master " );
527- $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ conf [" mysql " ][ " ispconfig_user " ],$ content );
528- $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ conf [" mysql " ][ " ispconfig_password " ], $ content );
529- $ content = str_replace ('{mysql_server_database} ' ,$ conf [" mysql " ][ " database " ],$ content );
534+ $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ this -> conf [' mysql ' ][ ' ispconfig_user ' ],$ content );
535+ $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ this -> conf [' mysql ' ][ ' ispconfig_password ' ], $ content );
536+ $ content = str_replace ('{mysql_server_database} ' ,$ this -> conf [' mysql ' ][ ' database ' ],$ content );
530537 $ content = str_replace ('{mysql_server_host} ' ,$ conf ["mysql " ]["host " ],$ content );
531538 $ content = str_replace ('{server_id} ' ,$ conf ["server_id " ],$ content );
532539 wf ($ conf ["dist " ]["mydns " ]["config_dir " ].'/ ' .$ configfile ,$ content );
0 commit comments