Changeset 2695


Ignore:
Timestamp:
03/13/10 17:31:46 (2 years ago)
Author:
nuxwin
Message:
  • [SETUP] Fixed #2279: Update Old disabled domain style to the new
Location:
branches/omega-1.0.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/omega-1.0.5/CHANGELOG

    r2692 r2695  
    11ispCP ω 1.0.5 Changelog 
    22~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     3 
     42010-03-13 Laurent Declercq 
     5        - SETUP: 
     6                * Fixed #2279: Update Old disabled domain style to the new 
    37 
    482010-03-12 Laurent Declercq 
  • branches/omega-1.0.5/engine/setup/ispcp-update

    r2666 r2695  
    4646use warnings; 
    4747 
    48 # FIXME: Check if it ok for all dist 
    4948use Term::ReadKey; 
    50  
    51 # Todo Add this package to package files 
    52 # (i.e. Debian: libfile-mimeinfo-perl) 
     49use Net::LibIDN ':all'; 
    5350use File::MimeInfo::Magic; 
    54  
    5551use Term::ANSIColor qw(:constants colored); 
    5652$Term::ANSIColor::AUTORESET = 1; 
     
    200196        $print = ' Please wait, this may take some time:'; 
    201197        print STDOUT "\n\t" . $print; 
     198 
     199        # First, we update old disabled domain style to new 
     200        if($main::cfg{'BuildDate'} <= 20100228) { 
     201                $rs = update_old_disabled_dmn_layout(); 
     202                exit_msg(str_to_right('[failed]', length($print)), $rs) if($rs != 0); 
     203        } 
     204 
    202205        $rs = rebuild_customers_cfg(); 
    203206        exit_msg(str_to_right('[failed]', length($print)), $rs) if($rs != 0); 
     
    855858} 
    856859 
     860# Update old disabled domain style to new 
     861# 
     862# This method is called only if the BuildDate of the current 
     863# ispCP version installed is less than or equal to 20100228 
     864# @Since 1.0.5 
     865sub update_old_disabled_dmn_layout { 
     866 
     867        push_el(\@main::el, 'update_old_disabled_dmn_layout()', 'Starting...'); 
     868 
     869        my ($rs, $rdata) = (undef, undef, undef); 
     870 
     871        my $httpd_uid = getpwnam $main::cfg{'APACHE_USER'}; 
     872        my $httpd_gid = getgrnam $main::cfg{'APACHE_GROUP'}; 
     873        my $log_file = '/tmp/ispcp-update-disabled_layout.log'; 
     874 
     875        my $dsd_dmn_skel_dir = "$main::cfg{'GUI_ROOT_DIR'}/domain_disable_page"; 
     876 
     877        # Find all domains disabled and update the layout 
     878        # (eg /var/www/virtual/domain.tld.disabled) 
     879        foreach(map{m@(.*\.disabled)$@} glob "$main::cfg{'APACHE_WWW_DIR'}/*") { 
     880 
     881                #Disabling the DocumentRoot. 
     882                #Here, we verify that it has not already been done to allow the error 
     883                # recovery if the process fail 
     884                if(-e "$_/htdocs" && !-e "$_/htdocs.disabled") { 
     885                        $rs = sys_command_rs( 
     886                                "$main::cfg{'CMD_MV'} $_/htdocs $_/htdocs.disabled &> $log_file" 
     887                        ); 
     888                        return $rs if($rs != 0); 
     889                } 
     890 
     891                # Copy the directory that contain the layout for disabled domains 
     892                $rs = sys_command_rs( 
     893                        "$main::cfg{CMD_CP} -TRfp $dsd_dmn_skel_dir $_/htdocs &> $log_file" 
     894                ); 
     895                return $rs if($rs != 0); 
     896 
     897                # Building the disabled page - Begin 
     898 
     899                # Get toUnicode domain name 
     900                my $unicode_dmn_name = undef; 
     901                if(m@.*/(.*)\.disabled$@) { 
     902                        $unicode_dmn_name = idn_to_unicode($1, 'utf-8'); 
     903                } else { 
     904                        push_el( 
     905                                \@main::el, 
     906                                'update_old_disabled_dmn_layout()', 
     907                                "ERROR: Unable to retrieve the domain name from the path!" 
     908                        ); 
     909 
     910                        return -1; 
     911                } 
     912 
     913                # Get the disabled raw page 
     914                ($rs, $rdata) = get_file("$_/htdocs/index.html"); 
     915                return $rs if ($rs != 0); 
     916 
     917                # Prepare tags 
     918                my %tag_hash = ( 
     919                        '{DOMAIN_NAME}' => $unicode_dmn_name, 
     920                        '{BASE_SERVER_VHOST}' => $main::cfg{'BASE_SERVER_VHOST'} 
     921                ); 
     922 
     923                # Replace tags 
     924                ($rs, $rdata) = prep_tpl(\%tag_hash, $rdata); 
     925                return $rs if ($rs != 0); 
     926 
     927                # Store the file with proper permissions 
     928                $rs = store_file( 
     929                        "$_/htdocs/index.html", 
     930                        $rdata, 
     931                        $main::cfg{'APACHE_USER'}, 
     932                        $main::cfg{'APACHE_GROUP'}, 
     933                        0644 
     934                ); 
     935                return $rs if ($rs != 0); 
     936 
     937                # Building of the disabled page - End 
     938 
     939                # Set permissions for the new DocumentRoot 
     940                $rs = setfmode( 
     941                        "$_/htdocs", 
     942                        $main::cfg{'APACHE_USER'}, 
     943                        $main::cfg{'APACHE_GROUP'}, 
     944                        0755 
     945                ); 
     946                return $rs if ($rs != 0); 
     947 
     948                # Set permissions for htdocs/images directory 
     949                $rs = setfmode( 
     950                        "$_/htdocs/images", 
     951                        $main::cfg{'APACHE_USER'}, 
     952                        $main::cfg{'APACHE_GROUP'}, 
     953                        0755 
     954                ); 
     955                return $rs if ($rs != 0); 
     956 
     957                # Set permissions for all files under .../htdocs/images 
     958                chmod 0644, glob "$_/htdocs/images/*"; 
     959                chown $httpd_uid, $httpd_gid, glob "$_/htdocs/images/*"; 
     960 
     961                # Move (eg /var/www/virtual/domain.tld.disabled) 
     962                # To (eg /var/www/virtual/domain.tld) 
     963                if(m@(.*)\.disabled$@) { 
     964                        $rs = sys_command_rs( 
     965                                "$main::cfg{'CMD_MV'} $_ $1 &> $log_file" 
     966                        ); 
     967                        return $rs if($rs != 0); 
     968                } else { 
     969                        push_el( 
     970                                \@main::el, 
     971                                'update_old_disabled_dmn_layout()', 
     972                                "ERROR: Unable to retrieve the domain name path!" 
     973                        ); 
     974 
     975                        return -1; 
     976                } 
     977        } 
     978 
     979        push_el(\@main::el, 'update_old_disabled_dmn_layout()', 'Ending...'); 
     980 
     981        0; 
     982} 
     983 
    857984# 
    858985## Subroutines - End 
Note: See TracChangeset for help on using the changeset viewer.