K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / share / doc / apache2 /
server ip : 104.21.89.46

your ip : 172.69.214.17

H O M E


Filename/usr/share/doc/apache2/migrate-sites.pl
Size1.48 kb
Permissionrw-r--r--
Ownerroot : root
Create time27-Apr-2025 10:07
Last modified26-Nov-2018 20:08
Last accessed07-Jul-2025 00:07
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
#! /usr/bin/perl

#
# Rename existing sites in $SITES_AVAILABLE to make sure they have a
# .conf suffix. update symlinks in $SITES_ENABLED if necessary
#
# Warning: This script does not work if you didn't use a2ensite/a2dissite to
# manage your sites
#

use strict;
use File::Copy;
use File::Spec;
use File::Basename;

my $SITES_AVAILABLE = "/etc/apache2/sites-available";
my $SITES_ENABLED = "/etc/apache2/sites-enabled";

my %SITES = (
"$SITES_AVAILABLE" => [],
"$SITES_ENABLED" => []
);

sub error
{
my $reason = shift;
print STDERR "$reason\n";
exit 1;
}

foreach my $key (keys %SITES)
{
error("No such directory: $key") unless -d $key;

opendir(DIR, $key) || error("$key: $!");
push $SITES{$key}, grep { m#^[^\.]# && $_ !~ m/default|default-ssl/ && $_ !~ m#\.conf$# } readdir(DIR);
closedir(DIR);
}

foreach my $site (@{ $SITES{$SITES_AVAILABLE} })
{
print("rename $site -> $site.conf\n");
my $curname = $SITES_AVAILABLE . "/" . $site;
my $newname = $curname . ".conf";
my $curlink = $SITES_ENABLED . "/" . $site;
my $newlink = $curlink . ".conf";

if (-e $curname)
{
move($curname, $newname) || error("Could not rename file $curname: $!");
if ( grep { $_ eq $site && -l $SITES_ENABLED . "/" . $_ } @{ $SITES{$SITES_ENABLED} } )
{
print("re-enable site: $site as $site.conf\n");
symlink( File::Spec->abs2rel( $newname, dirname($newlink)), $newlink ) || error("Could not create link $newlink: $1");
if ( -l $curlink )
{
unlink($curlink)
}
}
}
}