#!/usr/bin/perl -w #2007-03-17 18:45 use POSIX; $cdrom_path = "/media/cdrom0"; $target_path = "."; $do_mount = 1; $ftw = "Success.wav"; sub new_target_dir(); sub wait_for_mount(); umask(0022); chdir($target_path); while (1) { print "Enter DISK LABEL (warez name) and press enter\n"; $disklabel=; chomp $disklabel; `eject -t`; if ($do_mount) { `mount $cdrom_path`; print "Mount ok!\n"; } wait_for_mount(); $target = ($disklabel eq "") ? new_target_dir() : $disklabel; print "Copying files to $target\n"; print "Preforming rsync. Please wait.\n"; mkdir($target,0755); $log=`rsync -rltvz $cdrom_path/ $target`; print "Log file: $target/rsync.log\n"; open F, ">> $target/rsync.log"; print F $log; close F; print "Done!\n\n"; `eject`; `mplayer $ftw`; if ($target =~ /unknown$/) { print "Do you want to rename the iso now? "; $ans=; chomp $ans; if ($ans =~ /^y/i) { print "Input new name: "; $newtarget = ; chomp $newtarget; print `mv -v $target $newtarget`; } } } sub wait_for_mount() { local $mounted=0; print "Waiting for mount to complete: "; while (!$mounted) { open MOUNTS, "/proc/mounts"; @lines = ; close MOUNTS; @lines = grep(/$cdrom_path/,@lines); $mounted = ($#lines >= 0); if (!$mounted) { sleep(1); print "."; } } print " OK!\n"; } sub new_target_dir() { chdir($target_path); local $counter=1; $target_dir = sprintf("CDROM-%04d",$counter); while ( -d $target_dir ) { ++$counter; $target_dir = sprintf("CDROM-%04d",$counter); } return $target_dir; }