2 # Checks for modules available in an old install of webmin that are
3 # not included in this new install, and offers to copy them across.
4 # Also re-creates clones of existing modules in the new install
6 ($newdir, $olddir, $copythird) = @ARGV;
10 while($m = readdir(DIR)) {
11 next if ($m =~ /^\./);
12 if (-r "$olddir/$m/module.info" && !-r "$newdir/$m/module.info") {
13 if (-l "$olddir/$m") {
14 # Found a clone - recreate it
15 $clone = readlink("$olddir/$m");
16 symlink($clone, "$newdir/$m");
19 # Found a candidate for copying
21 &read_file("$olddir/$m/module.info", \%minfo);
23 push(@missdesc, $minfo{'desc'});
26 elsif (-r "$olddir/$m/theme.info" && !-r "$newdir/$m/theme.info") {
27 # Found a theme for copying
29 &read_file("$olddir/$m/theme.info", \%tinfo);
31 push(@missdesc, $tinfo{'desc'});
37 # Tell the user, and ask whether to copy
39 print "The following third party modules were found in your old Webmin\n";
40 print "installation in $olddir :\n";
41 for($i=0; $i<@missing; $i++) {
42 printf " %-12.12s %s\n", $missing[$i], $missdesc[$i];
44 print "Copy to new Webmin installation (y/n): ";
45 chop($resp = <STDIN>);
46 $copythird = $resp =~ /^y/i;
49 foreach $m (@missing) {
50 system("cp -rp $olddir/$m $newdir");
55 # read_file(file, array)
56 # Fill an associative array with name=value pairs from a file
61 open(ARFILE, $_[0]) || return 0;
64 if (!/^#/ && /^([^=]+)=(.*)$/) { $$arr{$1} = $2; }